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