I have an app made in Cordova using Ember framework.
When I receive a system notification I want to open a custom location based on id that notification send me. Notification call a method out of Ember route/controller system.
How I can call a ember router to load a custom location based on notification id if the method are not inside Ember managed code?
Regards.
You can check Ember.Instrumentation module which can be used for such scenarios.
http://emberjs.com/api/classes/Ember.Instrumentation.html
To send an event from outside Ember:
Ember.Instrumentation.instrument("eventGroup.notificationOccured", {id: 'id_which_you_got_from_notification'});
To subscribe the event inside Ember code:
Ember.Instrumentation.subscribe("eventGroup.notificationOccured", {
before: function(id, timestamp, payload) {
// Here you can do routing
},
after: function() {}
});
The subscribe
can be inside Ember App codebase where you can transitionTo
the route depending on the id.
You can probably put the subscribe code snippet in your IndexRoute's setupController
or inside any controller method which would have already executed whenever notification arrives.
In case you want to put the code in controller then redirection can happen via controller.transitionToRoute(routeName);
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments