Iphone 未收到印地语推送通知

Iphone Push notification in hindi is not received

我正在从 asp.net 应用程序发送 Iphone 的推送通知,就像这样-

String msg5 = "{\"aps\":{\"NewsId\":3156,\"NewCat\":\"Agra\",\"Date1\":\"11Apr2015\",\"content-available\":1,\"alert\":\"HelloWorld\",\"sound\":\"default\",\"badge\":2}}";

客户端完美接收。但是当我在警报键上放置一些印地语数据代替 "HelloWorld" 时,客户端未收到通知。请解释一下是什么问题。我发送通知的代码是 -

 public static void pushMessage(string deviceID)
    {
        int port = 2195;
        String hostname = "gateway.sandbox.push.apple.com";
        String certificatePath = System.Web.Hosting.HostingEnvironment.MapPath("~/Certificates.p12");
        //X509Certificate2 clientCertificate = new X509Certificate2(System.IO.File.ReadAllBytes(certificatePath), "");//password

        X509Certificate2 clientCertificate = new X509Certificate2(System.IO.File.ReadAllBytes(certificatePath), "", X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable);
        X509Certificate2Collection certificatesCollection = new X509Certificate2Collection(clientCertificate);

        TcpClient client = new TcpClient(hostname, port);
        SslStream sslStream = new SslStream(client.GetStream(), false, new RemoteCertificateValidationCallback(ValidateServerCertificate), null);

        try
        {
            sslStream.AuthenticateAsClient(hostname, certificatesCollection, SslProtocols.Tls, false);
            MemoryStream memoryStream = new MemoryStream();
            BinaryWriter writer = new BinaryWriter(memoryStream);
            writer.Write((byte)0);
            writer.Write((byte)0);
            writer.Write((byte)32);

            writer.Write(HexStringToByteArray(deviceID.ToUpper()));
            String msg4 = "{\"aps\":{\"NewsId\":3156,\"NewCat\":\"Agra\",\"Date1\":\"11Apr2015\",\"content-available\":1,\"alert\":\"मुख्यमंत्री ने जर्मनी के उद्यमियों को राज्य में निवेश के लिए आमंत्रित किया\",\"sound\":\"default\",\"badge\":2}}";
            String msg5 = "{\"aps\":{\"NewsId\":3156,\"NewCat\":\"Agra\",\"Date1\":\"11Apr2015\",\"content-available\":1,\"alert\":\"HelloWorld\",\"sound\":\"default\",\"badge\":2}}";
            writer.Write((byte)0);
            writer.Write((byte)msg5.Length);
            byte[] b1 = System.Text.Encoding.UTF8.GetBytes(msg5);
            writer.Write(b1);
            writer.Flush();
            byte[] array = memoryStream.ToArray();
            sslStream.Write(array);
            sslStream.Flush();
            client.Close();
        }
        catch (System.Security.Authentication.AuthenticationException ex)
        {
            client.Close();
        }
        catch (Exception e)
        {
            client.Close();
        }

但是我使用像这样的默认编码代替 UTF8

byte[] b1 = Encoding.UTF8.GetBytes(msg5)

收到的印地语文本为 ??????

试试这个代码,对我来说工作正常.. 已完成更改

写b1.length而不是msg5.length(因为印地语长度与原文不同)。

public static void pushMessage(string deviceID, string text)
    {
        int port = 2195;
        String hostname = "gateway.sandbox.push.apple.com";
        String certificatePath = System.Web.Hosting.HostingEnvironment.MapPath("~/cert.p12");

        X509Certificate2 clientCertificate = new X509Certificate2(System.IO.File.ReadAllBytes(certificatePath), "", X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable);
        X509Certificate2Collection certificatesCollection = new X509Certificate2Collection(clientCertificate);

        TcpClient client = new TcpClient(hostname, port);
        SslStream sslStream = new SslStream(client.GetStream(), false, new RemoteCertificateValidationCallback(ValidateServerCertificate), null);

        try
        {
            sslStream.AuthenticateAsClient(hostname, certificatesCollection, SslProtocols.Tls, false);
            MemoryStream memoryStream = new MemoryStream();
            BinaryWriter writer = new BinaryWriter(memoryStream);
            writer.Write((byte)0);
            writer.Write((byte)0);
            writer.Write((byte)32);

            writer.Write(HexStringToByteArray(deviceID.ToUpper()));
            String msg5 = "{\"aps\":{\"NewsId\":3156, \"alert\":\"" + text + "\",\"content-available\":\"1\"}}";
            writer.Write((byte)0);

            byte[] b1 = Encoding.UTF8.GetBytes(msg5);
            writer.Write((byte)b1.Length);
            writer.Write(b1);
            writer.Flush();
            byte[] array = memoryStream.ToArray();
            sslStream.Write(array);
            sslStream.Flush();
            client.Close();
        }
        catch (System.Security.Authentication.AuthenticationException ex)
        {
            client.Close();
        }
        catch (Exception e)
        {
            client.Close();
        }


    }