1

Apple Notification Class does not appear to have properties for badge and sound :

https://msdn.microsoft.com/en-us/library/azure/microsoft.azure.notificationhubs.applenotification.aspx

Is there some other class that could generate an iOS payload with sound and badge. I know I can do it manually by making strings, but would prefer to use a created class..

For example , this is undesired:

var alert = "{\"aps\":{\"alert\":\"" + pushNotificationMessage + "\",\"badge\":<input1>,\"sound\": <input2>"}}";

This would be better :

microsoftDefinedMethod( message = null, badge = false, sound = false);
js_55
  • 177
  • 1
  • 1
  • 9

1 Answers1

1

You can use SendAppleNativeNotificationAsync method (or one of its overloads):

public Task<NotificationOutcome> SendAppleNativeNotificationAsync(string jsonPayload)

The jsonPayload parameter is the native iOS payload. Here's an example from the official documentation that looks like something you want to achieve:

{
    "aps" : {
        "alert" : "You got your emails.",
        "badge" : 9,
        "sound" : "bingbong.aiff"
    },
    "acme1" : "bar",
    "acme2" : 42
}

Also, there's an slightly different question on SO with an answer that has a code snippet potentially similar to what you'd write in your case.

Community
  • 1
  • 1
Nikita R.
  • 7,245
  • 3
  • 51
  • 62
  • However, there is no method to generate JsonPayloads strings , correct ? I would have to create a method myself to organize the alert, badge, sound, and anything else I would want ? – js_55 Aug 29 '16 at 17:16
  • No, there's no built-in method to generate the payload. But it's just a string. You can use a `string.Format(...)` template to generate those. Or do it [the way they did it in the answer](http://stackoverflow.com/a/26492433/182371) I linked to. – Nikita R. Aug 29 '16 at 17:18