I want to receive data from a push notification. I successfully receive data when the application is in the foreground and in the background. but I can’t get the data when the application closes, and the button for pressing the user button is on the push notification. I write that the code in the application has completed the launch. This code causes the application to crash when you click on the "View" button for push notifications. If I comment on the code, the application will not work. Please help me get the data from the push notification when the application closes and the user clicks the browse button on the push notification. I really appreciate it.
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];
}
}
source
share