我想在应用关闭时从推送通知中获取数据。我正在使用下面给出的以下代码:
- (void) applicationUIApplication *)application didReceiveRemoteNotificationNSDictionary *)userInfo fetchCompletionHandlervoid (^)(UIBackgroundFetchResult))completionHandler
{
NSDictionary *aps = userInfo[@”aps”];
if (state == UIApplicationStateInactive){
// user tapped notification
NSLog(@"results%@",aps);
completionHandler(UIBackgroundFetchResultNewData);
} else {
// app is active
completionHandler(UIBackgroundFetchResultNoData);
}
}
在上面的代码中 NSLog(@"results%@",aps);应用程序在后台时不会打印值。请帮帮我
didReceiveRemoteNotification 仅在您点击通知时有效。所以它只会在您点击通知时为您提供数据,并且您的应用会打开。
如果要获取 NSDictionary *aps = userInfo[@”aps”];当您的应用程序处于终止状态时,您必须实现 pushkit 框架。
您可以从 1 my answer 下载示例代码
Can someone share a sample code of iOS Xamarin PushKit in C#?
Register for voip notifications outside of app delegate
来源 https://github.com/hasyapanchasara/PushKit_SilentPushNotification
关于ios - 关闭应用程序时如何从推送通知中获取数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38429156/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |