How can I get notification when the app is opened

Hi,

I was using PHP to send notification before and I am now trying to use OneSignal to replace my really outdated method. However, I had my first problem when I tried my first OneSignal notification on my Android device.

I added the following code to the main.lua

-- OneSignal Notification -- This function gets called when the user opens a notification or one is received when the app is open and active. -- Change the code below to fit your app's needs. function DidReceiveRemoteNotification(message, additionalData, isActive)     if (additionalData) then         if (additionalData.discount) then             native.showAlert( "Discount!", message, { "OK" } )             -- Take user to your app store         elseif (additionalData.actionSelected) then -- Interactive notification button pressed             native.showAlert("Button Pressed!", "ButtonID:" .. additionalData.actionSelected, { "OK"} )         end     else         native.showAlert("OneSignal Message", message, { "OK" } )     end end local OneSignal = require("plugin.OneSignal") -- Uncomment SetLogLevel to debug issues. -- OneSignal.SetLogLevel(4, 4) OneSignal.Init("MYONESIGNALPROJECTID", "MYANDROIDPROJECTID", DidReceiveRemoteNotification)

When I deploy my APK to my device and opened the app, I can see my device listed on the “All Users” page on your web platform.

I closed my app and try to send a test notification to my Android device. It works! However, I open my App and try again to send another test notification, it didn’t popup anything in my App. Looks like the above “DidReceiveRemoteNotification” is not working.

ok. I found I missed a line in the configuration file:

UIBackgroundModes = {“remote-notification”},

I think it is for iOS but after I added this line, it works on my Android device.

ok. I found I missed a line in the configuration file:

UIBackgroundModes = {“remote-notification”},

I think it is for iOS but after I added this line, it works on my Android device.