Push Android Problem with build 1260

Hi,

I followed the complete procedure (gcm console with api key and projectnumber, config.lua, build.lua and main.lua parameters) and nothing works. A problem with the build 1260 there ?

Best regards

Hi @Gispubc,

Just to confirm, did you follow through the entire guide on push notifications here?

http://docs.coronalabs.com/guide/events/appNotification/index.html

Best regards,

Brent Sorrentino

Sure.

For information everything works very well under IOS.

Config.lua :

[lua]

      – Push notifications

      notification =

      {

          google = { projectNumber = “myprojectnumber”, },        

      }

[/lua]

Build.lua :

[lua]

– Supported values for orientation:

– portrait, portraitUpsideDown, landscapeLeft, landscapeRight

settings = {

    

    orientation = {

        default = “portrait”,

        supported = { “portrait”, }

    },

    

    iphone = {

        plist = {

            UIStatusBarHidden = false,

            UIPrerenderedIcon = true, – set to false for “shine” overlay

            --UIBackgroundModes =

            --{

            –    “location”,

            --},

            UIApplicationExitsOnSuspend = false,

            --UIApplicationExitsOnSuspend = true, – uncomment to quit app on suspend

            – iOS app URL schemes:

            CFBundleURLTypes =

            {

                {

                    CFBundleIdentifier = “mybundleidentifier”,

                }

            },

            CFBundleIconFiles = {

                “Icon.png”,

                “Icon@2x.png”,

                “icon~ipad.png”,

                “icon@2x~ipad.png”,

                “Icon-60.png”,

                “Icon-60@2x.png”,

                “Icon-72.png”,

                “Icon-72@2x.png”,

                “Icon-76.png”,

                “Icon-76@2x.png”,

                “Icon-Small-50.png”,

                “Icon-Small-50@2x.png”,

                “Icon-Small.png”,

                “Icon-Small@2x.png”

            },

        }

    },

    

    – Android permissions

    android =

    {

        versionCode = “18”,

        permissions =

        {

            { name = “.permission.C2D_MESSAGE”, protectionLevel = “signature” },

        },

        usesPermissions =

        {

            “android.permission.INTERNET”,

            “android.permission.CALL_PHONE”,

            “android.permission.CALL_PRIVILEGED”,

            “android.permission.PROCESS_OUTGOING_CALLS”,

            “android.permission.READ_PHONE_STATE”,

            “android.permission.RECORD_AUDIO”,

            – Required by the MapView to fetch its contents from the Google Maps servers.

            --“android.permission.INTERNET”,

            – Optional permission used to display current location via the GPS.

            “android.permission.ACCESS_FINE_LOCATION”,

            – Optional permission used to display current location via WiFi or cellular service.

            “android.permission.ACCESS_COARSE_LOCATION”,

            “android.permission.GET_ACCOUNTS”,

            “android.permission.RECEIVE_BOOT_COMPLETED”,

            “com.google.android.c2dm.permission.RECEIVE”,

            “.permission.C2D_MESSAGE”,

        },

        usesFeatures =

        {

            – If you set permissions “ACCESS_FINE_LOCATION” and “ACCESS_COARSE_LOCATION” above,

            – then you may want to 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 },

        },

    },

}

[/lua]

Main.lua :

[lua]

local launchArgs = …

local json = require “json”

if launchArgs and launchArgs.notification then

    --native.showAlert( “launchArgs”, json.encode( launchArgs.notification ), { “OK” } )

    --onNotification( launchArgs.notification )

end

– notification listener

local function onNotification( event )

    if event.type == “remoteRegistration” then

        local DeviceID = event.token

        local deviceType = 1 

        if “Android” == platformName then deviceType = 3 end

        local PW_APPLICATION = “myappid”    --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”] = deviceType

                            }

                        }

                    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 )

    end

end

Runtime:addEventListener( “notification”, onNotification )

[/lua]

Hi @Gispubc,

Could I kindly ask you to test this same code in a newer build of Corona, i.e. #2100? I’m curious to see if the issue remains in more recent builds, and whether it’s isolated to #1260.

Thanks,

Brent

I ve tried with other build under 1260 (its the same) but i can’t test on build with graphic 2.0 because its too much work to make the porterage.

Can you do a basic test in 2.0 if you set V1 Compatibility mode on, so you don’t need to make many changes to the code base?

I have already tried but nothing more works. I do not have time to make the modifications for this application which works very well safe for push android. The problem comes necessarily from the build.

I just compiled with build 2122 and nothing more works… nothing Android users registered in pushwoosh and no message which asks me if I accept the notifications moreover.

example.png

Hi @Gispubc,

The problem may be with PushWoosh and/or how you’ve set it up. Can you test out our sample project and see if you have better luck? It’s located in your local Corona application directory:

