I want to integrate Firebase Cloud Messaging with my application, but when I run the application, I am getting following errors:
<FIRMessaging/WARNING> FIRMessaging registration is not ready with auth credentials.
Unable to connect to FCM. Error Domain=com.google.fcm Code=501 "(null)"
Here is my code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_7_1) {
// iOS 7.1 or earlier
UIRemoteNotificationType allNotificationTypes =
(UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge);
[application registerForRemoteNotificationTypes:allNotificationTypes];
} else {
// iOS 8 or later
// [END_EXCLUDE]
UIUserNotificationType allNotificationTypes =
(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge);
UIUserNotificationSettings *settings =
[UIUserNotificationSettings settingsForTypes:allNotificationTypes categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
[FIRApp configure];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tokenRefreshNotification:) name:kFIRInstanceIDTokenRefreshNotification object:nil];
return YES;
}
A possible answer is that you haven't added your Apple APS Certificates for Dev and Production. These are required to send push notifications on iOS. You do have to have a Paid Apple Developer's license to generate these certificates. To generate these, open this link, and then go to certificates, and click the plus button in the top right hand corner to create a new certificate. Then follow the instructions on the following pages until you have downloaded the signed certificate from Apple. Then go to the firebase console and then to your project. Then click on the gear, and then on project settings. Open cloud messaging, and then at the bottom, upload your dev and production certificates and enter the passwords you used when creating them. Hope this helps, if you have any trouble, feel free to ask.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With