Unity Doesn't Allow For Custom Push Notifications Including Data

0 votes

On this page it says that "Send Custom Push Message To User In Key Value Or JSON Format" is "Not Available".

Is there an alternative way to send data through a push notification to Unity on Android?

asked Mar 18, 2016 in Android by null (23 points)

1 Answer

+1 vote

Hi,

You can convert your JSON message in String format  and then can send message to user using following method.

sendPushMessageToUser(userName, message, callBack);

Let me know if more queries are concern.

Thanks

Vishnu Garg

answered Mar 18, 2016 by Vishnu Garg (674 points)
I will provide the same library by end of tomorrow, if you can share the exact json and which key text you want to display in it like alert or something.
"alert" key can be displayed in push notification text. In addition to "alert" key some extra data I want to put. In our case "roomId" for now. But It can be changed.
Hi Gokan, Let me know which collection you are using to sending message its HashMap or JSON.
If you use JSON and key name as message you want to display in the Notification every thing works with the plugin we have shared with you.

I suggest you to use Json format for that like

            JSONObject message = new JSONObject();  
        message.put("message", "Hello! This is my first notification.");  
        message.put("badge", "1"); //Applicable for iOS only  
        message.put("sound", "default"); //Applicable for iOS only  
        message.put("sendingFrom", "Android");

Let me know if you want to use alert key then I can share the new build.
Hi All
I have tested above issues discussed. And Existing version of push notification already does what we want.
JSONClass json=new JSONClass();
json.Add("message", "Hello!");
json.Add("extra", "extra data");
App42PushManager.Instance.SendPushToUser(buddyName,json.ToString());

Vishnu, thanks my friend for your help. But I guess you should try to be more clear. This thread could be closed much before if we would understand you correctly. Null asks above "  For instance, I'd want the message to say, 'You just beat player 2!', rather than "{'alert': 'You just beat player 2', 'GameID'...etc.}"". You could simply say "This functionality already exist. Try to use json format and put "message" key." But what you say is change jar file!!!. Anyway, problem solved:)
You need to change code of plugin if you want to use HashMap in case of JSON or want to use some other collection.

Let me know if more queries are there.
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
...