How can Send Notification to IOS in Tamil Language Using C# -
i'm developing application using c# have send notification both ios , android.in android notification send in tamil. send notification ios in english working good. but, how can send other languages hindi, french, german , on.
below code used:
string devicetocken = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";// iphone device token int port = 2195; string hostname = "gateway.sandbox.push.apple.com"; string certificatepath = @"certificates.pfx"; string certificatepassword = ""; x509certificate2 clientcertificate = new x509certificate2(certificatepath, certificatepassword, x509keystorageflags.machinekeyset); 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.default, false); } catch (authenticationexception ex) { console.writeline("authentication failed"); client.close(); return; } memorystream memorystream = new memorystream(); binarywriter writer = new binarywriter(memorystream); writer.write((byte)0); //the command writer.write((byte)0); //the first byte of deviceid length (big-endian first byte) writer.write((byte)32); //the deviceid length (big-endian second byte) int len = devicetocken.length; int len_half = len / 2; byte[] bs = new byte[len_half]; (int = 0; != len_half; i++) { bs[i] = (byte)int32.parse(devicetocken.substring(i * 2, 2), system.globalization.numberstyles.hexnumber); } byte[] b0 = bs; writer.write(b0); string payload; string strmsgbody = ""; strmsgbody = "சென்னை"; //strmsgbody = "chennai"; debug.writeline("during testing via device!"); payload = "{\"aps\":{\"alert\":\"" + strmsgbody + "\",\"sound\":\"mailsent.wav\"},\"acme1\":\"bar\",\"acme2\":42}"; writer.write((byte)0); //first byte of payload length; (big-endian first byte) writer.write((byte)payload.length); //payload length (big-endian second byte) byte[] b1 = system.text.encoding.utf8.getbytes(payload); writer.write(b1); writer.flush(); byte[] array = memorystream.toarray(); debug.writeline("this being sent...\n\n"); debug.writeline(array); try { sslstream.write(array); sslstream.flush(); } catch { debug.writeline("write failed buddy!!"); } client.close(); debug.writeline("client closed.");
you not problem - not happens when send message. since have not asked question, nobody able you.
however, quick glance @ code shows:
- you assuming payload never more 255 characters long (you setting high byte of length 0).
- you making payload length number of unicode characters, not number of characters in utf-8 representation of payload. correct? sounds unlikely. don't know answer, should.
Comments
Post a Comment