5

I'm using this code to send Apple Push Notifications to iPhone:

Public Function SendPush() As String
    Dim rt As String = "Sended!"
    Dim deviceToken As String = "my token"
    Dim message As String = "Parabéns é Campeão!"
    Try

        Dim payLoad As New NotificationPayload(deviceToken, message, 1, "default")
        payLoad.AddCustom("RegionID", "IDQ10150")
        ' 51 is the badge no
        Dim notificationList = New List(Of NotificationPayload)() From { _
         payload _
        }

        Dim push = New PushNotification(True, "apn_developer_identity.p12", "password")
        Dim result = push.SendToApple(notificationList)
    Catch ex As Exception
        rt = "Error!"
    End Try

    Return rt

End Function

But in my iPhone don't receive accents. I received this: Parab?ns ? Campe?o!

someone ideas about what happens?

regards

Solved it!

I have change into library Moon-APNS in class PushNotification.cs:

// String length
byte[] apnMessageLength = BitConverter.GetBytes((Int16)Encoding.UTF8.GetBytes(apnMessage).Length);

// Write the message
memoryStream.Write(Encoding.UTF8.GetBytes(apnMessage), 0, Encoding.UTF8.GetBytes(apnMessage).Length);

recompile and use into your project. Now accepts latin characters.

Kara
  • 5,650
  • 15
  • 48
  • 55

1 Answers1

1

You should encode your payload to UTF-8.

Eran
  • 359,724
  • 45
  • 626
  • 694
  • How? I make a download of moon-apns and use in my application server! I not see where make this! – monteiro_luiz Mar 11 '13 at 18:37
  • I'm not familiar with moon-apns. I wrote my server side APNS code in Java and encoded the payload to UTF-8. Do you pass the payload as Strings to moon-apns library? – Eran Mar 11 '13 at 18:51
  • Yes, pass to payload as string. I think into moon-apns library its resolve, but not. In your server java accept latin characters? – monteiro_luiz Mar 11 '13 at 19:01
  • I encode the string into bytes using UTF-8 encoding, which can encode characters of any language. – Eran Mar 11 '13 at 19:28