Push Notification custom data not working with APP42

0 votes

Hi,

 

I have been trying very hard a more than a week to get APP42 push notification with custom data to work. I keep receiving empty table from the push notification on the device. It seems that the custom data is not being push through vua GCM to the device. I have modify the code to do the push via gcm directly and it works perfectly. It seems like a bug in APP42. Also, I noticed that event.sound does not work too. Below is the code in my main.lua to receive the notification.

 

local function onNotification( event )
    if event.type == "remoteRegistration" then
      Constants.DeviceToken = event.token
      _G.PushToken = event.token
    elseif event.type == "remote" then
              native.showAlert("Advanced Msg", event.custom.key1 , {"OK"}) -- on APP42 HQ, I have put in key1: 123456
 
    elseif event.type == "local" then 
      native.showAlert( "Boss Rewards", event.custom.key1 , {"OK"} )
    end
end
 
Runtime:addEventListener( "notification", onNotification )
 
local options = {
    alert = "Wake up!",
    badge = 2,
    sound = "notification.wav",
    custom = { key1 = "Get a job" }
}
 
-- TEST LOCAL NOTIFICATION
local utcTime = os.date( "!*t", os.time() + 30 )
local notification = notifications.scheduleNotification( utcTime, options ) 
 
local launchArgs = ...
 
if ( launchArgs and launchArgs.notification ) then
 
    onNotification( launchArgs.notification )
end
 
Can somebody please help urgently?
 
Thanks.
asked Aug 18, 2016 in Corona by tianchoh (10 points)

1 Answer

0 votes

Hi Tianchoh,

I am forwarding this to my development team to get you code snippet for the same. I will update you with the code snippet as soon as possible.

Regards,

Rajeev

answered Aug 19, 2016 by rajeev.etc (1,660 points)
Hi Tian,

Could you please encode the response which comes in notification message and share with us. So that we can provide correct code snippet to you:

local JSON = require("App42-Lua-API.JSON")
JSON:encode(notification )

Regards,
Himanshu Sharma
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
...