我正在使用iOS
处理APNS
次通知。我可以发送和接收通知。我想在手机上保存这些通知。例如,我的应用程序通过APNS
收到每日温度状态通知,此消息类似于" temp:25C 16.08.2016"。我希望在收到通知时将此消息保存在手机用户默认值中。当用户想要查看过去的温度时,我想显示列表包含通知消息。列出像;
16.08.2016 25C
15.08.2016 26C
14.08.2016 21C 。 。
答案 0 :(得分:1)
您可以application:didReceiveRemoteNotification:
userInfo
方法从bower install
获取该内容。
答案 1 :(得分:-1)
在appDelegate.m
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
//Handle notification when the user click it while app is running in background or foreground.
//Get Custom field data 1618
NSLog(@"%@",userInfo );
if(application.applicationState == UIApplicationStateInactive) {
NSLog(@"Inactive - the user has tapped in the notification when app was closed or in background");
//do some tasks
}
else if (application.applicationState == UIApplicationStateBackground) {
NSLog(@"application Background - notification has arrived when app was in background");
//do some tasks
}
else {
NSLog(@"application Active - notication has arrived while app was opened");
//do some tasks
}
}