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

Android Client is not registered with Notification hub #5046

Closed
K232 opened this issue Feb 27, 2018 — with docs.microsoft.com · 8 comments
Closed

Android Client is not registered with Notification hub #5046

K232 opened this issue Feb 27, 2018 — with docs.microsoft.com · 8 comments

Comments

Copy link
Contributor

K232 commented Feb 27, 2018

I'm trying to add Push Notifications to my Xamarin Forms app. Azure Notification Hub works fine, I see my server sent several messages. But they do not appear on my Android. I've implemented AzureNotificationHubService https://docs.microsoft.com/en-us/azure/app-service-mobile/app-service-mobile-xamarin-forms-get-started-push#registering-with-the-azure-notification-hub, nor AndroidManifest or FirebaseRegistrationService.
But I wonder because RegisterAsync in AzureNotificationHubService is never called. Is that correct or am I missing something?


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

  • ID: 6f503e37-b16e-c92c-8668-313428451053
  • Version Independent ID: edc66d3e-bf88-3c4d-a148-6288a7022f16
  • Content
  • Content Source
  • Service: app-service-mobile
@K232
Copy link
Contributor Author

K232 commented Feb 27, 2018

Hmm, seems to be a problem of my emulator because on Hardware it works :-)

But nothing is displayed. Application output says:
[FirebaseNotificationService] Notification message body: Notification Hub test notification
[sfx] Unknown style!!! : com.android.internal.util.NotificationColorUtil@b5a3a2e

Downloaded demo app also has warnings on new Notification.Builder because SetSound is deprecated and Resource.Drawable.ic_stat_ic_notification is not found.

Any updates available?

@amanarneja
Copy link
Contributor

Thanx for the feedback!
I have assigned this to the author to take a look if there are any issues with the steps in the document. Stay tuned :)

@conceptdev
Copy link
Contributor

@K232 can you provide the link you used to download the demo app? Thanks!

@K232
Copy link
Contributor Author

K232 commented Feb 28, 2018

@conceptdev
Copy link
Contributor

Thanks @K232, note that your emulator must be configured with Google Play Services (ie "a virtual device that has Google APIs set as the target"). The Play app should be present on the emulator - we'll make this more obvious in the doc.

We've identified this as a common cause of push notifications not working on emulators, since Google Play Services/Google APIs aren't automatically present in every emulator configuration (especially when it works fine on real hardware). You can read more about emulator configuration on the Xamarin site:

https://developer.xamarin.com/guides/android/getting_started/installation/android-emulator/google-emulator-manager/#Installing_System_Images

@davidbritch
Copy link
Contributor

@K232 Before an Android app can receive push notifications, it must register with Firebase Cloud Messaging, which generates a registration token and returns it to the app. This is accomplished by:

  • Declaring a receiver in the Android manifest.
  • Implementing the Firebase Instance ID service (which is what the FirebaseRegistrationService class does).

When the app receives a registration token from Firebase, the FirebaseRegistrationService.OnTokenRefresh method is invoked, which in turn invokes SendRegistrationTokenToAzureNotificationHub, which in turn invokes AzureNotificationHubService.RegisterAsync.

The fact that AzureNotificationHubService.RegisterAsync is never called for you implies that the app isn't getting a token from Firebase, which implies either incorrect Firebase setup or the app not communicating with Firebase.

For more information about how to do this, see Sending Push Notifications from Azure Mobile Apps.

@davidbritch
Copy link
Contributor

@K232 Also, I've fixed the deprecated SetSound API. However, I've no problems with Resource.Drawable.ic_stat_ic_notification. If it wasn't in the project, the app wouldn't build.

Copy link
Contributor

The doc and sample have been updated with the feedback from this conversation #please-close

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

No branches or pull requests

4 participants