natsumiyu
natsumiyu

Reputation: 3257

Cannot receive notification in iOS using Firebase

I'm using the Firebase console in testing to receive a notification in my iOS. At first it says that I'm connected to Firebase and I receive the Message ID but then I'm having an error Warning: Application delegate received call to -application:didReceiveRemoteNotification:fetchCompletionHandler: but the completion handler was never called. and Unable to connect to FCM. Error Domain=com.google.fcm Code=2001 "(null)" How can I solve this?

Here is my code for 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]

Upvotes: 3

Views: 1144

Answers (1)

RockoDev
RockoDev

Reputation: 524

Try adding:

completionHandler(UIBackgroundFetchResultNoData);

At the end of your didReceiveRemoteNotification method.

Upvotes: 2

Related Questions