All you have to do is set a generic key to your payload which in your case looks like title. So when you send a push (as data/payload/json), when user receives one you cross reference the valueForKey:
As always, I highly encourage you try things out yourself because that's how you learn. And I always direct Parse users to their documentation because they are extremely well-documented. Almost too documented if that's a thing. However if you get stuck here is a working example:
Construct a push with payload:
NSDictionary *data = @{
@"alert" : @"some generic message here",
@"badge" : @"Increment",
@"sounds" : @"default",
@"title" : @"NY Times" //this is whatever you want
};
//schedule the push with some options. This isn't a mandatory set up, just an example. You can do a lot with PFPushes
PFPush *push = [[PFPush alloc] init];
[push setChannels:@[ @"subscribed" ]];
[push setData:data];
[push sendPushInBackground];
Now all you have to is see if the value in the payload for the key title matches your needs :
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
. . .
// Extract the notification data from payload
NSDictionary *notificationPayload = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey];
NSString *newsType = [notificationPayload valueForKey:@"title"];
// perform segue or tab bar selectedIndex or whatever you want after checking if user is launching from notification :
if (notificationPayload) {
//check it title has your string
if ([newsType isEqualToString:@"NY Times"]) {
//do whatever here
} else {
}
}
}
references - please use these liberally, they've done great with providing this up-to-date resource to us
Parse iOS Push : https://parse.com/docs/push_guide#top/iOS
Parse SDK https://parse.com/docs/ios/api/
Push Notification from Parse console :
{
"aps" : {
"alert" : "New NY Time Article",
"badge" : 1,
"sound" : "default",
"title" : "NY Times"
}
}
For reference this will get you started : https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW15