Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
shinzao opened this issue Jan 6, 2017 · 31 comments
Closed

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

shinzao opened this issue Jan 6, 2017 · 31 comments

Comments

@shinzao
Copy link

shinzao commented Jan 6, 2017

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
Copy link
Author

shinzao commented Jan 10, 2017

Hi guys,

Still have this problem, any idea ?

Thanks in advance

@snok3r
Copy link

snok3r commented Jan 11, 2017

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?

@psmoq
Copy link

psmoq commented Jan 11, 2017

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?

@shinzao
Copy link
Author

shinzao commented Jan 11, 2017

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.

@snok3r
Copy link

snok3r commented Jan 12, 2017

@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?

@revolter
Copy link
Contributor

revolter commented Jan 12, 2017

@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.

@snok3r
Copy link

snok3r commented Jan 12, 2017

@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
Copy link

snok3r commented Jan 12, 2017

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

@revolter @shinzao Thank you guys soooo much!

@revolter
Copy link
Contributor

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

@hyd00
Copy link

hyd00 commented Jan 13, 2017

@shinzao @revolter @snok3r

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

@xhidnoda
Copy link

@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"

@snok3r
Copy link

snok3r commented Jan 17, 2017

@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.

@xhidnoda
Copy link

xhidnoda commented Jan 18, 2017

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
Copy link

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..!

@fanals
Copy link

fanals commented Feb 4, 2017

@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.

@ghost
Copy link

ghost commented Mar 22, 2017

@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..

@rahulgarg12
Copy link

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

@ghost
Copy link

ghost commented Mar 29, 2017

@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.

@rahulgarg12
Copy link

@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.

@ghost
Copy link

ghost commented Mar 29, 2017

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

@manenga
Copy link

manenga commented Apr 6, 2017

Same here for iOS. I have the same notification sent to both Android & iOS. Android always receives them and iOS does for a while (maybe a week or 2) then suddenly stops until I go to the firebase console and manually send to the device. This also doesn't work at first, then it starts to work when I send my second notification.

@jrbecart
Copy link

Is is better to use the new .p8 file instead of the .p12 in firebase? Looks like easier to me.
Anyway, I'm trying to solve the same problem and I will try @xhidnoda steps.

@rsattar
Copy link
Contributor

rsattar commented Jun 16, 2017

@jrbecart Yeah, the new .p8 file is Apple's new authentication system and it works much better than the previous .p12 certificates, because:

  1. They don't expire every year.
  2. You can use the same .p8 file to send to all app in that Apple Developer account.
  3. You don't need to do a hard-to-follow export process via Keychain Access. You just upload the .p8 file as Apple gave you.

Be sure you're using the new FCM iOS SDK (version 2.x, as part of Firebase 4.x rolled out in May 2017)

@jrbecart
Copy link

jrbecart commented Jun 17, 2017

I think, I have the same kind of problem when app is in prod.
I get the notification, but in a different way (other method called) and it's hard for me to debug that way... :(
I opened a new issue for this: #296 .

@roberto-rodriguez
Copy link

Similar issue happen to me, I added Push Notifications to an existent app, tested by running using Xcode to my device and it worked well, but when when created the Archive and installed via iTunes, it didn't receive Push Notifications.
The problem was that when I added the permissions for push notifications, my Provisioning Profile got obsolete (Invalid), so I had to generate a new Provisioning Profile, apply to my iTunes/phone, and now when I install the app it works well.

@suvarapuprasad
Copy link

suvarapuprasad commented Jun 27, 2018

@xhidnoda -- your solution worked for me thanks

@vicky462
Copy link

vicky462 commented Nov 15, 2018

I have faced similar issue but after Enable FirebaseAppDelegateProxyEnabled to YES in the info.plist.it is working fine ios 12 but still in ios 10.3.3 push notification not working.Any one face these kinda problem ?? Please help me

@norter
Copy link

norter commented Jan 22, 2019

In addition to everything that is said about rebuilding the push certificates and the possible regeneration of the provisioning profile and the upload of new .p12 to Firebase. We found two possible solutions:
On the one hand: to kill the Apple developers. All this because the problem took us several hours to find it, is the file "name_your_project.entitlements".
When we see it, it is displayed correctly, the ticks appear that everything is ok, but when we export for Ad Hoc, it does not include "production" in "aps-environment", in the last step before generating the .ipa, with that push notifications do not arrive ... In short, to solve this, it is necessary to delete the file "file name_your_project.entitlements", deactivate push notifications in capabilities, and activate them again. This will regenerate the file "file name_your_project.entitlements", and with this, it will already generate in the last step of the Ad Hoc .ipa generation, with the aps-environment in production ...
So, the second, logic and the most boring alternative: Delete the file, desactive the push notifications in capabilities and active them again.

Summarizing.-

  • All the above mentioned (generation of .p12, upload to firebase, etc.)
  • Delete file "name_your_project.entitlements"
  • Deactivate and activate push notifications in Capabilities
  • Re-export for Ad Hoc and check that "aps-environment" comes as "production

@Nephsus
Copy link

Nephsus commented Jan 22, 2019

The error commented by Norter is caused because the reference to the entitlments file is lost. If you go to inactive capabilites and re-activate the push option, you will recreate it. When generating the ipa it is necessary to see that the APS Environment property comes out to production.

I'm Norter's partner: D

@hamza-gaya
Copy link

This issue is not closed at all as flutter plugins faced that or you guys would have fixed on your iphone device what about others iphone devices ??? have you all guys tested that. fluter is generating duplicate and also invalid firebase messaging token after 1 day gap they actually started sending those notifications but this is not a proper solution

@imtoori
Copy link

imtoori commented Jan 3, 2023

I'm experiencing something similar
https://stackoverflow.com/questions/74981072/flutter-fcm-not-working-on-ios-with-release-profile
I hope someone can help me 'cause I'm really struggling here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests