How to handle payload formats for both iOS and Android through the Azure Notification Hub

0 votes

I wish to support both iOS and Android platforms through the Azure Notification Hub.

The iOS platform expects the payload in the following form:

{"aps":{"alert":"Notification Hub test notification"}}

The Android platform expects the payload in this form:

{"data":{"message":"Notification Hub test notification"}}

I am aware that the payload can be modified to include more information but the example is sufficient for the question.

I send a notification to a destination based on a Tag and I do not keep a record of the platform, each push notification registration uses is the only alternative to send the notification twice - once for Apple native and the second for GCM native.

hubClient.SendAppleNativeNotificationAsync(payload, tag); 

hubClient.SendGcmNativeNotificationAsync(payload, tag);

Is there a way to send a notification to Azure Notification Hub with multiple payloads and then the notification hub will use the payload appropriate for the destination device?

Jul 9, 2019 in Azure by sabby
• 4,390 points
1,771 views

1 answer to this question.

0 votes

I think your solution is feasible and the way to go. But if you really want to avoid the extra call, you can register a "type" tag when you register the device and query the notification hub for the "type" tag and the other tag you want to send to

for (Registration reg in hubClient.getRegistrationsByTag(iosTag)) { hubClient.SendAppleNativeNotificationAsync(payload, tag); }

for (Registration reg in hubClient.getRegistrationsByTag(androidTag)) { hubClient.SendGcmNativeNotificationAsync(payload, tag); }


Hope it Helps!

To know more, join our Azure Training in Samarinda today.

answered Jul 9, 2019 by Perry
• 17,100 points

edited Oct 6, 2021 by Sarfaraz

Related Questions In Azure

0 votes
2 answers

How can I download a .vhd image to my local machine from azure and upload the same to a different azure account?

From the Windows Azure Portal you can ...READ MORE

answered Aug 20, 2018 in Azure by Priyaj
• 58,100 points
13,929 views
0 votes
2 answers
0 votes
1 answer
0 votes
1 answer

How to export the template used for a deployment in Azure?

Hi@akhtar, You can export the deployment available in ...READ MORE

answered Nov 16, 2020 in Azure by MD
• 95,460 points
699 views
0 votes
1 answer
0 votes
1 answer

Error with Azure AD Authentication in Unity for Android

Depending on the version, Unity uses UnityPlayerActivity ...READ MORE

answered Mar 24, 2022 in Azure by Edureka
• 13,620 points
871 views
0 votes
1 answer

Tableau dashboard for mobile/tablets

To make a dashboard mobile with Tableau, ...READ MORE

answered Apr 5, 2022 in Tableau by Neha
• 9,060 points
794 views
0 votes
1 answer

How to register new users for MVC4 website on Azure AD?

The application holds the permissions to read/write ...READ MORE

answered Jul 3, 2019 in Azure by Perry
• 17,100 points
2,055 views
0 votes
1 answer

How do I upload a picture to Windows Azure Website?

Check out this example: @model List<string> ...READ MORE

answered Jun 28, 2019 in Azure by Perry
• 17,100 points
1,611 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP