http://blog.csdn.net/acorld/article/details/9231821
一厘惦、APNS
1.注冊
[cpp] view plain copy print?
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert];
2.服務(wù)器推送(JAVA)
[java] view plain copy print?
PushNotificationPayload payLoad = PushNotificationPayload.fromJSON(message);
payLoad.addAlert("iphone推送測試 www.baidu.com"); // 消息內(nèi)容
payLoad.addBadge(count); // iphone應(yīng)用圖標(biāo)上小紅圈上的數(shù)值
payLoad.addSound("default"); // 鈴音 默認(rèn)
二巾表、程序內(nèi)
1.震動
添加系統(tǒng)框架:
[cpp] view plain copy print?
import <AudioToolbox/AudioToolbox.h>
調(diào)用震動代碼:
[cpp] view plain copy print?
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
2.消息聲音
2.1 系統(tǒng)聲音
[cpp] view plain copy print?
AudioServicesPlaySystemSound(1007);
其中1007是系統(tǒng)聲音的編號袖外,其他的可用編號:
iphone系統(tǒng)聲效
2.2 用戶音效
[cpp] view plain copy print?
//音效文件路徑
NSString *path = [[NSBundle mainBundle] pathForResource:@"message" ofType:@"wav"];
//組裝并播放音效
SystemSoundID soundID;
NSURL *filePath = [NSURL fileURLWithPath:path isDirectory:NO];
AudioServicesCreateSystemSoundID((__bridge CFURLRef)filePath, &soundID);
AudioServicesPlaySystemSound(soundID);
//聲音停止
AudioServicesDisposeSystemSoundID(soundID);