PushSharp - GCM Authorization Failed - notifications

Using v4.0.10 of Pushsharp (nuget package), I am getting error GCM Authorization Failed when sending push notifications to Android devices.
Seems the bug raised in issue 574 (https://github.com/Redth/PushSharp/issues/574 ) has been compiled into the nuget package, yet I'm still getting this error.
Could this be related to the introduction of Firebase Cloud Messaging?
Does anyone still have success using GCM?

As of right now, GCM is still usable. However, it is highly encouraged for new users to use FCM instead. Either way, for both GCM and FCM, you must use a Server Key generated from the Firebase Console. There is a visible note in the GCM docs saying:
Starting from Sept. 2016 new server key can only be created in the Firebase Console using the Cloud Messaging tab of the Settings panel. Existing projects that need to create a new server key can be imported in the Firebase console without affecting their existing configuration.
The Authorization error has been encountered by number of users, some also had an old project. See my answer here for more details.

The sender id used in the app code needs to match the sender id Firebase Cloud Message Console and its corresponding "Firebase Cloud Messaging token".
Thank you #AL for your help.

Related

E/FirebaseInstanceId: Topic sync or token retrieval failed on hard failure exceptions: AUTHENTICATION_FAILED. Won't retry the operation

I try to add FireBase cloud Messaging SDK to my app, and I step and step with the guide of FireBase
1, create an APP in FireBase Dashboard
2, download google-servers.json into Assest folder
3, Import FirebaseMessaging.unitypackage
4, Build app in android studio
5, run app in android simulator(mumu simulator) with AS-debug mode。
then I get the error:
I/firebase: Firebase Cloud Messaging API Initialized
I/Unity: Firebase Cloud Messaging API Initialized
error: E/FirebaseInstanceId: Topic sync or token retrieval failed on hard failure exceptions: AUTHENTICATION_FAILED. Won't retry the operation.
I/Unity: Firebase Messaging Initialized
I/Unity: RequestPermissionAsync completed
I read the issue: https://github.com/firebase/firebase-android-sdk/issues/1286 ,but it's not work
https://github.com/firebase/firebase-android-sdk/issues/1286
I find lot of ways to resolve it, but not work
AUTHENTICATION_FAILED error message is usually caused by an environment issue. Make sure that you are using the latest Google Play Services version available, as well as the latest version of the Firebase SDK.
Also, if your connection has firewall, ensure that you open the ports 5228, 5229, and 5230 (although FCM typically only uses 5228) to properly access FCM. This information can also be seen here.

APNS handle obtained by Expo in React Native is incorrect

EXPO SDK Version: 42.0.01
Developing for: iOS
Our goal: successfully send a test notification from Test Send tool in Azure Notification Hub to a registered physical iPhone which is running a local instance of an EXPO app.
Progress: we're able to successfully register a physical iPhone with Azure Notification Hub without using a 3rd party library. We can see that registration in the Hub.
Issues: when using the Azure's Test Send tool we're getting an error "The Push Notification System handle for the registration is invalid" and the test notification does not get delivered.
Debugging:
we're using EXPO's Notifications.getDevicePushTokenAsync() API to obtain the push token.
Azure support team analysed the logs and concluded that the problem is the PNS handle i.e. Apple's ID of the phone registered for notifications.
the phone's PNS handle remains the same at all times.
by using "expo credentials:manager" I've added a new Push Notification Key using KeyID, TeamID and .p8 certificate - the PNS handle didn't change after doing that and notifications were failing too.
I haven't found any tools to validate the APNS handle. I'm currently awaiting a .p12 certificate from our corporate team to test notifications by using https://pushtry.com/.
How do we validate the APNS handle and if found that it's invalid - how do we cycle it / request another?
The PNS Handle from APNs does not change that often as it is tied to the device and app installation. See this answer for more details Does the APNS device token ever change, once created?

Mobilefirst 8.0 Push notification Implemantation

I have made simple application using Ionic and cordova. Added Mobilefirst plugin in it. Also I have used security adapters in it ResourceAdapter and UserLogin Adapter which is provided by IBM.
Now I want to include push notification part in this project. So I have added push notificationMFP plugin in same project. Sender id and key in push settings. Added scope push.mobileclient also.
When I tried to call MFPPush.registerDevice javascript method I am getting failed to register device.
Failed to register device:"com.ibm.mobilefirstplatform.clientsdk.android.push.api.MFPPushException: Response: Status=404, Text: Error 404: SRVE0295E: Error reported: 404\n, Error Message: Not Found"
Also when App get initialized I can see in MFP console that particular device in devices list and when I login I can see user ID also get added in device information. So what is problem is something I am missing? Why device is not able to register for push?
The original issue in the question was resolved:
Yes. Now its working Its initialization issue. Just got it. Thnks.
The user then added a new issue via comments:
One more help I need. I am trying to send notification to particular User ID through MFP console. But device can not get any notification. But i cn see User ID against device id. So there is option to send to user id in console. But its not working for me
Unless you got an error in the console, this means that the notification in all likelyhood left the MobileFirst Server. From there there are numerous options why the sending will fail. See the Push Notifications Troubleshooting section.

Gcm with appodeal

I am using gcm with appodeal in my app and when I am sending the push notification the for the first push was successful but phone is not receiving the notification and after that error is there while sending push that device is not register. What to do in this situation please help me.
Is it iOS or Android ? I had the exact same issue just yesterday with iOS and all I had to was to create a development provisioning profile and set it up properly in xCode. I hope that helps you.
I think for you to verify that your app can send and receive messages, client apps must register with GCM.
To register with GCM:
1.The client app obtains a registration token using the Instance ID API. The call to this API must have the authorized entity set to your app server's sender ID, and the scope set to the appropriate value for GCM (depending on your platform). Refer to the API reference for full detail on this API.
2.The client app passes the registration token to the app server.
3. The app server saves the registration token and acknowledges to the client app that the process completed successfully.
This thread may also provide further insight as to why you are receiving the device not registered error.

Should i backup GCM registration ID with google cloud?

Is it advised to backup GCM id using android cloud back up ? i am storing the GCM id in a sharedpreferences so i dont have to keep registering.
if i backup this GCM sharedpref and user changes devices do i need to update it to a new registration id ? Is the registration ID device specific ? What happens when user changes devices and backs up ?
I tried and read this from the docs:
You must exclude any device specific identifiers, either issued by a server or generated on the device. This includes the Google Cloud Messaging (GCM) registration token which, when restored to another device, can render your app on that device unable to receive GCM messages.
From the docs i found my answer that the reason this should not be done is that it can intrefer in the apps intialization of gcm and it will not try to get the GCM id if its already restored from a new device that restored a old registration id.
Handle Google Cloud Messaging
For apps that use Google Cloud Messaging (GCM) for push notifications,
backing up the registration token that Google Cloud Messaging
registration returned can cause unexpected behavior in notifications
for the restored app. This is because when a user installs your app on
a new device, the app must query the GCM API for a new registration
token. If the old registration is present, because the system had
backed it up and restored it, the app doesn't seek the new token. To
prevent this issue from arising, exclude the registration token from
the set of backed-up files.