Hi Grace,
Thank you for your reply, I can confirm that this workaround does work.
- Is this workaround something we can rely on long term or is it possible it will get removed?
- Are there any plans to add native Apple MDM push support to the Azure Notifications Hub service?
Thanks
For anyone else following, here is some sample code to send an MDM push notification via Azure Notification Hubs to a device you already have a push token and push magic string for and where you have already uploaded the MDM push certificate to ANH portal
public async Task SendMdmNotification()
{
var azureNotificationsConnectionString = "[YOUR-SHARED-ACCESS-KEY]";
var azureHubName = "[YOUR-HUB-NAME]";
var notificationHubClient = NotificationHubClient.CreateClientFromConnectionString(azureNotificationsConnectionString, azureHubName);
var registration = await notificationHubClient.CreateAppleNativeRegistrationAsync("[DEVICE-PUSH-TOKEN]", new[] { "test-device" });
var headers = new Dictionary<string, string>
{
{ "apns-push-type", "mdm"},
{ "apns-topic", "com.apple.mgmt.External.[YOUR-PUSH-CERTIFICATE-TOPIC]"},
{ "apns-id", Guid.NewGuid().ToString()},
{ "apns-expiration", "0"},
{ "apns-priority", "10"}
};
var message = $@"{{ ""aps"": {{}}, ""mdm"": ""[YOUR-DEVICE-PUSH-MAGIC-STRING]""}}";
var notification = new AppleNotification(message, headers);
var result = await notificationHubClient.SendNotificationAsync(notification, "test-device", CancellationToken.None);
}