Push notification text in the status bar

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
giovanni_c
Posts: 52
Joined: Sat Sep 08, 2012 10:50 am

Push notification text in the status bar

Post by giovanni_c » Sun Sep 09, 2012 8:32 am

Hi all.
As in subject: there's a way to customize / change the notification text in the Android status bar?
I've tried to change the data array send but in the status bar I always see "Notification received"
(in english... and my device is in another language!)

I think push notification is a great tool to communicate with your app but right now I can't find
documentation to work with them.
Thank you to everyone can / want help me!

Bernard
Posts: 351
Joined: Sat Apr 08, 2006 10:14 pm
Location: London, England

Re: Push notification text in the status bar

Post by Bernard » Tue Oct 02, 2012 11:25 am

Hi Giovanni,

I've just started to look at Android development & notifications.

I found that the following data items (sent to the GCM api service) affect what is displayed in the status bar when a notification is received.

data.title is displayed to the right of the icon of the status bar
data.body is displayed beneath the icon+text of the status bar

I'm giving you the parameters as "data.xxxx" because I'm using plain-text (not JSON) to send the notification to the GCM api service. Maybe I will get round to using JSON soon. However, I'm sure your JSON array already contains a "data" key, so it is just a question of adding new elements named "title" & "body" in your own language, and that should work.

I've requested that Runrev update the Lesson for Push Notification, as a) the Android way is soooo much simpler than the iOS way, and b) that Lesson (for all its simplicity) is woefully out of date).

Bernard

Bernard
Posts: 351
Joined: Sat Apr 08, 2006 10:14 pm
Location: London, England

Re: Push notification text in the status bar

Post by Bernard » Wed Oct 03, 2012 9:43 am

Giovanni, I'm wondering if there is a bug with the status bar/notifications and Livecode.

When a Notification turns up in the status bar (either Push or Local) I get no warning sound/no vibration. That's bad. But also, when I then go to my app (either by selecting the Notification, or by just going to the app), none of the message handlers are triggered (e.g. pushNotificationReceived) with the payload details that accompany the Notification.

Is this your experience too? I tried this with Push and Local Notifications, and tried it with two different (Android 2.2) devices. Nothing seems to make any difference.

I can't see that Notifications are really that useful if they cannot alert a user when the display of the device is asleep. And surely there must be something wrong if they payload is lost between the Status Bar and the App.

Bernard

giovanni_c
Posts: 52
Joined: Sat Sep 08, 2012 10:50 am

Re: Push notification text in the status bar

Post by giovanni_c » Tue Jan 01, 2013 9:03 pm

Hi all.
First of all I want to thank you for your replies and excuse me for the delay in my answer... I'm really sorry.
Bernard wrote: data.title is displayed to the right of the icon of the status bar
data.body is displayed beneath the icon+text of the status bar
Thank you Bernard! Your answer did the trick for me!!!
Using the "title" and "body" keys for the data array permit me to customize the notification alert in the way I want!

The notification is correctly received form me but, as you reported, no sound is played.
But the message handlers are correctly triggered for me and I can see the alert I call in "pushNotificationReceived" with the payload sent.

ddupont
Posts: 10
Joined: Tue Aug 06, 2013 6:14 pm

Re: Push notification text in the status bar

Post by ddupont » Tue Aug 06, 2013 6:36 pm

Splash21 has posted a sender stack that works. There are parameters for sound that are not in the LC lesson. I have attached splash21's stack for sending push notifications as it is MUCH better than the LC lesson stack. :D

Thank you Splash21! :D
Attachments
AndroidGCM.zip
Splash21 provided this stack, AndroidGCM
(2.86 KiB) Downloaded 398 times

giovanni_c
Posts: 52
Joined: Sat Sep 08, 2012 10:50 am

Re: Push notification text in the status bar

Post by giovanni_c » Fri Nov 08, 2013 12:59 pm

Hi ddupont!
I'm sorry for replying so late to your post.
Splash21's stack helped me to solve the Android Notification Sound problem!
Thank you very much for pointing me to the right direction!!!

I'm not using the JSON form for my data but simply post the data to the sending page and it worked flawlessly sending the parameter "data.play_sound=true"

Great thanks!

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: Push notification text in the status bar

Post by sphere » Sun Sep 06, 2015 7:13 pm

I am glad i finally found this stack whoohoo!

First one that actually works! The lesson did not work for me and i tried dozens of examples from the web.

I always did get the push notification registration, and if i did a push via php script on my website to test i even got Succes:1 from the google server but never got an pushnotification on my rooted Galaxy Sii with Lollipop on it.

But this stack does work with my API and device token credentials.

May i thank you?
I think that's a yes.

Well thank you very much!!!

Now i'm going to check why this works and via my php scripts do not. I want to let it work via the php scripts so the stored device id's can be used.
But maybe i can do a work around. Get the id's from the database and send it direct form the livecode stack instead of sending the message to the php script.

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: Push notification text in the status bar

Post by sphere » Mon Sep 21, 2015 12:52 pm

It seems that in the client app. you have to set which icon will be shown or which sound will be played has to be set.


I noticed that if you do not and you use the androidgcm stack that the notification is received, because i hear the sound, but no notification is shown.
(i also noticed, in all different tests i did, that if you do not send all these things like badge, sound, etc it is not working)

edit---Probably my status bar icon was not findable while building the apk(but i did not get any fault message) once i re-selected the icon, it is now working as expected.

I love it. Sometimes it takes more time to get the puzzle solved.

MWCoastMedia
Posts: 32
Joined: Fri Jan 16, 2015 5:31 pm

Re: Push notification text in the status bar

Post by MWCoastMedia » Tue Sep 01, 2020 5:21 pm

I looked in the Standalone Application Settings Lesson for the specs of this icon, but couldn't find details @ http://lessons.livecode.com/m/4603/l/68 ... n-settings

It would appear this needs to be a 96x96 white PNG with alpha.

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: Push notification text in the status bar

Post by sphere » Tue Sep 01, 2020 6:19 pm

yes it has to be white with alpha.

Previous color was allowed, but after some date it was changed.

Post Reply

Return to “Android Deployment”