IOS new Message Notification tips-sound, vibration

Source: Internet
Author: User

First, APNS
1. Registration
    1. [[uiapplication sharedapplication] registerforremotenotificationtypes:uiremotenotificationtypebadge | Uiremotenotificationtypesound | Uiremotenotificationtypealert];
Copy Code
2. Server push (JAVA)
    1. Pushnotificationpayload payLoad = Pushnotificationpayload.fromjson (message);
    2. Payload.addalert ("iphone push Test www.baidu.com"); Message content
    3. Payload.addbadge (count); The number on the small red circle on the iphone app icon
    4. Payload.addsound ("Default"); Ring tone Default
Copy Code
Ii. in- process
1. Vibration
To add a system framework:
    1. #import <AudioToolbox/AudioToolbox.h>
Copy CodeCall the vibration code:
    1. Audioservicesplaysystemsound (ksystemsoundid_vibrate);
Copy Code 2. Message sounds
2.1 System Sound
    1. Audioservicesplaysystemsound (1007);
Copy Code where 1007 is the number of the system sound, the other available numbers:


With rich iphone system sound effect (click on it)



2.2 User audio
    1. //audio file path   
    2.     NSString *path = [[NSBundle mainbundle] pathforresource:@ "message "oftype:@" wav "];&NBSP;&NBSP;
    3.    /assemble and play sound   
    4.     Systemsoundid Soundi d;  
    5.     Nsurl *filepath = [Nsurl fileurlwithpath:path isdirectory:no];  
    6.     Audioservicescreatesystemsoundid ((__bridge cfurlref) FilePath, &soundid);   
    7.     Audioservicesplaysystemsound (soundid);   
    8.         //sound stop   
    9.         audioservicesdisposesystemsoundid (soundid);  

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.