发送有效载荷中的字符串列表

时间:2015-02-25 07:22:26

标签: pushsharp

我正在使用Push Sharp向iOS和Android客户端发送推送通知。我需要发送一个字符串列表,但不知道如何实现这一点?我需要发送有效载荷吗?有人可以告诉我代码吗?

对于iOS示例代码:

 var appleCert = File.ReadAllBytes(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, 
                 "../../../Resources/PushSharp.Apns.Sandbox.p12"));

 //Extension method
 push.RegisterAppleService(new ApplePushChannelSettings(appleCert, "radint123?")); 

 push.QueueNotification(new AppleNotification()
     .ForDeviceToken("b06d5462020a01703f6c740f8de77d7450878739ec2954775db5411d0f3f17d7")
     .WithAlert("Hello World!").WithBadge(i)
     .WithSound(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, 
            "../../../Resources/sound.caf")));

1 个答案:

答案 0 :(得分:0)

是的,您必须使用这样的有效负载发送它(VB.Net代码):

Dim appleNotif As New AppleNotification
'Define other properties here

Dim notiPayLoad = New AppleNotificationPayload()
notiPayLoad.AddCustom("key1", "value1")
notiPayLoad.AddCustom("key2", "value2")
appleNotif.Payload = notiPayLoad
push.QueueNotification(appleNotif)