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

Gideros Notification Plugin

135

Comments

  • I still get no PUSH_NOTIFICATION event when my app is in the foreground. @ar2rsawseen I think the plugin needs a definitive update.
  • Hello @amaximov can you send me your set up Android project to ar2rsawseen at gmail dot com so I could check it out ;)
  • ar2rsawseenar2rsawseen Maintainer
    edited January 2014
    I'm so sorry @amaximov
    with all these holidays I somehow forgot about your email and only dug it up today, while getting through of all the emails piled up

    So I've tried your project, and you need to update the AndroidManifest file, basicallyu changing
    <receiver android:process=":remote" android:name="com.giderosmobile.android.plugins.notification.NotificationClass"></receiver>
    to
    <receiver android:name="com.giderosmobile.android.plugins.notification.NotificationClass"></receiver>
    And it works as expected
  • Also sorry for the delayed response, my push server is production ready so I'll be trying out the Android plugin next week. Currently I'm working on the iOS plugin and I was wondering, is there a way for the Gideros Notification plugin to retrieve "custom" data from notification similar to Corona?

    The APS format is :

    (
    [aps] => Array
    (
    [alert] => Push notification text here

    [badge] => 1
    [sound] => default
    )
    [custom] => Array
    (
    [otherstuff] => somedata
    )
    )

    In Corona for example, the custom key in the notification can be processed via the "custom" key in the "notification" event table. Is there something similar in the Gideros Plugin?
  • Honestly I don't remember if it is supported, but it is possible to add such support.
    In exactly the same structure you described.
    But only you need to note that there is a size limitation (can't remember exact number).

    I just need to remember how similar thing could be done on Android and implement support for custom data to both, if it is not done yet ;)
  • I haven't used pushed notification with native development but I know that with GCM the body is json to which you can add any key value pairs, Perhaps the plugin could provide an option for checking if the notification data has a custom key and adding that as an "event.custom" data. Something similar can be done with iOS with the plugin checking for a "custom" field in the structure I showed in my previous post.
  • oh yes there is no problem with android, just will come up with identical interface (something along the lines you suggested ;) )
  • Updated Notification plugin:
    version 1.3
    Fixed number passed as 0 in some cases
    Added custom data (setCustom/getCustom) methods for local notifications
    Added custom data to push notifications
    Added PHP push server example
  • @ar2rsawseen A quick question: how can I check/handle if the app was opened by clicking on a notification for the app?
    (sorry for the double post; the one in Gideros Labs can be removed)
  • @Venorcis currently there is no difference between opening app with the click on notification or receiving notification while app is running. In both cases there should be an event about new either local or push notification

    should there be a difference? :)
  • @ar2rsawseen A parameter indicating if it was in-app or outside would be useful!
    Can you give my any indication of how to call an Android 'keyboard-close' from lua?
  • I just looked over the code and it seems there is only one native event for IOS, so I don't know if it is possible to determine difference between them

    But could you elaborate on the use case for this, as maybe I can come up with alternative solutions, as for example:
    local mngr = NotificationManager.getSharedInstance()
    mngr:addEventListener(Event.PUSH_NOTIFICATION, function(e)
    	--if less then 100 miliseconds
    	if os.timer() - startTime < 100 then
    		print("Notification opened app")
    	end
    end)
    startTime = os.timer()
  • @ar2rsawseen We need this for e.g. the following difference:
    - notification of new incoming message within the app: vibrate the phone, and show a dialog with read/dismiss
    - clicking on a notification of a new message outside of the app: open the app and go to the relevant message inmediately.
    I will try out your proposed solution with the timer; is the PUSH_NOTIFICATION event reliably called that early when opening the app through a notification?
  • amaximovamaximov Member
    edited January 2014
    @ar2rsawseen I'm not sure if I am doing anything wrong, but for the life of me I cannot seem to get a Event.PUSH_NOTIFICATION event to fire. I have tried sending notifications to my device with app in background or foreground and the event simply does not fire. I can see the notification arrive in the notification bar but it doesn't propagate through to the Gideros Lua side...
  • @Venorcis I see, let me check if there is anything more on IOS side I could do
    @amaximov which OS exactly are you talking about? Or both?
    Did it happen after you upgraded Notification plugin?
    Are you sending custom data?
    Are you using the provided server side script?
  • Talking about iOS and using Parse as provider without custom data. I honestly didnt test previous version of notification plugin so I cant remember if Event.PUSH_NOTIFICATION worked or not...
  • ar2rsawseenar2rsawseen Maintainer
    edited January 2014
    and local ones work?
    if not then maybe you did not set AppDelegate event handlers in AppDelegate.m file
  • Did not test local notification, the problem was with remote notifications. I did modify the AppDelegate.mm so not sure what the issue is because I do get APS registration token from the Event.REGISTRATION (off of memory)
  • @ar2rsawseen thanks for the notification plug-in. I've been incorporating it into my project and have a few questions. First, you're version 1.3 hosted at http://giderosmobile.com/labs/notification is different/ahead from your GitHub hosted version. Would it be possible for you to keep GitHub up to date - it's confusing to have them out of sync and I'd like to send you a pull request.

    Speaking of pull-requests, I've got some fixes I wanted to send you. Until GitHub is up to date I've attached my changes.
    - Support for loc-key and loc-key-args
    - Support for launched flag to determine if app was launched/resumed via push notification.
    - Fixed crashes with nil body/title

    Thanks again - very helpful.
    zip
    zip
    Notification.zip
    461K
  • @troysandal wow thanks will definitely take a look
    You are completely right, I need to update github also, I just seem to forgot all the time.
    I have my own internal repo for daily commits, then I have Gideros repo for working builds, then I have Gideros Labs for tested builds, 4th repo is probably a little too much and thats why I always forget about it :)
  • troysandaltroysandal Member
    edited February 2014
    Forgot to mention, my changes were only to iOS, not the Android side. Someone with Android experience will need to tackle that :)

    One thing you can't differentiate between is whether the application was launched or resumed, it's not important to me but might be to others. Easy to fix that if we switch 'launched' from a boolean to integers 0 for NO, 1 for LAUNCHED, 2 for RESUMED. We could then add a boolean property 'clicked' to indicate if the user click the notification or not, in which case launched is present. OR we could keep the launched flag as is and not put events into the "NotificationLocalEvent" repo so Event.PUSH_NOTIFICATION and Event.LOCAL_NOTIFICATION only fire for those received while running. Thoughts?

    Also, I was wondering why notification ids have to be integers, is that an inherent limit from Android or a personal choice? I find strings to be much more robust ids as well as human readable form. I'm using custom to store my names but having id be a string would be useful.

    Speaking of ids, I noticed that for remote iOS messages you store the id inside the aps payload which goes against Apple's suggestion of storing custom values outsdie the aps payload. There's no guarantee those fields will be preserved, was this intentional?

    I'm new to push notifs so forgive me if these are newb questions.
  • I don't really see much of a difference if app was resumed or launched, but if someone thinks there should be, give us a shout :)

    Yes Ids as integer are limitation from Android (and as you have seen in code, struggling a lot on converting it to object on ios par), same reason why loc-key was not separately implemented.

    I actually don't remember about Ids storage in the push notification structure, so will have to recheck that ;)
  • Attached is a new version that deals with a crash with malformed/non-string custom fields in push notifications and that uses a safer method for converting the device token into a string.

    Cheers!
    zip
    zip
    Notification.zip
    461K
  • @ar2rsawseen This week we've again received multiple reports that push notifications don't do anything if the app is not already running in the background yet. We've also had some reports that (probably when the app is running in the background) opening a push notifications makes the app 'hang' on a black screen (but only rarely). We've already added a time-out to the push notification event of 2 seconds before doing anything with it, because I've noticed that sometimes as well, but unfortunately we keep having multiple problems on Android, and I hope they can be fixed!
  • VenorcisVenorcis Member
    edited February 2014
    @ar2rsawseen I've also confirmed on iOS that if the application is not running yet, the push notification event will not be fired when clicking on a push-notification. So this is identical between iOS and Android. @troysandal might have fixed this for iOS already? And again, the flag to check if it was really 'within-app' or because of a 'click on the notification from a menu' would really help; the timer-stuff you proposed does not work (os.timer is in second instead of milliseconds anyway, and when the app is in the background iOS usually saves all the values anyway).

    Edit: is it possible that the events are fired before the eventlistener can even be registered?
  • @Venorcis they should not be, as they are waiting for GAPPLICATION_START_EVENT to be executed and queued until then, but there may be bugs to queue, or in Gideros changing GAPPLICATION_START_EVENT behavior, so will check out today ;)
  • I've been playing a lot with android, but could not reproduce the issue when app does not get a notification when opening app from notification

    I've tried both with local and push notifications
    With Gideros Player, with app launched in eclipse and with exported/signed app
    I tried with Gideros splash screen and without it
    I tried app in the background, app killed when receiving, app killed after receiving, completely turning off/restarting device, etc
    Basically did quite a thorough testing and it always opens with the event.

    So there is a chance that your project is not set up correctly (either you have missed something or I forgot to mention something :) )

    For example, are all receivers correctly included (with your app package name instead of "com.yourdomain.yourapp"):
    <receiver android:name="com.giderosmobile.android.plugins.notification.NotificationClass"></receiver>
     
    <receiver android:name="com.giderosmobile.android.plugins.notification.NotificationRestore" >
    <intent-filter>
    <action android:name="android.intent.action.BOOT_COMPLETED" />
    </intent-filter>
    </receiver>
     
    <receiver android:name="com.giderosmobile.android.plugins.notification.GCMReceiver" android:permission="com.google.android.c2dm.permission.SEND" >
    <intent-filter>
    <action android:name="com.google.android.c2dm.intent.RECEIVE" />
    <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
    <category android:name="com.yourdomain.yourapp" />
    </intent-filter>
    </receiver>
    <service android:name="com.giderosmobile.android.plugins.notification.GCMIntentService" />
    Or did you add onNewIntent in your main activity?
    <a href="https://forum.giderosmobile.com/profile/Override" rel="nofollow">@Override</a>
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        setIntent(intent);
    }
    If all of the above seems correct, then maybe you can send me your android project, so I can compare with mine.

    I've also implemented didOpen property for Android and now looking at @troysandal additions for IOS, but I would like to resolve the issue you have and if it is a bug then fix it, before releasing a new version of Notification plugin ;)
Sign In or Register to comment.