Search code examples
xamarin.androidfirebase-cloud-messagingazure-notificationhub

Xamarin/Azure Notification Hubs GCM registration removed after sending


I have a Xamarin Android app setup using the GCMClient library as recommended in the Azure tutorials. When sending a notification from code or a test notification through the Azure portal (or the Azure VS plugin) the device registration is removed and the following response is received from Azure Notification Hubs:

The Push Notification System handle for the registration is no longer valid

I have commented out all code in the app that unsubscribes the registration, tried running on an emulator with the Google API's & a physical Nexus device in both debug & release mode but still the registration is removed whenever a notification is sent.

I have also configured an existing web app to use the same Azure Notification Hub; the web app uses Chrome's web push notifications with a service worker and it works perfectly, the registration is never removed from Notification Hubs and the test messages come through every time.

I have verified the usual's; Sender ID & Azure NH connection string are both correct...


Solution

  • A couple of things to check:

    1. Can you check if the credentials you have set for GCM are correct. Use this link: https://learn.microsoft.com/en-us/azure/notification-hubs/xamarin-notification- hubs-push-notifications-android-gcm

    2. Make sure you register with the latest device token whenever the App opens up to make sure the registrations are up to date.

    I am assuming the registrations exists before you send the notification. But just to make sure, please check your registration Id using Visual studio server explorer See link Verify Registrations