CrossGeeks / FirebasePushNotificationPlugin

Firebase Push Notification Plugin for Xamarin iOS and Android
MIT License
394 stars 177 forks source link

iOS Pushnotifications no longer working. #345

Open chromos33 opened 4 years ago

chromos33 commented 4 years ago

Scratch that... I simply forgot to register an APN certificate with Firebase.. Can be Closed

🐛 Bug Report

iOS Push Notifications no longer arrive in the app. RegisteredForRemoteNotifications and OnTokenRefresh get Triggered with (what appears to be) valid data. But when triggering a Notification in https://console.firebase.google.com/project/[projectname]/notification it does not trigger OnNotificationOpened or OnNotificationReceived, though Android works fine.

Expected behavior

OnNotificationOpened or OnNotificationReceived get Triggered and a Notification pops up

Reproduction steps

Install Firebase PushNotification and configure as directed in README Compile/Start App -> let it Register Trigger Pushnotification on Firebase

Configuration

Version: tried with

Platform:

dentep commented 4 years ago

same problem here. notification doesn't arrive after triggering it in firebase console.

Aresak commented 4 years ago

same problem here. notification doesn't arrive after triggering it in firebase console.

Check your public override void FailedToRegisterForRemoteNotifications(UIApplication application, NSError error) { FirebasePushNotificationManager.RemoteNotificationRegistrationFailed(error); }

to see the error.

dentep commented 4 years ago

same problem here. notification doesn't arrive after triggering it in firebase console.

Check your public override void FailedToRegisterForRemoteNotifications(UIApplication application, NSError error) { FirebasePushNotificationManager.RemoteNotificationRegistrationFailed(error); }

to see the error.

no valid “aps-environment” entitlement string found for application

is it about certificate/provisioning profile?

Aresak commented 4 years ago

same problem here. notification doesn't arrive after triggering it in firebase console.

Check your public override void FailedToRegisterForRemoteNotifications(UIApplication application, NSError error) { FirebasePushNotificationManager.RemoteNotificationRegistrationFailed(error); } to see the error.

no valid “aps-environment” entitlement string found for application

is it about certificate/provisioning profile?

Welcome to my world, I'm trying to solve this now too.

Make sure you have the following:

I think the provision profile then needs to be regenerated and set after the identifier is updated which is what I'm having troubles right now.

dentep commented 4 years ago

same problem here. notification doesn't arrive after triggering it in firebase console.

Check your public override void FailedToRegisterForRemoteNotifications(UIApplication application, NSError error) { FirebasePushNotificationManager.RemoteNotificationRegistrationFailed(error); } to see the error.

no valid “aps-environment” entitlement string found for application is it about certificate/provisioning profile?

Welcome to my world, I'm trying to solve this now too.

Make sure you have the following:

  • Info.plist -> Capabilities -> Background modes -> Enable Background modes ON and Remote notifications ON
  • Entitlements.plist -> Push Notifications -> Enabled
  • Have the Push Notifications enabled in the Identifier @ developer.apple.com
  • Have either setup the APN P12s or authentication key @ Firebase application settings

I think the provision profile then needs to be regenerated and set after the identifier is updated which is what I'm having troubles right now.

I was just about to tell you that it works after I have enabled APN in Entitlements.plist.

The only problem now is that the notifications do not arrive when the application is in foreground (arrive fine in the background or when the app is killed). Firebase console shows that the notification is "scheduled" but the notification data shows in the application console if I debug it in VS with all data correct... Screen Shot 2020-09-18 at 7 48 59 PM

Aresak commented 4 years ago

same problem here. notification doesn't arrive after triggering it in firebase console.

Check your public override void FailedToRegisterForRemoteNotifications(UIApplication application, NSError error) { FirebasePushNotificationManager.RemoteNotificationRegistrationFailed(error); } to see the error.

no valid “aps-environment” entitlement string found for application is it about certificate/provisioning profile?

Welcome to my world, I'm trying to solve this now too. Make sure you have the following:

  • Info.plist -> Capabilities -> Background modes -> Enable Background modes ON and Remote notifications ON
  • Entitlements.plist -> Push Notifications -> Enabled
  • Have the Push Notifications enabled in the Identifier @ developer.apple.com
  • Have either setup the APN P12s or authentication key @ Firebase application settings

