scb998 scb998 - 11 months ago 52
Objective-C Question

Extract "alert" text from push notification

I have the following code placed in my app delegate file. In theory, it should be extracting the message from the push notification and displaying it in a

- yet it displays the title and the candle button, and nothing else. Can anybody see where I am going wrong?

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
[PFPush handlePush:userInfo];
pushText = [userInfo objectForKey:@"alert"];
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:NSLocalizedString(@"News", "")
otherButtonTitles: nil];
[alert show];


The push payload has the following structure:

    "aps" : {
             "alert" : "Push notification text"

So you need to pull out the "aps" dictionary first and then you can retrieve the value for the "alert" key:

 pushText = [[userInfo objectForKey:@"aps"] objectForKey:@"alert"];