无法使用Firebase

时间:2016-06-03 06:43:30

标签: ios objective-c firebase firebase-cloud-messaging

我在测试中使用Firebase控制台在我的iOS中接收通知。首先它说我已连接到Firebase并收到消息ID,但后来我遇到错误Warning: Application delegate received call to -application:didReceiveRemoteNotification:fetchCompletionHandler: but the completion handler was never called.Unable to connect to FCM. Error Domain=com.google.fcm Code=2001 "(null)"我该如何解决这个问题?

这是我的didReceiveRemoteNotification

代码
// [START receive_message]
 - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
    fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
// If you are receiving a notification message while your app is in the background,
// this callback will not be fired till the user taps on the notification launching the application.
// TODO: Handle data of notification

// Print message ID.
NSLog(@"Message ID: %@", userInfo[@"gcm.message_id"]);

// Pring full message.
NSLog(@"%@", userInfo);
}
// [END receive_message]

1 个答案:

答案 0 :(得分:2)

尝试添加:

completionHandler(UIBackgroundFetchResultNoData);

在didReceiveRemoteNotification方法结束时。