Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Gideros Notification Plugin - Page 2 — Gideros Forum

Gideros Notification Plugin

245

Comments

  • @kussakov
    1) for example, you send a push notification with promotion, get free 10 coins, and if in your app you want to identify, that user opened the app using this push notification or received it during the app running, you may assign him 10 coins.

    If you don't need it, you can simply send push notifications and only this app will receive it, only you won't be able to identify if this was the exact push notification inside your lua code

    Because as you know push notifications are push and forget (at least if done directly without third party provider), so the ids are meant for you to identify if user received this specific push notification or not inside your lua code, nothing more.

    2) you don't have to clear the notifications per se, but it might be a good idea to clear them once you don't need information about it, just not to consume memory for storing information about notification (especially if you send them a lot)
  • ar2rsawseenar2rsawseen Maintainer
    edited September 2013
    Updated Notification plugin both repo and gideros labs:

    http://giderosmobile.com/labs/notification
    version 1.1

    Fixed crash when opening app with notification
    Fixed repeating local notifications

    Unfortunately currently it seems Apple decides on its own when to re dispatch repeating notifications, but I will experiment if I can get around it by manually re dispatch them later on. For now on IOS it takes full measurements, as 1 minute, 1 second, 1 day, 1 week, 1 month or 1 year. If multiple are specified, it takes the highest one, as in if you specify 1 day and 1 hour, it will re dispatch just approximately every day.
  • One more update to Notification plugin on android side:

    version 1.2
    Android - made event related variables thread safe
    Android - does not dispatch notification when app is in forground, instead dispatched internal Lua event (same as IOS)
    Android - notifications get cleared after click on them
  • Hmm.. I checked the iOS plugin, and it seems that it won't get cleared after i click on them. I wonder if i did something wrong...

    iOS7 by the way.
  • ar2rsawseenar2rsawseen Maintainer
    edited October 2013
    unfortunately currently I did not find a way to do that on IOS, only thing I currently do is to reset the app icon number to 0.

    From the information found on the internet, only canceling all notifications seem to solve the issue, but I don't want to implement that to do automatically, because it will also cancel scheduled notifications
  • After some testing on Android, i think i found a bug (but might be not).

    1. Can't seem to cancel all the notification with cancelAllNotifications(),
    so what i did is i cancel each of the notif in each id.

    2. Default sound seems not working and there is no vibration?
    As for this case, i did a change on public Notification createNotification, but since i'm not used with this, what i did is just remove checking on sound == "default" and forcely add :
    mBuilder.defaults = Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE;


    Might be a good to add setVibrate on Android, and setBadge(without notif) on iOS.
  • Ok will check them both.

    Might be a good to add setVibrate on Android, and setBadge(without notif) on iOS.
    the reason it was not done, trying to maintain same API to both Android and IOS, thus unfortunately cutting of some specific functionalities.

  • @tkhnoman updated the notification plugin
    1) rebuilt .so files to work with new Gideros version
    2) added Android vibration by default
    3) fixed bug, that cancelAll did not cancel the notifications, which had not instances created in this app session. now it should really cancel all notifications ;)
  • amaximovamaximov Member
    edited November 2013
    @ar2rsawseen just started having some issues using Android:

    Basically my app registers properly with GCM, gets the device token, and registers with PushWoosh.

    Now, my app is currently open in the foreground and when I send a push notification nothing happens. My status bar does not get a notification, and neither does my Event.PUSH_NOTIFICATION listener function get called. However, ADB DOES SHOW PLUGIN ACTIVITY(Check log).

    Now when I press the home button and my app goes into the background and I send a notification I get a crash if my phone is NOT in silent mode! Notification is still received but activity issues a crash warning. (Check log)

    Also strangely the log says the error was a SecurityException and that I needed the VIBRATION permission. This wasn't in the GitHub docs so I added:

    uses-permission android:name="android.permission.VIBRATE"

    However, still same exact error! Also, the notification does in fact get processed successfully if my phone IS in silent mode.

    Same problem occurs with delayed local notifications when my phone ringtone and vibration is on. Using dispatchNow on a local notification works fine however.

    In summary:
    application in foreground + push notification = nothing happens
    application in foreground + local notification = great
    application in background+ push notification + NOT in silent mode = crash
    application in background+ local notification + NOT in silent mode = crash
    application in background+ push notification + IN silent mode = ok
    application in background+ local notification + IN silent mode = great

    I have the latest libs and classes from your GitHub and I'm at a loss to explain the problem. Any help is appreciated :)
    txt
    txt
    log.txt
    7K
  • @amaximov sure I'll test the cases more and get back to you ;)
  • amaximovamaximov Member
    edited November 2013
    Ah well here is an update:

    I think my Eclipse was bugging out and I solved the vibration issue.

    So now:
    application in background+ push notification + NOT in silent mode = great
    application in background+ local notification + NOT in silent mode = great
    application in background+ push notification + IN silent mode = great
    application in background+ local notification + IN silent mode = great

    New issue discovered:
    The above 4 work only if my app is in the background but ALIVE. If my app has been shutdown with a task manager, I still get the notification but the app crashes immediately after I click the notification and the Gideros splash screen ends. Log attached.

    Also, still:

    application in foreground + push notification = nothing happens (ADB shows plugin activity as before)

    Attached are two new logs. The first logis when the app has been killed and it receives the notification. Looks as if it tries to start the app back up in the background or something... log2 is a couple seconds after when I actually click the notification and the app crashes on startup. The logs are separate because between them there was a bunch of useless not related Facebook and TextPlus junk.
    txt
    txt
    log1.txt
    3K
    txt
    txt
    log2.txt
    13K
  • @ar2rsawseen I'm thinking about writing my own GCM server and using Parse for iOS but I have some questions first. I've never done native push notification development and my first question is: what json format does the Gideros Notification Plugin parse?

    For example sending a PushWoosh notification to a Gideros and Corona client produces slightly different results because I assume the plugins parse the data slightly differently and display different device notifications.

    Could you possibly add this to the docs so we know what data to send?
  • ar2rsawseenar2rsawseen Maintainer
    edited December 2013
    I've wrote a simple PHP class to handle both IOS and Android push notifications.
    I've attached it here:

    If you don't know/have PHP, the json format is something like

    ios
    Array
    (
        [aps] => Array
            (
                [alert] => Array
                    (
                        [action-loc-key] => Test it 2
                        [body] => Final test push notification
                    )
     
                [badge] => 1
                [sound] => default
            )
    )
    or
    Array
    (
        [aps] => Array
            (
                [alert] => Push notification text here
     
                [badge] => 1
                [sound] => default
            )
    )
    Android
    Array
    (
        [registration_ids] => Array
            (
                --list of all registered ide
                [0] => id1
                [1] => id2
            )
     
        [data] => Array
            (
                [message] => Final test push notification
                [title] => Test it 2
                [sound] => default
                [number] => 1
            )
    )
  • VenorcisVenorcis Member
    edited December 2013
    @ar2rsawseen thanks for the server examples; very useful!
    However, on Android I have the problem @amaximov mentions: everything works fine when the app is closed, but when the app is already open and a notification arrives, nothing happens! Is this a bug or am I doing something wrong?

    Thanks,
    -Vincent

    PS. This is using latest v1.2 from the labs page
    PS2. Latest Git version (which is identical, apparentley) gives same results
  • Sorry not yet, last week finished all with other plugins and this is the next one, will look at it today ;)
  • Great news ar2rsawseen! I just finished implementing device registration/unregistration on my GCM server:)
  • ar2rsawseenar2rsawseen Maintainer
    edited December 2013
    @amaximov awesome :)
    The first time I've sent a push notification from my server, when making this plugin, I was like:
    image
    +1 -1 (+4 / -0 )Share on Facebook
  • I have tried out the plugin both on player and app and exported app and it works great in both background and foreground. So I can't reproduce the issue, but the fact that you both have it, seems disturbing.

    Just a reminder but there was recently a change in the plugins files, so plugins where rebuilt for latest Gideros version, so make sure you use new files with new Gideros version

    And I would appreciate if any of you could send me exported android project with installed plugin, which does not work for you, to ar2rsawseen at gmail dot com so I could check it out ;)
  • @ar2rsawseen I've sent you a mail with a compiled player app ;) I've used the latest files for it, but that hasn't changed since my first message about this issue.
  • ar2rsawseenar2rsawseen Maintainer
    edited December 2013
    Interesting but both with your project and player.apk I can receive both notifications (local and push) in foreground and background. So maybe the problem is either on Lua part (the code) or on server part (the message structure), or maybe device specific?

    So what I have on Lua part is:
    local mngr = NotificationManager.getSharedInstance()
    --receiving local notification in foreground
    --or app opened through local notification
    mngr:addEventListener(Event.LOCAL_NOTIFICATION, function(e)
    	mngr:cancelNotification(e.id)
    	print("Local notification: "..e.id)
    	print("Title: "..e.title)
    	print("Text: "..e.message)
    	print("Number: "..e.number)
    	print("Sound: "..e.sound)
    end)
     
    --registering to push notifications
    mngr:addEventListener(Event.PUSH_REGISTRATION, function(e)
    	--print out the token
    	print("Push notification registered: "..e.deviceId)
    end)
     
    --could nor register
    mngr:addEventListener(Event.PUSH_REGISTRATION_ERROR, function(e)
    	print("Could not register: "..e.error)
    end)
     
    --receiving push notification in foreground
    --or app opened through push notification
    mngr:addEventListener(Event.PUSH_NOTIFICATION, function(e)
    	print("Push notification: "..e.id)
    	print("Title: "..e.title)
    	print("Text: "..e.message)
    	print("Number: "..e.number)
    end)
     
    --my google api console
    mngr:registerForPushNotifications("953841987672")
     
    --dispatch local notification on click
    stage:addEventListener(Event.MOUSE_DOWN, function()
    	local note = Notification.new(1)
    	note:setTitle("Test from Lua")
    	note:setMessage("Do you see me?")
    	note:dispatchAfter({sec = 20})
    end)
    Then I launch the app, copy the deviceId in output pane, which was printed there on Event.PUSH_REGISTRATION event, and go to my PHP files I posted previously. Open try.php and change the deviceId in $push->set_android_devices method.
    And simply launch try.php on my server through browser.

    And it all works :)

    So any other ideas what may go wrong? Any device specifics you have?
  • @ar2rsawseen When including a Event.PUSH_NOTIFICATION listener, I do get the following output:
    Push notification: 0
    Title: Test
    Text: Dit is een test!
    Number: 0

    Is it correct that both the ID and the number are 0 although I do set the number to 1 by default (I use your server classes almost directly)? Still, no notification window shows on multiple devices, and no vibrate or something happens.

    -Vincent
  • @Venorcis yes this is a default behavior for foreground that your receive the notification and should handle it internally. Although on Android it would be possible still to dispatch the notification in the bar, to make the behavior similar to ios this is how notifications are handled in opened app and you could vibrate, bring up the AlertDialog etc as you would like yourself.

    To pass ID, you should need to set id in your android json, I think I have not implemented it in pusher class, will update it later.

    And would need to check on whats happening with the number
  • @ar2rsawseen Ah, then that is my confusion! I'm used to iOs myself so I did not know that you have to handle those notifications yourself in the app. I guess that could be made more clear in the manuals then as well, as two persons apparantley did not understand it properly :P Another thing I've noticed is that the manuals use 'deviceToken' for the PUSH_REGISTRATION event, but this should be 'deviceId' (for Android at least).
    Sorry for possibly wasting your time with this ;)
  • @ar2rsawseen I've got a really busy school week ahead for me so I'll try to send you an Eclipse project bit it might be delayed. Thanks for the help :)
  • amaximovamaximov Member
    edited December 2013
    @ar2rsawseen sorry I still don't have a project to send :( School has been really tough this week but I have made some progress on my GCM server.

    Quick question, you said : "Just a reminder but there was recently a change in the plugins files, so plugins where rebuilt for latest Gideros version, so make sure you use new files with new Gideros version"

    I can't seem to find any Notification plugin under my "All Plugins" folder in the Gideros installation using Gideros 2013.09.1
  • no worries,
    and about new libs, in both Gideros Labs and github, there are two folders, you should use libs-old with older Gideros version and libs with latest version
  • Successful GCM notification sent from server! All with an API for registering and unregistering devices using Google App Engine Datastore as my database!

    Will try to find some time tomorrow to test Gideros Notification Plugin thoroughly.
    the-very-best-of-the-success-kid-meme.jpg
    513 x 339 - 20K
  • @ar2rsawseen I've run into a problem I simply cannot figure out how to fix. I have a custom Gideros player w/notification plugin that I use for testing. I can successfully register with gcm, get token, and register with my server. However when I export my Lua code to a dedicated Android project, the mngr:registerForPushNotifications("googleprojnumber") call does nothing. I do not get a PUSH_REGISTRATION or PUSH_REGISTRATION_ERROR event. As far as I can tell my projects are set up identically and I am using the same keystore and alias to sign the custom player and dedicated app. Do you have any hints?
Sign In or Register to comment.