I think the provision profile then needs to be regenerated and set after the identifier is updated which is what I'm having troubles right now.

I was just about to tell you that it works after I have enabled APN in Entitlements.plist.

The only problem now is that the notifications do not arrive when the application is in foreground (arrive fine in the background or when the app is killed). Firebase console shows that the notification is "scheduled" but the notification data shows in the application console if I debug it in VS with all data correct... Screen Shot 2020-09-18 at 7 48 59 PM

I finally got it for myself running too. I receive notifications sent by the Console in any state of the application (foreground, background or killed).

About the "Scheduled" status - you see it scheduled, since the notification is in their queue and hasn't been sent yet. However if you refresh the page again you will see it in a Completed/Failed status. It's same for android.

I hope you will find the solution for your notifications not being received in the foreground ;)

QualitasGit commented 4 years ago

Hi, I'm currently trying to make this work on iOS. I think I'm pretty close too. -You guys managed to test this on simulator? cause I received an error: cannot use firebase on simulator. so I'm submiting it to test flight everytime I need to test. -Have you changed this section of entitlements?

aps-environment
<string>production</string>

cause it's uncheck entitlements UI and i'm not sure if it's ok -The APN configuration needs any further steps like SSL configuration or something? -Is your certificate marked as "Not in keychain" in Tools->Options->Xamarin->Apple Accounts->View Details ? Sorry for the long question, but I really think I'm very close of doing it

dentep commented 4 years ago

Hi, I'm currently trying to make this work on iOS. I think I'm pretty close too. -You guys managed to test this on simulator? cause I received an error: cannot use firebase on simulator. so I'm submiting it to test flight everytime I need to test. -Have you changed this section of entitlements? aps-environment production cause it's uncheck entitlements UI and i'm not sure if it's ok -The APN configuration needs any further steps like SSL configuration or something? -Is your certificate marked as "Not in keychain" in Tools->Options->Xamarin->Apple Accounts->View Details ? Sorry for the long question, but I really think I'm very close of doing it

  1. I wasn't able to get it working on simulator, I don't think apn works on iOS simulator (I might be wrong)
  2. I didn't change source of the entitlements.plist, just ticked the window that says "enable push notifications"
  3. no If you followed through the tutorial and uploaded p8 key successfully
  4. I don't have "options" under "tools"...?
dentep commented 4 years ago

same problem here. notification doesn't arrive after triggering it in firebase console.

Check your public override void FailedToRegisterForRemoteNotifications(UIApplication application, NSError error) { FirebasePushNotificationManager.RemoteNotificationRegistrationFailed(error); } to see the error.

no valid “aps-environment” entitlement string found for application is it about certificate/provisioning profile?

Welcome to my world, I'm trying to solve this now too. Make sure you have the following:

  • Info.plist -> Capabilities -> Background modes -> Enable Background modes ON and Remote notifications ON
  • Entitlements.plist -> Push Notifications -> Enabled
  • Have the Push Notifications enabled in the Identifier @ developer.apple.com
  • Have either setup the APN P12s or authentication key @ Firebase application settings

I think the provision profile then needs to be regenerated and set after the identifier is updated which is what I'm having troubles right now.

I was just about to tell you that it works after I have enabled APN in Entitlements.plist. The only problem now is that the notifications do not arrive when the application is in foreground (arrive fine in the background or when the app is killed). Firebase console shows that the notification is "scheduled" but the notification data shows in the application console if I debug it in VS with all data correct... Screen Shot 2020-09-18 at 7 48 59 PM

I finally got it for myself running too. I receive notifications sent by the Console in any state of the application (foreground, background or killed).

About the "Scheduled" status - you see it scheduled, since the notification is in their queue and hasn't been sent yet. However if you refresh the page again you will see it in a Completed/Failed status. It's same for android.

I hope you will find the solution for your notifications not being received in the foreground ;)

I think it might be the priority issue...Did you change your priority to "high" anywhere? I am trying to find where I can change this setting now.

QualitasGit commented 4 years ago

I think it might be the priority issue...Did you change your priority to "high" anywhere? I am trying to find where I can change this setting now.

use a https://fcm.googleapis.com/fcm/send post and make sure your payload has "priority": "high" property.

QualitasGit commented 4 years ago

just ticked the window that says "enable push notifications"

if I do this, I cannot archive my app for realease. Have you tested it? It works when I manually change it to production

I don't have "options" under "tools"

it's where you login in your apple account. I'm not sure how to explain beside that. Anyway i'm recreating like my 14th provisioning profile and trying to figure it out

dentep commented 4 years ago

I think it might be the priority issue...Did you change your priority to "high" anywhere? I am trying to find where I can change this setting now.

use a https://fcm.googleapis.com/fcm/send post and make sure your payload has "priority": "high" property.

I didn't quite get that part working with firebase notifications console...

dentep commented 4 years ago

just ticked the window that says "enable push notifications"

if I do this, I cannot archive my app for realease. Have you tested it? It works when I manually change it to production

I don't have "options" under "tools"

it's where you login in your apple account. I'm not sure how to explain beside that. Anyway i'm recreating like my 14th provisioning profile and trying to figure it out

Yes. I had the same problem. Make sure you downloaded the correct profile from your developer account and install it again. Relaunch visual studio after installation. I was stuck at that part for some time, but then the issue was resolved by itself (I just reinstalled the prov. profile).

Also I had to log in VS apple account and click "download all profiles". After that, the entitlements.plist didn't show any error.

QualitasGit commented 4 years ago

Make sure you downloaded the correct profile from your developer account and install it again

I'm not using a developer account. I use VS for windows, use a rent Mac and the only way I can test is by sending a Distribuition version to Test Flight. That's when Entitlements give an error, when archiving

dentep commented 4 years ago

Make sure you downloaded the correct profile from your developer account and install it again I'm not using a developer account. I use VS for windows, use a rent Mac and the only way I can test is by sending a Distribuition version to Test Flight. That's when Entitlements give an error, when archiving

hmmm, how do you generate apple's prov. profiles then?

QualitasGit commented 4 years ago

sorry, I misunderstood. I though you said developer profile. I'm using a developer account with a distribuition profile, not a developer profile

dentep commented 4 years ago

sorry, I misunderstood. I though you said developer profile. I'm using a developer account with a distribuition profile, not a developer profile

alright. so you have your provisioning profile by apple. in vs you need to login into that profile and download it so it matches the entitlements configuration. It worked for me after I logged in inside VS.

dentep commented 4 years ago

BTW. The foreground works when I add this line:

FirebasePushNotificationManager.CurrentNotificationPresentationOption = UNNotificationPresentationOptions.Alert | UNNotificationPresentationOptions.Sound;

adds alert type APN and a sound while in foreground. Perfect!

Aresak commented 4 years ago

BTW. The foreground works when I add this line:

FirebasePushNotificationManager.CurrentNotificationPresentationOption = UNNotificationPresentationOptions.Alert | UNNotificationPresentationOptions.Sound;

adds alert type APN and a sound while in foreground. Perfect!

Oh yea, you are right. I got this too ':D Happy that you found it.

QualitasGit commented 4 years ago

Ok, I added a log to RegisteredForRemoteNotifications FailedToRegisterForRemoteNotifications DidReceiveRemoteNotification I'm able to register to any topic without error, but ReceiveRemoteNotification never trigger by post nor firebase console. It's a known issue?

QualitasGit commented 4 years ago

no If you followed through the tutorial and uploaded p8 key successfully

It worked, this line was the light. I was adding a APN key, not a certificate. It worked from the console. Now I need to figure how to set the POST payload to work too

dentep commented 4 years ago

no If you followed through the tutorial and uploaded p8 key successfully

It worked, this line was the light. I was adding a APN key, not a certificate. It worked from the console. Now I need to figure how to set the POST payload to work too

congrats :) if you figure it out let me know :)

B2alex commented 4 years ago

no If you followed through the tutorial and uploaded p8 key successfully

It worked, this line was the light. I was adding a APN key, not a certificate. It worked from the console. Now I need to figure how to set the POST payload to work too

@HiagoQualitas so do APN key's not work?

QualitasGit commented 4 years ago

@HiagoQualitas so do APN key's not work?

I'm not sure if it works, but for me it doesn't. My iOS device received the first notification as soon as I changed it to the certificate