Hello,
We encountered a problem with iOS notifications.
We are trying to register the user devices but we are no longer receiving the data from the remoteRegistration (we are registering devices with APNS).
This problem was encountered with the legacy, so we tried to switch to the notifications.v2 plugin. But we encounter the same problem after the migration.
It worked before.
On iOS (It works perfectly on Android), the Runtime: addEventListener (“notification”, notificationListener) does not seem to work.
We have no print displayed in the called notificationListener function.
So it never does the remoteRegistration event.
Oddly, it works if we do a live build, but not with a normal build.
Has anyone encountered this problem?
In advance thank you to the person who will take the time to read my post and will bring me a beginning of solution.
PS: sorry for my bad english.
Here is parts from the code of my main.lua , config.lua and build.settings
Have a nice day!
mail.lua
local notifications = require( "plugin.notifications.v2" ) notifications.registerForPushNotifications() local function notificationListener( event ) print("test of notificationListener") local easyurl = "" if ( event.type == "remoteRegistration" )then print("test of the remoteRegistration") if ( device.isAndroid ) then googleRegistrationId = event.token local message = "This app has successfully registered for Google push notifications." print(message) easyurl = myData.httpsyst..myData.domainesyst..myData.urlpush.."php/apns\_google.php?task=register" else local message = "This app has successfully registered for Ios push notifications." print(message) easyurl = myData.httpsyst..myData.domainesyst..myData.urlpush.."php/apns.php?task=register" end if ( device.isAndroid ) then easyurl=easyurl.."&deviceuid="..urlencode(googleRegistrationId ) else easyurl=easyurl.."&deviceuid="..urlencode(system.getInfo("deviceID")) end if (event.token ~= nil) then easyurl=easyurl.."&devicetoken="..event.token end local headers = {} headers["Content-Type"] = "application/json" local params = {} params.headers = headers network.request ( easyurl, "GET", networkListener, params ) elseif ( event.type == "remote" ) then end end Runtime:addEventListener( "notification", notificationListener )
Config.lua
notification = { iphone = { types = { "badge", "sound", "alert" } }, }
Build.settings
plugins = { ["plugin.notifications.v2"] = { publisherId = "com.coronalabs", }, },