Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Local Notifications in Android — Gideros Forum

Local Notifications in Android

moopfmoopf Guru
edited March 2013 in General questions
Hi,

I've come across a plugin for Gideros for iOS notifications here: http://www.giderosmobile.com/forum/discussion/1103/uinotifications-plugin-local-notifications-for-iphone#Item_3

Does anybody have something similar for Android available, specifically setting up a local notification and cancelling them again.

Cheers,

Gareth

Comments

  • Nobody got anything?
  • ar2rsawseenar2rsawseen Maintainer
    Maybe your grumpiness scares everyone's away? :D
    If you really really really need it, I can try experiment something out, single purpose use, etc. But describe what you need more.
    Will toast notification work?
    Should notifications appear even if you are not inside the app?
    Etc.
  • It's OK, I think it's time for me to learn Java as well. Even when I offered money on here for another Android plugin, nobody wanted the work, and it's something I'm going to need more and more of to match features across platforms. iOS is well covered with plugins here, Android not so much.
  • talistalis Guru
    edited March 2013
    hi @moopf when you will come up with a solution, if it is not confidential information of course, we will be more than happy to have this plugin and experiment with it.

    Once, we wrote some android application which was using AlarmManager class. With it you can simply run any intent (activity). You can use this class for one time or for repetitive jobs. Also you can make an Android service with it. Unfortunately we didn't experiment it so much with it.

    If you have any Android based questions and it is within my knowledbase i will be glad to help :-B
  • ar2rsawseenar2rsawseen Maintainer
    Although I think you are right with your decision @moopf, local notifications probably is not something you want to start with :)

    I'll still have an attempt at this and if done right (multi purpose, same API for both platforms, etc) maybe it will be included Gideros :)

    And @talis I hope your offer extends to me too, cause I bet I'll might need some help :D
  • talistalis Guru
    edited March 2013
    of course @ar2rsawseen hit me with questions, i am ready :D

    med3d-chevalier.gif
    77 x 77 - 45K
  • ar2rsawseenar2rsawseen Maintainer
    edited March 2013
    Hello all,
    actually the plugin comes great, better then I anticipated, and now it's time to decide on API design

    So which style would you feel more comfortable with?
    Multiple instance Gideros style:
    local notificationID = 1
    local notification = Notification.new(notificationID)
    notification:setTitle("SomeTitle")
    notification:setContent("SomeContent")
    notification:dispatchAfter({seconds = 10})
    notification:addEventListener(Event.NOTIFICATION, ...)
    notification:cancel()
    Or more a singleton style as rest of the plugins:
    local notificationID = 1
    notification:add(notificationID, "Some Title", "SomeContent") 
    notification:dispatch(notificationID, {seconds = 10}) 
    notification:addEventListener(Event.NOTIFICATION, ...)
    notification:cancel(notificationID)
    Please vote folks :D

    Likes: hgvyas123

    +1 -1 (+1 / -0 )Share on Facebook
  • @ar2rsawseen for me both of the styles are good. However i prefer first style for more object oriented approach similar with Gideros classes.

    With your plugin, can we listen to local notification event and react on it even when the game has closed? I mean, could we know which notification opening up the game if we setup more than one notification? Will the behavior similar on Android and iOS?
    have fun with our games~
    http://www.nightspade.com
  • ar2rsawseenar2rsawseen Maintainer
    Yes, my goal is to make plugin the same on both platforms.

    And all notifications would be managed through ids (which would be integers) and you could safe them using persistent storages and modify notifications using these ids later on.

    And I also have the event in mind which would receive the notification ID which brought application to front, but I do not know about closed applications right now, because then event will probably be dispatched before you could register to it, so will have to think of some kind of delay and discuss it more with @atilim, so I can't say if it would be possible for closed apps right now.
  • NascodeNascode Guru
    edited March 2013
    @ar2rsawseen there was discussion in this forum about passing argument when app started. And i talked about possibility using it on notifications (local or push). Maybe this old thread could help http://www.giderosmobile.com/forum/discussion/comment/16222

    One scenario i can think off is to setup local or push notification with certain string. So when notification happens, we could read the string/id, then player could buy item in discounted price.
    have fun with our games~
    http://www.nightspade.com
  • ar2rsawseenar2rsawseen Maintainer
    edited March 2013
    @Nascode thanks it will definitely come in handy, when I start on IOS part, I'm total noob there :D
  • second one However as long as we get plugin for notification i am more than happy

    :D
  • ar2rsawseenar2rsawseen Maintainer
    Ok then, you won't get plugin, because I won't make one, until you guys decide on the API >:) :))
  • moopfmoopf Guru
    edited March 2013
    Hi @ar2rsawseen, sorry I didn't reply yesterday (wasn't around). This is great news. I prefer the first one for the same reasons as @Nascode

    Couple of questions just to make sure this is the same thing I need:

    1. This will be suitable for setting up notifications that would trigger even if the app is closed?
    2. Will you be providing a facility to cancel all notifications setup? Or even just an individual one if we're tracking the IDs. And will this work between app loads.

    You see what I'll be wanting to do is setup notifications when the app closes and cancel and that haven't run when the app re-opens. Think Tiny Tower kind of thing, where you get notifications when you're out of the app about things that have happened.

    But this is great, many thanks for running with it :)
  • @ar2sawseen i like the first approach. (Multiple instance Gideros style). I said before let me repeat, please let me know if i can help in any way :D
    (Resarch, code, etc ....)
  • Ok then, you won't get plugin, because I won't make one, until you guys decide on the API >:) :))
    ohhh no i change first approach is good one see no fighting

    :D
  • atilimatilim Maintainer
    @hgvyas123 don't change your mind. I prefer second one also :)
  • in that case we can never decide and we wont get plugin :(

    and on top of that our own @moopf is on opposite party any ways second one final :ar!

    :)
  • I'm not actually bothered. Whilst my personal preference would be for the first style, I'm really not bothered if it's style 2. I'll work with it whichever way.

    Likes: hgvyas123

    +1 -1 (+1 / -0 )Share on Facebook
  • hgvyas123hgvyas123 Guru
    edited March 2013
    yeah i knows that O:-) but still... :ar!

    :)
  • ar2rsawseenar2rsawseen Maintainer
    Accepted Answer
    @moopf
    1) yes they will work even if app is closed, only problem right now that Android seem to cancel them after device reboot, but I already found an approach to fix that and am working on it
    2) yes cancelling all events method will also be implemented as well as scheduling them on specific time or after specific time and with specific repeating.

    Likes: moopf

    +1 -1 (+1 / -0 )Share on Facebook
  • Hi all,

    Sorry for kicking up the dust on an old post..... but i read this, which referenced another post on notifications.

    its like there was to be be a plug in created ?

    or is this the code you put into your code:
    local notificationID = 1
    local notification = Notification.new(notificationID)
    notification:setTitle("SomeTitle")
    notification:setContent("SomeContent")
    notification:dispatchAfter({seconds = 10})
    notification:addEventListener(Event.NOTIFICATION, ...)
    notification:cancel()
Sign In or Register to comment.