Notifications for new IOS messages-sound and Vibration

Source: Internet
Author: User

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 );

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.