我在我的.asmx服务端使用下面的vb.net代码在Apple设备上发送通知并发送我正在使用JdSoft.Apns.Notifications.dll和Newtonsoft.Json.dll dll,我为此创建了证书如此多的时间和正确创建的设备令牌,但我仍然无法在苹果设备上发送通知。
请下面的任何一个检查代码,并建议我在哪里做错了,并给我发送示例代码更好,因为使用vb.net后端这是我在Apple设备上发送通知的第一个代码。
Imports JdSoft.Apple.Apns.Notifications
Imports Newtonsoft.Json
Dim sandbox As Boolean = True
Dim p12File As String = "Certificate/Certificates.p12" '' certificate path
Dim p12FilePassword As String = ""
Dim p12Filename As String = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, p12File)
Dim service As New NotificationService(sandbox, p12Filename, p12FilePassword, 1)
service.SendRetries = 5
service.ReconnectDelay = 1000
Dim alertNotification As New Notification(deviceToken)
alertNotification.Payload.Alert.Body = String.Format("New message again. !!!.")
alertNotification.Payload.Sound = "default"
alertNotification.Payload.Badge = 1
alertNotification.Payload.CustomItems.Add("MSGID", New Object() {MessageID})
alertNotification.Payload.CustomItems.Add("MID", New Object() {MID})
alertNotification.Payload.CustomItems.Add("MSGTYPE", New Object() {MSGTYPE})
alertNotification.Payload.CustomItems.Add("RID", New Object() {RID})
alertNotification.Payload.CustomItems.Add("RNAME", New Object() {RNAME})
alertNotification.Payload.CustomItems.Add("MNAME", New Object() {MNAME})
alertNotification.Payload.CustomItems.Add("MSG", New Object() {MSG})
alertNotification.Payload.CustomItems.Add("MSGCONTENT", New Object() {MSGCONTENT})
alertNotification.Payload.CustomItems.Add("BOOL", New Object() {BOOL})
If service.QueueNotification(alertNotification) Then
Console.WriteLine("Notification Queued!")
Else
Console.WriteLine("Notification Failed to be Queued!")
End If