Push Notification Service sending message non-ASCII characters in JavaScript SDK

0 votes
1. It is possible to send push message with non-ASCII characters (e.g. Chinese characters "你好") in JavaScript SDK?

I tried to do so with:

 

pushNotificationService.sendPushMessageToAll("你好", ...) but the iOS client received "??" instead of "你好"。

 

2. Is is possible to add application key in JavaScript SDK? e.g:

 

var m = { "alert" : "New version is available", "downloadUrl" : "http://some.url.to.open" }

pushNotificationService.sendPushMessageToAll(m, ...)

 

So in the iOS client I can get the downloadUrl and open it for user.
asked May 4, 2015 in App42 Cloud API-BaaS by Cheng Zhong (10 points)

1 Answer

0 votes

Hello,

 

Yes you can send it easily by setting dataEncoding true in meta headers. Please find the below code snippet and let me know if it helps:

 

var userName = "Nick",

message  = "Message which you have to send",

result ;  

App42.initialize("API_KEY","SECRET_KEY");

var pushNotificationService  = new App42Push();

var otherMetaHeaders={dataEncoding:true}; // For Non-English Character

pushNotificationService.setOtherMetaHeaders(otherMetaHeaders);

pushNotificationService.sendPushMessageToUser( userName,message, {  

            success: function(object) 

            {  

                        var pushNotification = JSON.parse(object);  

                        result = pushNotification.app42.response.push;

                        console.log("UserName is : " + result.getUserName());

                        console.log("Message is : " + result.message)

                        console.log("Expiry is : " + result.expiry)      

            },  

            error: function(error) {  

            }  

     }); 

Thanks,

Himanshu Sharma

 

answered May 5, 2015 by hs00105 (2,005 points)
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...