ios - Parse push notification: How to use custom payload -


i'm using following json send push notification in parse.

{   "alert": "push title goes here",   "sound": "",   "url": "emap://video/4000" } 

the url emap://video/4000 points specific video inside app if type in safari , hit enter. want user sent video when clicks on notification. why doesn't above json achieve this?

so sending payload :

nsdictionary *data = @{     @"alert" : @"some generic message here",     @"badge" : @"increment",     @"sound" : @"default",     @"url" : @"emap://video/4000" };     

and when user interacts act accordingly :

- (void)application:(uiapplication *)application didreceiveremotenotification:(nsdictionary *)userinfo {      if (application.applicationstate == uiapplicationstateinactive) {       [self handleremotenotificationwithpayload:userinfo];     } }  -(void)handleremotenotificationwithpayload:(nsdictionary *)payload {      if (payload) {        nsstring *urllink = [payload valueforkey:@"url"];        // perform segue or tab bar selectedindex or open webview whatever want after checking if user launching notification :     } } 

you should call in application didfinishlaunchingwithoptions: in case users app has been terminated or released memory:

- (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { ...     nsdictionary *notificationpayload = launchoptions[uiapplicationlaunchoptionsremotenotificationkey];     [self handleremotenotificationwithpayload:notificationpayload]; ... } 

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -