quickstart-ios icon indicating copy to clipboard operation
quickstart-ios copied to clipboard

Push Notifications only works when the provisioning profile is iOS development type, AdHoc and Production not working

Open zhenjiangliu24 opened this issue 5 years ago • 6 comments

Similar issue as https://github.com/firebase/quickstart-ios/issues/207

When the provisioning profile type is Development, everything works as expected When the provisioning profile type is Ad hoc or Production, no push notification is delivered

Versions for FirebaseMessagingBinary and all other Firebase SDKs: 6.32.0

What I have already tried:

  1. Approach One, followed https://github.com/firebase/quickstart-ios/issues/207#issuecomment-274820033:

1 - Make sure to Enable FirebaseAppDelegateProxyEnabled to YES in the info.plist 2- Revoke your certificate (APNS develop and distribution) and create a news ones 3 - NOTE: 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. 4 - Make sure you upload to the Firebase console this .p12 file in the Cloud Messaging APN certificate settings. 5- Send remote notification with Firebase Console.

  1. Approach Two: followed https://stackoverflow.com/a/41696213
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

}
  1. Approach Three:

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

Any ideas about how to solve this issue, please

zhenjiangliu24 avatar Sep 15 '20 08:09 zhenjiangliu24

Please help

zhenjiangliu24 avatar Sep 30 '20 03:09 zhenjiangliu24

What version of Firebase are you using? You should be able to set the APNs token without setting the type without issues.

morganchen12 avatar Sep 30 '20 16:09 morganchen12

@morganchen12 the firebase iOS SDK version is 6.32.0

zhenjiangliu24 avatar Oct 02 '20 07:10 zhenjiangliu24

Unfortunately I won't be able to help much without a reproducible example, but you can try using Messaging.messaging().apnsToken = deviceToken instead of explicitly specifying the token type.

morganchen12 avatar Oct 02 '20 16:10 morganchen12

@morganchen12 I have already tried this, but no luck func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { Messaging.messaging().setAPNSToken(deviceToken as Data, type: .unknown) }

zhenjiangliu24 avatar Oct 06 '20 04:10 zhenjiangliu24

any updates on this? I experience the exact same issue with firebase_messaging 9.1.3

jwoyo avatar May 05 '21 09:05 jwoyo