CoronaSDK > SampleCode > Notifications > GooglePushNotifications

Best regards,

Brent

Hi @Gispubc,

Just to confirm, did you follow through the entire guide on push notifications here?

http://docs.coronalabs.com/guide/events/appNotification/index.html

Best regards,

Brent Sorrentino

Sure.

For information everything works very well under IOS.

Config.lua :

[lua]

      – Push notifications

      notification =

      {

          google = { projectNumber = “myprojectnumber”, },        

      }

[/lua]

Build.lua :

[lua]

– Supported values for orientation:

– portrait, portraitUpsideDown, landscapeLeft, landscapeRight

settings = {

    

    orientation = {

        default = “portrait”,

        supported = { “portrait”, }

    },

    

    iphone = {

        plist = {

            UIStatusBarHidden = false,

            UIPrerenderedIcon = true, – set to false for “shine” overlay

            --UIBackgroundModes =

            --{

            –    “location”,

            --},

            UIApplicationExitsOnSuspend = false,

            --UIApplicationExitsOnSuspend = true, – uncomment to quit app on suspend

            – iOS app URL schemes:

            CFBundleURLTypes =

            {

                {

                    CFBundleIdentifier = “mybundleidentifier”,

                }

            },

            CFBundleIconFiles = {

                “Icon.png”,

                “Icon@2x.png”,

                “icon~ipad.png”,

                “icon@2x~ipad.png”,

                “Icon-60.png”,

                “Icon-60@2x.png”,

                “Icon-72.png”,

                “Icon-72@2x.png”,

                “Icon-76.png”,

                “Icon-76@2x.png”,

                “Icon-Small-50.png”,

                “Icon-Small-50@2x.png”,

                “Icon-Small.png”,

                “Icon-Small@2x.png”

            },

        }

    },

    

    – Android permissions

    android =

    {

        versionCode = “18”,

        permissions =

        {

            { name = “.permission.C2D_MESSAGE”, protectionLevel = “signature” },

        },

        usesPermissions =

        {

            “android.permission.INTERNET”,

            “android.permission.CALL_PHONE”,

            “android.permission.CALL_PRIVILEGED”,

            “android.permission.PROCESS_OUTGOING_CALLS”,

            “android.permission.READ_PHONE_STATE”,

            “android.permission.RECORD_AUDIO”,

            – Required by the MapView to fetch its contents from the Google Maps servers.

            --“android.permission.INTERNET”,

            – Optional permission used to display current location via the GPS.

            “android.permission.ACCESS_FINE_LOCATION”,

            – Optional permission used to display current location via WiFi or cellular service.

            “android.permission.ACCESS_COARSE_LOCATION”,

            “android.permission.GET_ACCOUNTS”,

            “android.permission.RECEIVE_BOOT_COMPLETED”,

            “com.google.android.c2dm.permission.RECEIVE”,

            “.permission.C2D_MESSAGE”,

        },

        usesFeatures =

        {

            – If you set permissions “ACCESS_FINE_LOCATION” and “ACCESS_COARSE_LOCATION” above,

            – then you may want to 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 },

        },

    },

}

[/lua]

Main.lua :

[lua]

local launchArgs = …

local json = require “json”

if launchArgs and launchArgs.notification then

    --native.showAlert( “launchArgs”, json.encode( launchArgs.notification ), { “OK” } )

    --onNotification( launchArgs.notification )

end

– notification listener

local function onNotification( event )

    if event.type == “remoteRegistration” then

        local DeviceID = event.token

        local deviceType = 1 

        if “Android” == platformName then deviceType = 3 end

        local PW_APPLICATION = “myappid”    --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”] = deviceType

                            }

                        }

                    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 )

    end

end

Runtime:addEventListener( “notification”, onNotification )

[/lua]

Hi @Gispubc,

Could I kindly ask you to test this same code in a newer build of Corona, i.e. #2100? I’m curious to see if the issue remains in more recent builds, and whether it’s isolated to #1260.

Thanks,

Brent

I ve tried with other build under 1260 (its the same) but i can’t test on build with graphic 2.0 because its too much work to make the porterage.

Can you do a basic test in 2.0 if you set V1 Compatibility mode on, so you don’t need to make many changes to the code base?

I have already tried but nothing more works. I do not have time to make the modifications for this application which works very well safe for push android. The problem comes necessarily from the build.

I just compiled with build 2122 and nothing more works… nothing Android users registered in pushwoosh and no message which asks me if I accept the notifications moreover.

example.png

Hi @Gispubc,

The problem may be with PushWoosh and/or how you’ve set it up. Can you test out our sample project and see if you have better luck? It’s located in your local Corona application directory:

CoronaSDK > SampleCode > Notifications > GooglePushNotifications

Best regards,

Brent