I want to get data from push notification message. I successfully get the data when app is on foreground and in background. but I am unable to get data when app is quit and user press view button on push notification. I write the code in application did finish launching. This code cause the app crash when pressing on View button of push notification message. If I comment the code then app doesn’t crash. Kindly help me to fetch data from push notification when app is quit and user press view button on push notification. I’ll really appreciate that.
if(launchOptions != nil){
NSDictionary *tmpDic = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
if (tmpDic!=nil) {
pushedMessage=[NSString stringWithFormat:@"%@",[[tmpDic objectForKey:@"aps"] objectForKey:@"alert"]];
pushedCountry=[NSString stringWithFormat:@"%@",[tmpDic objectForKey:@"country"]];
[self saveToDatabase];
}
}
When you click view button
this method is called and userinfo will contain all data
Things which you are doing in didfinishlaunch method do in didReceiveRemoteNotification: