Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Push Notifications on Android Missing Sent Text Data
Started by tokevinharris Feb 14 2020 02:19 PM

1 reply to this topic
android push notifications
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

tokevinharris

[GLOBAL: userInfoPane.html]
tokevinharris
  • Observer

  • 1 posts
  • Corona SDK

I'm using the REST API of Backendless to send push notifications from my Corona game. I've been successful in sending push notifications to both iOS and Android devices. On iOS the push notifications look good, but on Android. the message, as it appears in the system tray that you pull down, is missing all the text sent. The message only has test that says the app's name and the name is shown twice for some reason.

 

The JSON that I send to Backendless looks like this:


{
    "message": "test message",
    "headers": {
        "ios-alert": "test ios alert",
        "ios-sound": "default",
        "android-content-title": "test content title",
        "android-content-text": "test content text",
        "android-ticker-text": "test ticker text",
        "gameId": "test game id"
    }
}

 

Now, no other Backendless developers seem to have the same issue as me, so is it possible the this is a Corona issue? Why would Android not show any text for, "message", "android-content-title", "android-content-text", or "android-ticker-text" on the notification? Does Corona need or use different names?

 



[TOPIC: post.html]
#2

yosu

[GLOBAL: userInfoPane.html]
yosu
  • Contributor

  • 551 posts
  • Corona SDK

Try using the 'alert' instead of 'message' key.

 

A sample POST to FCM :

$data = array(
	'alert' => 'Your push notification message',
	'data' => 'this is an array with data that you want to send together with this. Note there is a max size',
);

$post = array(
	'registration_ids'  => 'an array of google-fcm tokens',
	'data'              => $data,
	'time_to_live'		=> 'in seconds, see fcm document',		
);

// Add your api-key into the 'Authorization' header. Remember to json-encode the array before sending to https://fcm.googleapis.com/fcm/send



[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: android, push notifications