Bug 40659 - Azure Messaging Component doesn't receive messages on Android (Using the Sample App Code)
Summary: Azure Messaging Component doesn't receive messages on Android (Using the Samp...
Status: RESOLVED ANSWERED
Alias: None
Product: Components
Classification: Xamarin
Component: Xamarin Components ()
Version: Production (addons.xamarin.com)
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jon Dick
URL:
Depends on:
Blocks:
 
Reported: 2016-04-24 16:40 UTC by Mike Rowley
Modified: 2016-05-11 00:47 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description Mike Rowley 2016-04-24 16:40:14 UTC
I am using the Azure Messaging Component from the Component store, I implemented the code as per the https://components.xamarin.com/gettingstarted/azure-messaging on both iOS and Android, iOS works perfectly however Android does not.  The code properly registers the device (I can see that in the Server Explorer – Notification Hub Diagnose window) and receives a registration ID.  I then send a test message from the Notification Hub Diagnose window and see the matching registration ID in the Results pane, however the OnMessage override never fires.  I have triple checked the connection string elements (which would cause the registration to fail if there were incorrect), I have tried multiple Tags including no tag and the corresponding Broadcast option in the Notification Hub Diagnose Test Send window.  

I then happened across the “Sample” attached to the Component, I changed the configuration constants, SenderID, HubName, APIKey and blanked the Tags.  (I had to alter the connection string creation as -ns is no longer prefixed) and ran the sample.  I received the registration ID as expected and could see it in the Notification Hub, I then sent a test broadcast message (with no tag) and OnMessage never fired.

Just to ensure it wasn’t a configuration issue between the Azure Notification Hub and the GCM, I created a XamAndTest Notification Hub in Azure and a XamAndTest Project in the Google Developer Console.  I created an API Key in GCM and enabled the service, I then updated that API Key in the GCM setting on Azure and reran the Xamarin Sample app with these settings and received a registration ID an never got the test message I sent but can see the matching registration ID in the results of the Azure Test Send window.  Just for good measure I repeated the same test on the same code and configuration with a Tag and still never received the test message on my device.

I am testing on a Galaxy S5 running Android 5.1, I also tested this on a Samsung Galaxy Tab 8 with Android 5.0 and a Google Nexus 6p running Android 6.0, I observed the exact same behavior on all 3 devices. 
I am currently using 
Xamarin   4.0.3.214 (0dd817c)
Xamarin.Android   6.0.3.5 (a94a03b)
Xamarin.iOS   9.6.1.8 (3a25bf1)
Azure Messaging Andriod 1.1.5.6 

After this exhaustive process, I can only assume this is a bug within the Microsoft.WindowsAzure.Messaging.Android.dll or a problem with the sample code implementation that I cannot identify and resolve to make the Messaging work.
Comment 1 Sturla Thorvaldsson 2016-05-02 09:53:16 UTC
I have the same problem with the basic/vanilla Notification demo program from Xamarin https://developer.xamarin.com/samples/monodroid/RemoteNotifications/

It sends notification successfully (or so it seems) but doesn´t receive the notification back to the device. 

Please give us some feedback for this.
Comment 2 Jon Dick 2016-05-11 00:47:08 UTC
Google now recommends using Google Play Services to handle GCM registration.  You can see a sample of this here: https://github.com/redth/pushsharp.clientsamples

To register the device's registration id with azure, you should use the Azure Mobile Client SDK which contains a managed implementation for registering devices with notification hubs: https://components.xamarin.com/view/azure-mobile-client

The Azure Messaging component has been delisted and deprecated in favour of the new libraries.