Hi All,
I am using pushwoosh to send remote notifications to my app (IOS - testing phase) and the basic text works well. I do have some problems with way the remote message is displayed.
If the app is not active, a notification alerts the user. this notification piece is working well. When the user taps this notification or if the app is active, the remote message is displayed in alert style, encoded. Please see the attached screen shot. I just want the message displayed with the app icon, like the notification.
Thanks
==================
main.lua has the following code to handle the event:
local launchArgs = …
local json = require “json”
if launchArgs and launchArgs.notification then
native.showAlert( “launchArgs”, json.encode( launchArgs.notification ), { “OK” } )
end
– notification listener
local function onNotification( event )
if event.type == “remoteRegistration” then
--native.showAlert( “remoteRegistration”, event.token, { “OK” } )
local DeviceID = event.token
local PW_APPLICATION = “C327E-C1959” --use your app id in pushwoosh
local PW_URL = “https://cp.pushwoosh.com/json/1.3/registerDevice”
local function networkListener( event )
if ( event.isError ) then --error occurred notify user
native.showAlert( “Notification Registration Failed”, “An Error Contacting the Server has Occurred. Please try again later from the application settings.”, { “OK” } )
else
--Registration worked perform any action you like here
end
end
local commands_json =
{
[“request”] = {
[“application”] = PW_APPLICATION,
[“push_token”] = DeviceID,
[“language”] = system.getPreference(“ui”, “language”),
[“hwid”] = system.getInfo(“deviceID”),
[“timezone”] = 3600, – offset in seconds
[“device_type”] = 1
}
}
local jsonvar = {}
jsonvar = json.encode(commands_json)
local post = jsonvar
local headers = {}
headers[“Content-Type”] = “application/json”
headers[“Accept-Language”] = “en-US”
local params = {}
params.headers = headers
params.body = post
network.request ( PW_URL, “POST”, networkListener, params )
elseif event.type == “remote” then
native.showAlert( “remote”, json.encode( event ), { “OK” } )
– native.showAlert( “remote”, json.encode( launchArgs.notification ) , { “OK” } )
end
end
Runtime:addEventListener( “notification”, onNotification )