Problem with Push notifications

61 views
Skip to first unread message

Mario Barón

unread,
Mar 21, 2014, 12:49:53 PM3/21/14
to codenameone...@googlegroups.com
Hey guys,

I'm having problems with push notifications. When I send type 3 notifications, the data arrives correctly but the notification itself appears on the notification bar with the full message and parameters how can this be fixed? 

I see someone else posted about this on this entry but no real answer was given. Please help me with this. 

PS: I've so far tried it on Android and no other platform


Thanks

Shai Almog

unread,
Mar 21, 2014, 1:21:18 PM3/21/14
to codenameone...@googlegroups.com
Hi,
You should use type 2 not type 3. Type 3 is something else.

Mario Barón

unread,
Mar 21, 2014, 3:16:59 PM3/21/14
to codenameone...@googlegroups.com
Hey Shai,

thanks for your response. What I need to do is show a message to the user but also send some data to the app so it can react in a different way depending on the data sent. With type 2 I could only send the dat but without notifyng the user, am I right? What would be the use case for Type 3 Push notifications?


Thanks. 

Shai Almog

unread,
Mar 22, 2014, 4:03:20 AM3/22/14
to codenameone...@googlegroups.com
Hi,
do you separate the two values with a ; character? One will always appear and the other should never appear. This is the equivalent of sending a type 0 message and a type 2 message.

Mario Barón

unread,
Mar 22, 2014, 9:47:41 AM3/22/14
to codenameone...@googlegroups.com
Hey Shai,

yes. I'm sending a Type 3 Push notification with a message in this format: "Message;Parameter" as the "body" value but both of these values appear on the notification bar.



On Friday, March 21, 2014 11:49:53 AM UTC-5, Mario Barón wrote:

Mario Barón

unread,
Mar 22, 2014, 10:01:14 AM3/22/14
to codenameone...@googlegroups.com
I attach these 2 screenshots taken from the push notification on my device and DDMS 




On Friday, March 21, 2014 11:49:53 AM UTC-5, Mario Barón wrote:

Shai Almog

unread,
Mar 22, 2014, 12:41:15 PM3/22/14
to codenameone...@googlegroups.com
Thanks, I see the problem. Its a regression in the current Android build, this should work as described and should work properly in iOS.

Mario Barón

unread,
Mar 25, 2014, 11:26:00 AM3/25/14
to codenameone...@googlegroups.com

Hey Shai, 

thanks for your response. I'm just getting to check this out again. Turns out that it looks like it's working fine now (on Android at least which is the main platform I'm working on). But I still need some help with something. I need to manage the push notification, on cases when the app is running and when it's not and I have written some code to handle this, but I'm not exactly sure if this is correct or not. I attach my main class' code to this post so you can please check it out, 

I'm specifically interested in the part of obtaining the currently running statemachine so I can make calls to its methods for the push callback and also a little bit confused with how I'm supposed to manage the type 3 Push notifications, since it seems as if this push type would go twice through the public void push(String value) method of the callback. At least that's what I think by observing some console output from the device when sending this, I attach a screenshot of this also, maybe it would help illustrating what I'm saying. 




Thanks for your help.    

On Friday, March 21, 2014 11:49:53 AM UTC-5, Mario Barón wrote:
AppTaxi.java

Shai Almog

unread,
Mar 25, 2014, 3:12:43 PM3/25/14
to codenameone...@googlegroups.com
Hi,
to see if the app is running or not just use Display.isInitialized().

All push notifications arrive to the push method. Type 3 allows you to bundle both a message and metadata together. You need to be able to distinguish the two from one another e.g. place a # sign before meta data.

To get the current state machine you can just keep a pointer to it in your main class.
Reply all
Reply to author
Forward
0 new messages