I don't get "remoteRegistration" Event

Yes, It is working well now.

Hi all, I hope this thread is still open. I seem to have encountered this same issue on the most recent build of corona, 2014.2393.

I recently updated an app I launched last year, and it seems to have broken for several users pre 4.0.4 as mentioned above. I can’t figure out what to change (if anything on my end). Below are high level current implementations, build and configs. It seems to be working on many other Android devices, and I’m trying to get as much information from one of my users as possible as to why it isn’t working for them.

Implementation:

function onNotification(event) native.showAlert("GCM EVENT: ","EVENT: "..event.type.." Platform: "..system.getInfo("platformName") ,{"OK"}) if event.type == "remoteRegistration" then local deviceToken = event.token local deviceType = 1 --default to iOS if ( system.getInfo("platformName") == "Android" ) then deviceType = 3 end if(deviceType==1)then -- Apple registration elseif(deviceType==3)then -- GCM registration googleRegistrationId = event.token end end end Runtime:addEventListener("notification", onNotification)

Settings:

settings = { orientation = { default = "portrait", supported = { "portrait" } }, plugins = { ["CoronaProvider.ads.admob"] = { publisherId = "com.coronalabs", supportedPlatforms = {android=true}, }, }, android = { permissions = { { name = ".permission.C2D\_MESSAGE", protectionLevel = "signature" }, }, usesPermissions = { "android.permission.INTERNET", "android.permission.ACCESS\_NETWORK\_STATE", "android.permission.GET\_ACCOUNTS", "android.permission.RECEIVE\_BOOT\_COMPLETED", "com.google.android.c2dm.permission.RECEIVE", "android.permission.C2D\_MESSAGE", "android.permission.ACCESS\_FINE\_LOCATION", -- Fetches location via GPS. "android.permission.ACCESS\_COARSE\_LOCATION", -- Fetches location via WiFi or cellular service. }, usesFeatures = { -- If you set permissions "ACCESS\_FINE\_LOCATION" and "ACCESS\_COARSE\_LOCATION" above, -- then you should set up your app to not require location services as follows. -- Otherwise, devices that do not have location sevices (such as a GPS) will be unable -- to purchase this app in the app store. { name = "android.hardware.location", required = false }, { name = "android.hardware.location.gps", required = false }, { name = "android.hardware.location.network", required = false }, }, }, iphone = { plist = { CFBundleIconFile = "Icon.png", CFBundleIconFiles = { "Icon.png", "Icon@2x.png", "Icon-72.png", "Icon-72@2x.png", }, UIAppFonts = { "LiberationSans-Regular.ttf" }, UIApplicationExitsOnSuspend = false, UIStatusBarHidden = true, }, components = {}, }, }

Config (note, just one of several potential configs):

else print("CONFIG----6") application = { content = { graphicsCompatibility = 1, width = 320, height = 512, scale = "letterBox", xAlign = "center", yAlign = "center", imageSuffix = { ["@2x"] = 1.5, ["@4x"] = 3.0, }, }, notification = { iphone = { types = { "badge", "sound", "alert" } }, google = { projectNumber = "xxxxxxxxxxx" } } } end

Bump?

While I’m not an Android expert, you do have a difference in your build.settings from our sample app which is known to work.  These are the permissions from the sample app:

        usesPermissions =
        {
            “android.permission.INTERNET”,
            “android.permission.GET_ACCOUNTS”,
            “android.permission.RECEIVE_BOOT_COMPLETED”,
            “com.google.android.c2dm.permission.RECEIVE”,
            “.permission.C2D_MESSAGE”,
        },

Note the last one does not have com.google.android on it nor android.  Perhaps you could try the permissions as specified above and see if that addresses your issue.

Rob

Ok thanks Rob, going to try that and see if it works. Out of curiosity, why isn’t that consistent?

I have no idea.  I don’t know Android native behavior well enough to know if this is a Googleism or not.

Rob

Hi, I can get Android registration key(device token)  but i can’t iphone device token.

Do you have any idea?

I can’t get any notification event.

local function notificationListener( event )

    native.showAlert( “Alert”, “I can’t get any event”, {“Ok”} )

    if ( event.type == “remoteRegistration” ) then

        native.showAlert( “Register”, event.token, { “Ok” } )

    elseif ( event.type == “remote” ) then

        --handle the push notification

    end

end

–The notification Runtime listener should be handled from within “main.lua”

Runtime:addEventListener( “notification”, notificationListener )

Below is my config file content.

application = {

   content = {

      width = aspectRatio > 1.5 and 320 or math.ceil( 480 / aspectRatio ),

      height = aspectRatio < 1.5 and 480 or math.ceil( 320 * aspectRatio ),

      scale = “letterBox”,

      fps = 60,

      imageSuffix = {

         ["@2x"] = 1.5,

         ["@4x"] = 3.0,

      },

      notification = 

      {

         iphone =

         {

            types = { “badge”, “sound”, “alert” }

         },

         google =

         {

            projectNumber = “1039916599XXX”

         },

      }

   },

}

I’ll check my configuration and initial code later, but did you setup dev cert for push notifications and enable in Apple developer?

Sorry, There was issue in config file.

As you can see above, notification tag should be same level with content below application.

I have just seen that after post

Did you get it working?

Yes, It is working well now.