tag:robotlegs.tenderapp.com,2009-10-18:/discussions/robotlegs-2/10738-push-notifications-handling-in-a-mobile-appRobotlegs: Discussion 2014-04-22T13:23:43Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/326289062014-04-22T09:01:23Z2014-04-22T09:01:23ZPush Notifications handling in a mobile app<div><p>Hi Valley,</p>
<p>Sorry for the late response due to Easter holydays...</p>
<p>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:</p>
<pre>
<code>var remoteNotifier:RemoteNotifier = new RemoteNotifier();
injector.map(RemoteNotifier).toValue(remoteNotifier);
var notifierService:NotifierService = injector.getOrCreateNewInstance(NotifierService);
//in case you need to inject it somewhere:
injector.map(NotifierService).toValue(notifierService);</code>
</pre>
<p>NotifierService would be injected with the RemoteNotifier and
with an IEventDispatcher (the shared event dispatcher).</p>
<p>Once initialized in the config, the NotifierService would be
persistent.</p>
<p>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...<br>
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.</p>
<p>So, your PushNotificationsHandler would be the NotifierService
from my example.</p>
<p>Hope this helps.</p>
<p>Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/326289062014-04-22T11:41:26Z2014-04-22T11:41:26ZPush Notifications handling in a mobile app<div><p>Hello Ondina,</p>
<p>yes that helps, thank you very much.<br>
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).<br>
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.<br>
There it can be decided how to react to that notification.</p>
<p>Best regards<br>
valley</p></div>rivella50tag:robotlegs.tenderapp.com,2009-10-18:Comment/326289062014-04-22T13:23:42Z2014-04-22T13:23:42ZPush Notifications handling in a mobile app<div><p>You're welcome, Valley :)</p></div>Ondina D.F.