ios - 处理程序远程通知背景

标签 ios objective-c firebase push-notification apple-push-notifications

我现在有这个问题,我需要在应用程序在后台时处理推送通知的信息,我的意思是,即使不点击通知。 这意味着这个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/

相关文章:

ios - 尝试将OpenTok 2.3添加为本地coapapod

ios - 将 Storyboard转换为 XIB

java - 当 Cardview 移出屏幕时,Recyclerview 不起作用

ios - UIImageView tintColor 设置,无论如何都不对图像应用颜色

iphone - CFReadStream - 在后台启动

ios - -thingWithContentsOfFile : vs. NSPropertyListSerialization

ios - iPhone 应用程序中的 Google 帐户自动登录

ios - CALayer 属性(例如 : drop shadows) not appearing on all UITableViewCells

javascript - 使用 Express 从 Firebase 数据库获取数据

node.js - FireStore 如果不存在则创建一个文档