我想生成带有徽章和声音功能的 iOS 推送通知负载,我可以使用哪些 类 和库? [C#]
I want to generate iOS push notification payload with badge and sound features, what classes and libraries can I use? [c#]
Apple Notification Class 似乎没有徽章和声音的属性:
是否有其他 class 可以生成带有声音和徽章的 iOS 负载。我知道我可以通过制作字符串手动完成,但更愿意使用创建的 class..
例如,这是不希望的:
var alert = "{\"aps\":{\"alert\":\"" + pushNotificationMessage + "\",\"badge\":<input1>,\"sound\": <input2>"}}";
这样会更好:
microsoftDefinedMethod( message = null, badge = false, sound = false);
您可以使用 SendAppleNativeNotificationAsync 方法(或其重载之一):
public Task<NotificationOutcome> SendAppleNativeNotificationAsync(string jsonPayload)
jsonPayload
参数是native iOS payload。这是官方文档中的一个示例,看起来像您想要实现的目标:
{
"aps" : {
"alert" : "You got your emails.",
"badge" : 9,
"sound" : "bingbong.aiff"
},
"acme1" : "bar",
"acme2" : 42
}
此外,关于 SO 的问题略有不同 an answer that has a code snippet 可能与您在案例中所写的相似。
Apple Notification Class 似乎没有徽章和声音的属性:
是否有其他 class 可以生成带有声音和徽章的 iOS 负载。我知道我可以通过制作字符串手动完成,但更愿意使用创建的 class..
例如,这是不希望的:
var alert = "{\"aps\":{\"alert\":\"" + pushNotificationMessage + "\",\"badge\":<input1>,\"sound\": <input2>"}}";
这样会更好:
microsoftDefinedMethod( message = null, badge = false, sound = false);
您可以使用 SendAppleNativeNotificationAsync 方法(或其重载之一):
public Task<NotificationOutcome> SendAppleNativeNotificationAsync(string jsonPayload)
jsonPayload
参数是native iOS payload。这是官方文档中的一个示例,看起来像您想要实现的目标:
{
"aps" : {
"alert" : "You got your emails.",
"badge" : 9,
"sound" : "bingbong.aiff"
},
"acme1" : "bar",
"acme2" : 42
}
此外,关于 SO 的问题略有不同 an answer that has a code snippet 可能与您在案例中所写的相似。