【发布时间】:2018-10-29 19:19:46
【问题描述】:
我正在使用 Firebase 进行分析,并使用库进行推送通知。当我使用其中任何一个时,都会调用 didReceiveRemoteNotification。但是当我同时使用它们时,didReceiveRemoteNotification 不会被调用。
代码:
didFinishLaunchingWithOptions:
NSString *google_app_id = @"----";
NSString *gcm_sender_id = @"----";
FIROptions *o = [[FIROptions alloc] initWithGoogleAppID:google_app_id GCMSenderID:gcm_sender_id];
o.APIKey = @"----";
o.bundleID = @"----";
o.clientID = @"----";
[FIRApp configureWithOptions:o];
// Initilization of push framework
didReceiveRemoteNotification:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
// This method is not called when Firebase and push framework are enabled at the same time
// It works fine when only Firebase or only push framework is enabled
NSLog(@"Push: %@", userInfo);
}
【问题讨论】:
-
您如何注册接收推送通知?
-
@dudeman :推送框架就是这样做的。他们有他们的后端。当框架初始化时,推送,应用注册推送通知。
-
在您注册推送通知后,有回调方法让您知道注册是否成功,并为您提供用于发送通知的推送令牌。您是否尝试过注册是否成功?另外,你用他们给你的令牌做什么?
-
@dudeman : 注册肯定成功。我总是收到推送通知。只是push框架和Firebase都没有调用didReceiveRemoteNotification。
-
你查看过UNUserNotificationCenter developer.apple.com/documentation/usernotifications/…
标签: ios objective-c firebase apple-push-notifications