Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase push notifications not working for production on iOS

I integrated Firebase Messaging SDK into my iOS project, created a push notification certificate for development and one for production, uploaded both p12 keys to Firebase and I do not receive the notifications, but just for development.

The code for registration is good, and it is the same I used for usual APNS, which worked fine.

The same behaviour happens for 3 applications.

Did someone else encounter this problem? Do you have any solutions or suggestions?

like image 218
User123335511231 Avatar asked Dec 15 '16 16:12

User123335511231


People also ask

Does Firebase notification work on iOS?

For Apple client apps, you can receive notification and data payloads up to 4000 bytes over the Firebase Cloud Messaging APNs interface.

How do I enable push notifications on iOS?

Go to Settings and tap Notifications. Select an app under Notification Style. Under Alerts, choose the alert style that you want. If you turn on Allow Notifications, choose when you want the notifications delivered—immediately or in the scheduled notification summary.

Does iOS support web push notifications?

With iOS 16, Apple will bring support for opt-in web notification support later in 2023, allowing users to receive notifications from websites through Safari and, presumably, other supported browsers on iOS. Apple mentions the feature on the iOS 16 features page, saying it will be coming to iOS in 2023.

Can iOS simulator receive push notifications Firebase?

FCM via APNs does not work on iOS Simulators. To receive messages & notifications a real device is required…


1 Answers

I had the same issue. Apparently there is an error in the Firebase documentation. When you exporting the APN certificate for production from your keychain to the .p12 file you have to select the actual certificate, not the private key.

Make sure you upload to the Firebase console this .p12 file in the Cloud Messaging APN certificate settings.

Swift 4.0

Also make sure you're using:

Messaging.messaging().setAPNSToken(deviceToken as Data, type: .prod)

inside:

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {

    #if DEVELOPMENT
        //Develop
        Messaging.messaging().setAPNSToken(deviceToken as Data, type: .sandbox)
    #else
        //Production
        Messaging.messaging().setAPNSToken(deviceToken as Data, type: .prod)
    #endif

}
like image 52
andrew_b Avatar answered Sep 21 '22 04:09

andrew_b