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
UIAlertview
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
[PFPush handlePush:userInfo];
pushText = [userInfo objectForKey:@"alert"];
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:NSLocalizedString(@"News", "")
message:pushText
delegate:nil
cancelButtonTitle:@"Ok"
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"];