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 8 in Azure by sabby
• 4,350 points
21 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); }
answered Jul 8 by Perry
• 17,010 points

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
• 56,160 points
1,113 views
0 votes
2 answers
+1 vote
2 answers

How do I establish an connection to Azure IoT Hub? Say a connection like MQTT/AMQP using Python.

Azure IoT Hub comes with 3 SDK's: Service SDK Device ...READ MORE

answered Apr 13, 2018 in Azure by null_void
• 3,220 points
490 views
0 votes
1 answer

Are Docker and Azure Service Fabric both the same?

It's confusing since Docker (the company) is ...READ MORE

answered Jun 1, 2018 in Azure by null_void
• 3,220 points
522 views
0 votes
1 answer
+1 vote
2 answers
0 votes
1 answer

What OS is Jenkins installed on Azure Virtual Machine?

Under Managed Jenkins there's a section called ...READ MORE

answered Apr 4, 2018 in DevOps & Agile by DareDev
• 6,810 points
29 views
+1 vote
4 answers

Where to find the Microsoft.IdentityModel dll?

I finally found this Nuget package: https://www.nuget.org/packages/Microsoft.SharePointOnline.CSOM, which ...READ MORE

answered Oct 23, 2018 in Azure by Trisha
343 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 in Azure by Perry
• 17,010 points
728 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 27 in Azure by Perry
• 17,010 points
32 views