I. APNS
1. Registration
[Cpp]
[[UIApplication sharedApplication] registerForRemoteNotificationTypes: UIRemoteNotificationTypeBadge | uiremotenotiftypetypesound | UIRemoteNotificationTypeAlert];
[[UIApplication sharedApplication] registerForRemoteNotificationTypes: UIRemoteNotificationTypeBadge | uiremotenotiftypetypesound | UIRemoteNotificationTypeAlert];
2. server push (JAVA)
[Java]
PushNotificationPayload payLoad = PushNotificationPayload. fromJSON (message );
PayLoad. addAlert ("iphone push test www.baidu.com"); // message content
PayLoad. addBadge (count); // the value in the red circle on the iphone app icon
PayLoad. addSound ("default"); // ringtone default
PushNotificationPayload payLoad = PushNotificationPayload. fromJSON (message );
PayLoad. addAlert ("iphone push test www.baidu.com"); // message content
PayLoad. addBadge (count); // the value in the red circle on the iphone app icon
PayLoad. addSound ("default"); // ringtone default
Ii. Procedures
1. Vibration
Add system framework:
[Cpp]
# Import <AudioToolbox/AudioToolbox. h>
# Import <AudioToolbox/AudioToolbox. h>
Call the vibration code:
[Cpp]
AudioServicesPlaySystemSound (kSystemSoundID_Vibrate );
AudioServicesPlaySystemSound (kSystemSoundID_Vibrate );
2. Message sound
2.1 system sound
[Cpp]
AudioServicesPlaySystemSound (1007 );
AudioServicesPlaySystemSound (1007); 1007 indicates the number of the system sound, and other available numbers:
Iphone sound effects
2.2 user sound effects
[Cpp]
// Audio file path
NSString * path = [[NSBundle mainBundle] pathForResource: @ "message" ofType: @ "wav"];
// Assemble and Play Sound Effects
SystemSoundID soundID;
NSURL * filePath = [NSURL fileURLWithPath: path isDirectory: NO];
AudioServicesCreateSystemSoundID (_ bridge CFURLRef) filePath, & soundID );
AudioServicesPlaySystemSound (soundID );
// Sound stops
AudioServicesDisposeSystemSoundID (soundID );
// Audio file path
NSString * path = [[NSBundle mainBundle] pathForResource: @ "message" ofType: @ "wav"];
// Assemble and Play Sound Effects
SystemSoundID soundID;
NSURL * filePath = [NSURL fileURLWithPath: path isDirectory: NO];
AudioServicesCreateSystemSoundID (_ bridge CFURLRef) filePath, & soundID );
AudioServicesPlaySystemSound (soundID );
// Sound stops
AudioServicesDisposeSystemSoundID (soundID );