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)
Wouldn't that show up in their notifications looking pretty ugly?  For instance, I'd want the message to say, 'You just beat player 2!', rather than "{'alert': 'You just beat player 2', 'GameID'...etc.}"
For this you need to change App42GCMService.java file according to your requirements and build new plugin jar and replace the same in Assets folder.
Okay, I'll let you know how it goes.  I've never programmed plugins before.  Thanks.
Hi,

Did you find any solution to this yet ? I need to have the same functionality in my game and want to send some custom data with push notification message. Please share your code of plugin if you were able to achieve that.

Thanks
You can send the message in json format and on App42GCMService.java file parse the same that will contains the message and extradata.So just import the plugin sample in Eclipse and make the programming and replace the same in Sample.Let me know if you face issue in it.
Why shephertz programmers do not change App42GCMService.java and want us to change it? I also need this functionality and I do not know how to change it!!!
Thanks for your feedback. We are taking and it and will plan to change it accordingly.
Thanks for your interest. My game waits this feauture. How long does it take to implement it?
My friend, can you please add this functionality to app42PushServiceV2.jar(do not show push if application is open) as well. Because I am still not sure which jar to use.
I will let you know asap and would provide internal jar file so that you will also gets the extra data as well.
Still no news?
You can send the same data using the API and you will be getting the same in Unity.But you need to parse accordingly and based on your logic.
What u mean exactly by saying "send same data using the API"? Which API u mean?
Hi Vishnu
You said you will provide an internal jar file for custom push notification but then you did not return me. Can you please inform me about process because I am waiting this.
Hi Gokhan, whatever API you are using to send message like json or String format, you will be retrieving the same in the callback we have implemented. In the unity plugin.It may be JSON or Simple String text. There is no need to change the plugin we have share with you.

But if you send message from AppHQ from different section like Advance Tab in that case there is need to change the plugin.
Man, simply I want to send multiplayer match request to a player. Something like "Player 1 wants to play a game with you!". To do this, I should send roomId with notification. So I am asking you how I can do this WITHOUT  displaying something like "{'alert': 'Player 1 wants to play a game with you!', 'RoomId'...etc.}" in push notification text? I just want to show only the text itself. So you say this is not possible with unity? if you say it is possible, can you please guide me because I could not do it!
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
...