Cross-App Launch
From WebOS101
If your app needs to use the services of another app, you could launch that app, but that may not be appropriate in all cases. If you need to go to a specific scene, it may be easier and quicker to use the Cross-App Launch technique. This uses the pushScene API, and is less resource intensive (no new card is created). Furthermore, it keeps all the action in the context of your application -- when the user swipes back, or you pop the scene, they're back in the calling app.
Setting It Up
In the calling app:
this.controller.stageController.pushScene(
{ appId :'com.other.app.id',
name: 'name-of-scene-in-called-app-to-push' },
{ your: 'arbitrary', jsonObject: 'payload', goes: 'here' }
);
In the called app's scene assistant:
function MySceneAssistant(argFromPusher) {
if (argFromPusher) {
Mojo.Log.info("argFromPusher: %j", argFromPusher);
if (argFromPusher.jsonObject === 'payload') {
// Do stuff with argFromPusher
// Remember, it will supplant the args you normally get...
}
}
}
In the called app, when you're done doing your stuff, pop the scene:
this.controller.stageController.popScene(
{ your: 'arbitrary', jsonObject: 'payload', goes: 'here' }
);
If the user swipes back, you won't be able to pass a payload...
Finally, in the calling app again:
CallerAssistant.prototype.activate = function(event) {
if (event != undefined) {
Mojo.Log.info("event=%j", event);
// The 'event' param will be your payload object
this.whatever = event.your + event.jsonObject;
}
};
Also, the called app will need to be a multi-stage app (or at least look like one):
In appinfo.json:
{
...
"noWindow" : "true",
...
}
And you'll need an app-assistant.js that looks something like this.