我现在有这个问题,我需要在应用程序在后台时处理推送通知的信息,我的意思是,即使不点击通知。 这意味着这个application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler 必须在后台调用! 这是我的代码
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
NSLog(@"full message %@", userInfo);
NSDictionary *aps = [userInfo objectForKey:@"aps"];
NSLog(@"full aps %@", aps);
NSString *custom = [userInfo objectForKey:@"custom"];
NSLog(@"full custom %@",custom);
completionHandler(UIBackgroundFetchResultNewData);
[[NSNotificationCenter defaultCenter] postNotificationName:@"notificationRemote" object:nil userInfo:userInfo];
}
我真的需要处理这些信息,以便在每次收到任何通知时都将其保存到本地,无论我是否点击推送通知。
我搜索并发现我的负载需要可用内容,但我无法在 Firebase 控制台通知中找到它。
最佳答案
是的,您需要有效负载中的内容可用 key 才能静默推送通知。
更多关于FCM,你可以看这个链接: Firebase silent apns notification
关于ios - 处理程序远程通知背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44111214/