sending push in other languages using server api

Hi, I get this error message while trying to send push 

{"errors":["  Notifications must have English language content"]} 

While I do understand what it means Im not sure how to use languages. There are 2 fields that can be used, one is the header field “headers[“Accept-Language”]” and one is the json message [“contents”] I want to use swedish language, I’ve tried changing these to ISO language code, eg: “sv-SWE” and [“sv”] and get this error message.

Thanks

Hello,

You can set the message for each language by using the ISO 639-1 format (2 letter code) for each language as a key in the contents hash. See this example for setting English and Swedish.

contents: {"en": "English Message","sv": "Swedish Message"}

The only exceptions are “Chinese (Simplified)” = “zh-Hans” and “Chinese (Traditional)” = “zh-Hant”

You do not need to include a Accept-Language in your header as it is not used.

The headings field used in the title of the notification also follows this same format. See our full create notification REST API page.

Thanks.

Im using it inside of corona at the moment for testing, but I have this

[“contents”] = {[“sv”] = “Testar och skicka från telefonen”},

and its giving me the above error.

Thanks.

You still need “en” defined in the hash. If you want all users to receive your message in Swedish you can just use “en” instead of “sv”.

The reason we require “en” as it is used as a default if you don’t define a language. For example if you have some users who have their device set to Spanish and you do not include “es” in your contents hash they will get the message string you set in “en”.

Thanks.

Thank you for the help =)

jkasten, would you be so kind in helping me in this one also. Im trying to send a push using tags via the api but keep running into errors.

The tag looks like this at the moment. [“tags”] = {[“key”] = “iFreduser”, [“relation”] = “=”, [“value”] = “54071”} Normally I would get a error back saying {“errors”:[“You must include which players, segments, or tags you wish to send this notification to.”]}  But know Im getting back html header saying <title>We’re sorry, but something went wrong (500)</title> … Ive seen this error before but thats when the keys are wrong. I can’t figure out what Im doing wrong here. Thanks.

Our tags field is a JSON array of hash so you need to add an extra set of {} around the tags value to make it an array.

The following should work.

["tags"] = {{["key"] = "iFreduser", ["relation"] = "=", ["value"] = "54071"}}

Thanks.

Thank you =)) Is it possible to se all messges that have been recivied or only the last one? At the moment Im trying to add received messages to a table with no luck. Im asking because som messges are b64encoded and are decoded inside “DidReceiveRemoteNotification”. But at the moment its only possible to se the last message when encoded. I can use GameThrive.ClearAllNotifications() but what exactly does it clear?

You can only get the notification that was tapped on (or ones comes in while the app is in use) with DidReceiveRemoteNotification.

GameThrive.ClearAllNotifications() clears all notifications from the app no matter if they are with Corona’s local notification plugin or remote with GameThrive.

Thanks.

You can save your messages into app local storage to access it on later in the app. When ever remote notification received push messages, you can retrieve that message and save into app local storage.

Hi hs00105, how would I go about to do that? I can save them to a table inside the app with DidReceiveRemoteNotification, but outside the app I have no idea? Thanks

Hello Sam,

We don’t have a way to retrieve all notifications that have been sent to the device from GameThrive in Lua however we did just add Android background data (silent notification) support and already have support from our server to send iOS content-available notifications. Since your using Enterprise you can follow these instructions to add the Android BroadcastReceiver and do any processing or saving of the data you need to. On iOS you just need to hook into the application:didReceiveRemoteNotification:fetchCompletionHandler: selector.

Note we just added Android part today so it should show in the next Daily plugin builds. You should see version 1.8.0 printed in the terminal when you have the newest version.

Thanks.

Hello Sam,

If you have a scenario where you have to display the previous push messages to your app user. In that case, you required some data base where you can save your push message when user received on device.  And you can easily maintain it by fetching it from data base and display it on device UI. Apart from displaying the messages, you can apply analytic’s to show user that, how much he is using his app and ho much time? At what time he/she reads the messages? Or play the game etc by saving/fetching the information into data base.

Thanks,

Himanshu Sharma 

Thank you both for the information  :slight_smile:

Hello,

You can set the message for each language by using the ISO 639-1 format (2 letter code) for each language as a key in the contents hash. See this example for setting English and Swedish.

contents: {"en": "English Message","sv": "Swedish Message"}

The only exceptions are “Chinese (Simplified)” = “zh-Hans” and “Chinese (Traditional)” = “zh-Hant”

You do not need to include a Accept-Language in your header as it is not used.

The headings field used in the title of the notification also follows this same format. See our full create notification REST API page.

Thanks.

Im using it inside of corona at the moment for testing, but I have this

[“contents”] = {[“sv”] = “Testar och skicka från telefonen”},

and its giving me the above error.

Thanks.

You still need “en” defined in the hash. If you want all users to receive your message in Swedish you can just use “en” instead of “sv”.

The reason we require “en” as it is used as a default if you don’t define a language. For example if you have some users who have their device set to Spanish and you do not include “es” in your contents hash they will get the message string you set in “en”.

Thanks.

Thank you for the help =)

jkasten, would you be so kind in helping me in this one also. Im trying to send a push using tags via the api but keep running into errors.

The tag looks like this at the moment. [“tags”] = {[“key”] = “iFreduser”, [“relation”] = “=”, [“value”] = “54071”} Normally I would get a error back saying {“errors”:[“You must include which players, segments, or tags you wish to send this notification to.”]}  But know Im getting back html header saying <title>We’re sorry, but something went wrong (500)</title> … Ive seen this error before but thats when the keys are wrong. I can’t figure out what Im doing wrong here. Thanks.

Our tags field is a JSON array of hash so you need to add an extra set of {} around the tags value to make it an array.

The following should work.

["tags"] = {{["key"] = "iFreduser", ["relation"] = "=", ["value"] = "54071"}}

Thanks.