Files

38 lines
1.0 KiB
TypeScript

import {App, IonicApp, IonicPlatform, ActionSheet} from 'ionic/ionic';
import {IonicView, IonicConfig, Events} from 'ionic/ionic';
import {ActionSheetPage} from 'actionSheet/actionSheet';
import * as helpers from 'helpers';
@App({
template: '<ion-nav id="nav" [root]="rootPage"></ion-nav>'
})
class DemoApp {
rootPage: any;
constructor(app: IonicApp, platform: IonicPlatform) {
this.app = app;
this.platform = platform;
this.platform.ready().then( () => {
window.addEventListener('message', (e) => {
zone.run(() => {
if (e.data) {
var data = JSON.parse(e.data);
if (data.hash) {
this.nextPage = helpers.getPageFor(data.hash.replace('#', ''));
} else {
this.nextPage = ActionSheetPage;
}
let nav = this.app.getComponent('nav');
nav.setRoot(this.nextPage);
}
});
});
window.parent.postMessage(this.platform.is('ios')? "ios":"android", "*");
});
}
}