Forum Xamarin Cross Platform with Xamarin

Firebase Test msgs working, but not Azure hubs

AlanStrattonAlanStratton USMember ✭✭
edited February 2018 in Cross Platform with Xamarin

Using Xamarin.Forms 2.5, Xamarin.Firebase.Messaging & Xamarin.GooglePlayServices.Base v60.1142.0.
I am using my own custom backend to register with Azure. The backend is a WebAPI that uses Microsoft.Azure.Notifications 1.0.9

My Xamarin.Android phone client successfully registers with Firebase and gets a token. It then calls my backend to register and the register is succesfull.

The backend code is something like this.

registration = new GcmRegistrationDescription(deviceUpdate.Handle);
template = "{ \"data\" : {\"message\":\"" + "$(message)\"}}";
registration.Tags = new HashSet(deviceUpdate.Tags);
registration.Tags.Add("username:" + USERNAME);
hub.CreateGcmTemplateRegistrationAsync(Id, template, registration.Tags);

This is successful.
Then I go to the Visual Studio 2017/ServerExplorer/NotificationHubs/ and double click it.
There is a registration that is listed that has the tags I added.
When I go to Test Send, regardless of my tag, broadcast, and message, there is never any "Message Result" displayed towards the bottom and I never get a notification on the Android Xamarin client.
When I go to Test Send in the Azure Portal, and attempt either broadcast or to my "username:myusername" tag, it always says "No matching targets".

However, If I go to the firebase console and send a message to my Token, my Android Emulator successfully gets the notification.
So I am really at a loss as how to proceed. I googled around but it appears nobody has the same problem I am describing.

Is there any real good reasons to use Azure Notification hubs? Perhaps I should just take that component out and have my backend communicate directly with Firebase and APNS?

Thanks for any suggestions.

Best Answer

  • AlanStrattonAlanStratton USMember ✭✭
    Accepted Answer

    There are two models for integrating with AzureNotificationHubs. The first way, registrations, is what I was attempting above. I decided to attempt the 2nd way, Installations instead and found success.

Answers

  • HasanSyedHasanSyed USMember

    We are experiencing exactly the same. We have also tried the hub in another Azure subscription but didn't work.

  • AlanStrattonAlanStratton USMember ✭✭
    Accepted Answer

    There are two models for integrating with AzureNotificationHubs. The first way, registrations, is what I was attempting above. I decided to attempt the 2nd way, Installations instead and found success.

Sign In or Register to comment.