Push Notifications handling in a mobile app
Hi there,
i am writing a mobile app using Robotlegs 2 and am about to
integrate Push Notifications support with an ANE.
The init and register part will be handled by a startup service,
but i'm wondering what would be the best approach to handle
the notification part (3 use cases: the app is running, running in
the background and not running).
My best guess so far is a singleton class
(PushNotificationsHandler), which listens for the push notification
events and is mapped to a separate Mediator, where the listener
class invokes the Mediator by dispatching a signal. The listener
class is enabled by the service.
Then the Mediator can
a) invoke a screen change or
b) invoke a command
for handling the received events.
What do you think, is this a good approach or is there a
better/easier one ?
Thank you for your inputs.
Regards
valley
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Ondina D.F. on 22 Apr, 2014 09:01 AM
Hi Valley,
Sorry for the late response due to Easter holydays...
I would wrap RemoteNotifier with a service class, say NotifierService, which would handle the configuration, subscribe, unsubscribe and the notification processes. I would let the injector instantiate the NotifierService in a config class, like this:
NotifierService would be injected with the RemoteNotifier and with an IEventDispatcher (the shared event dispatcher).
Once initialized in the config, the NotifierService would be persistent.
NotifierService can dispatch a custom event on the shared event dispatcher, when a notification is received. You can register listeners for the custom event wherever you need, Mediators, Commands...
You could also inject the service into a command, in case you wanted to subscribe/unsubscribe to/from the push notifications in response to user's interactions.
So, your PushNotificationsHandler would be the NotifierService from my example.
Hope this helps.
Ondina
2 Posted by rivella50 on 22 Apr, 2014 11:41 AM
Hello Ondina,
yes that helps, thank you very much.
Since i got a similar answer from the publishers of the push notifications ANE i have implemented all notifications aspects in one service class which is mapped as a singleton in the injector (therefore persistent).
When a notification event arrives the JSON data is parsed and inserted into an injected model. Finally the service dispatches a signal where the "super" mediator (is always alive since performing the screen changes) is listening for these signal events.
There it can be decided how to react to that notification.
Best regards
valley
Support Staff 3 Posted by Ondina D.F. on 22 Apr, 2014 01:23 PM
You're welcome, Valley :)
Ondina D.F. closed this discussion on 22 Apr, 2014 01:23 PM.