Push popup effect on IOS foreground

Source: Internet
Author: User

Specific code: see demo below

Github:https://github.com/yasashi/ebforenotification

Here's how:

1. Add the Ebforenotification folder into the project

2--and-- targets Build Settings 搜 other link添加 -ObjC

3. Local pop-up window

Normal pop-up window (System sound) [Ebforenotification handleremotenotification:@{@ "APS": @{@ "alert": @ "Show content"}} soundid:1312];//normal pop-up window ( Specify sound file) [ebforenotification handleremotenotification:@{@ "APS": @{@ "alert": @ "Show content"}} customsound:@ "My_sound.wav"];/ /Popup with custom parameters (System sound) [Ebforenotification handleremotenotification:@{@ "APS": @{@ "alert": @ "Show content"}, @ "Key1": @ "value1", @ " Key2 ": @" value2 "} soundid:1312];//normal popup (Specify sound file) [ebforenotification handleremotenotification:@{@" APS ": @{@" alert ": @" Show content "}, @" Key1 ": @" value1 ", @" Key2 ": @" value2 "} customsound:@" My_sound.wav "];

4. Accept remote and local push pop-up windows

//ios7 before-(void) Application: (UIApplication *) application Didreceiveremotenotification: (nsdictionary *) UserInfo {...//system sound pop-up [ebforenotification handleremotenotificatio    N:userinfo soundid:1312];    Specify the sound file pop-up [ebforenotification handleremotenotification:userinfo customsound:@ "My_sound.wav"]; ...} iOS7 later-(void) Application: (UIApplication *) application didreceiveremotenotification: (nsdictionary *) userInfo Fetchcompletionhandler: (void (^) (uibackgroundfetchresult)) Completionhandler {...//system sound pop-up window [ebforenotificatio    n Handleremotenotification:userinfo soundid:1312];    Specify the sound file pop-up [ebforenotification handleremotenotification:userinfo customsound:@ "My_sound.wav"]; ... completionhandler (uibackgroundfetchresultnewdata);} 

Note: Soundid parameter: The iOS system comes with the sound ID, the system-level push service is used by default 三全音 , id = 1312, the other system sound ID can be queried here to IOS predefined sounds, alternate address Audioservice s sounds

5, add Observer listening EBBannerViewDidClick , get push content, by pushing the custom fields to handle their own logic, such as: Jump to the corresponding page and so on.

[[Nsnotificationcenter Defaultcenter] addobserver:self selector: @selector (ebbannerviewdidclick:) Name: Ebbannerviewdidclick object:nil];-(void) Ebbannerviewdidclick: (nsnotification*) noti{    if (noti[@ "key1" = = @ " Jump Page 1 "]) {        //Jump to page 1    }}

Push popup effect on IOS foreground

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.