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

Not receiving push notifications in prod (or ad hoc build)

Open shinzao opened this issue 9 years ago • 31 comments

Hi, I have exactly le same problem that the issue #201 ,

Into my .plist, I have : capture d ecran 2017-01-06 a 09 41 22

And into my Delegate, I've tried many things like : FIRInstanceID.instanceID().setAPNSToken(deviceToken, type: FIRInstanceIDAPNSTokenType.sandbox)

or FIRInstanceID.instanceID().setAPNSToken(deviceToken, type: FIRInstanceIDAPNSTokenType.prod)

or with .unknown also. Everything work in development but not in prod (or ad Hoc).

This is a screenshot of my code : capture d ecran 2017-01-06 a 09 58 32

Do you have an idea ?

Thanks in advance, Antoine

shinzao avatar Jan 06 '17 09:01 shinzao

Hi guys,

Still have this problem, any idea ?

Thanks in advance

shinzao avatar Jan 10 '17 16:01 shinzao

Same here. Moreover, I don't get notifications in ad hoc build at all. I've tried to set FirebaseAppDelegateProxyEnabled flag to YES and even remove it, it didn't help.

Is it possible that if build an app for App Store it will work? If it's not the reason, then why it's happening?

Update: Now, i'm trying to build an ad hoc build. Still nothing, neither from console nor through API:

  • I've got FirebaseAppDelegateProxyEnabled flag removed.
  • I've checked that didRegisterForRemoteNotificationsWithDeviceToken get called with not nil value.
  • FIRInstanceID.instanceID().token() is not nil.
  • And eventually FIRMessaging.messaging().connectWithCompletion callback returns without an error.

With FirebaseAppDelegateProxyEnabled flag set to YES:

  • sometimes FIRInstanceID.instanceID().token() is nil.
  • but eventually FIRInstanceID.instanceID().token() is not nil and FIRMessaging.messaging().connectWithCompletion callback returns without an error.

In all cases didReceiveRemoteNotification don't get called when I'm sending message from Firebase console.

What could possibly go wrong?

snok3r avatar Jan 11 '17 12:01 snok3r

Hello everyone,

I have the same problem... While developing an app everything works perfect (with the Firebase Console). After deploying an app to the TestFlight, push notifications stop working... Has anyone managed to resolve it?

psmoq avatar Jan 11 '17 21:01 psmoq

Hey guys, I just find a way to solve it.

I revoked all certification (on my apple developper account and firebase), recreated and reuploaded. Now, everything works.

shinzao avatar Jan 11 '17 22:01 shinzao

@shinzao Hi! Could you please be more specific, did you revoke all certificates or just for push notifications? And how do you revoke certificates on firebase? Also, it would be very helpful if you wrote the steps you've taken.

Thanks in advance!

Update: I assume you sticked with FirebaseAppDelegateProxyEnabled flag set to NO? Did you write something else except from setAPNSToken? Also, I found that I have a weird target settings: screen shot 2017-01-12 at 13 19 14 maybe something wrong?

snok3r avatar Jan 12 '17 10:01 snok3r

@snok3r, About the Code Signing Identity setting, this is the recommended way.

Also, you revoke a certificate from this page, specifically, the ones with the type Apple Push Services. You don't need to revoke all your certificates. On Firebase you need to upload the .cer file after re-generating the revoked certificates.

revolter avatar Jan 12 '17 10:01 revolter

@revolter thanks! You mean .p12 file?

@shinzao About provisioning profiles, did you create them on your own like Firebase tutorial says or let XCode to do it?

snok3r avatar Jan 12 '17 10:01 snok3r

It finally worked! I think right Project and Target settings along with recreation of this certificates helped!

@revolter @shinzao Thank you guys soooo much!

snok3r avatar Jan 12 '17 12:01 snok3r

@snok3r, Glad it worked, you're welcome.

revolter avatar Jan 12 '17 13:01 revolter

@shinzao @revolter @snok3r

Thank you guys! Finally got it to work! THANKS THANKS THANKS!!!

hyd00 avatar Jan 13 '17 09:01 hyd00

@snok3r so... This is correct? captura de pantalla 2017-01-16 a las 11 27 21 p m

captura de pantalla 2017-01-16 a las 11 28 03 p m

--and not revoke my Apple Push Services Certificate? from my "developer account"

xhidnoda avatar Jan 17 '17 02:01 xhidnoda

@xhidnoda hi! Yes, I have the same Target settings and info.plist keys. I've revoked the two distribution certificates: iOS Distribution and Apple Push Services. After you've done this, don't forget to reupload your newly generated .p12 to Firebase.

snok3r avatar Jan 17 '17 07:01 snok3r

THANKS @snok3r

Apparently the only solution is:

  1. Revoke the certificate and create new ones
  2. Don't forget to upload in firebase the new .p12 again

Will confirm this...later

xhidnoda avatar Jan 18 '17 01:01 xhidnoda

Finally work for me...

Here my steps:

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.

Thanks to all..!

xhidnoda avatar Jan 24 '17 14:01 xhidnoda

@xhidnoda I tried your solution starting from the beginning and it finally worked ! Not sure but the only thing I remember doing different was exporting the APN certificate by selecting both certificate and private key. This time I exported only the certificate without the private key.

fanals avatar Feb 04 '17 00:02 fanals

@snok3r @revolter Hi guys! Did you have a problem about that: When calling FIRInstanceID.instanceID().setAPNSToken(deviceToken, type: FIRInstanceIDAPNSTokenType.prod) in Appdelegate method, the tokenRefreshNotificationcallBack be invoked infinitely.... By the way, the scheme I set release But in debug scheme and FIRInstanceIDAPNSTokenType.sandBox, everything work fine..

ghost avatar Mar 22 '17 12:03 ghost

@canny09 I am facing the same problem. Did you get any solution?

rahulgarg12 avatar Mar 28 '17 18:03 rahulgarg12

@rahulgarg12 Hi ! I got the problem because I set FirebaseAppDelegateProxyEnabled value for NO in info.plist. So reset the value with YES will work fine for me. Try.

ghost avatar Mar 29 '17 02:03 ghost

@canny09 Yes everything works fine when i enable Method Swizzling. But when I disable it and set token programmatically, on prod instance id is nil everytime and tokenRefreshNotification gets called infinitely. I want to know why this is happening.

rahulgarg12 avatar Mar 29 '17 06:03 rahulgarg12

@rahulgarg12 YES! The situation same as yours. En.. I also want to know the reason.

ghost avatar Mar 29 '17 11:03 ghost