feat(platform): cordova pause/resume events

This commit is contained in:
Adam Bradley
2016-04-21 22:03:30 -05:00
parent fae16faede
commit 532096b7ab
2 changed files with 24 additions and 10 deletions

View File

@ -290,7 +290,9 @@ export class Platform {
// called by engines (the browser)that do not provide them
/**
* @private
* The `exitApp` method is useful when running from a native platform,
* such as Cordova. This adds the ability to place the Cordova app
* in the background.
*/
exitApp() {}
@ -298,17 +300,29 @@ export class Platform {
// **********************************************
/**
* @private
* The back button event is emitted when the user presses the native
* platform's back button, also referred to as the "hardware" back button.
* This event is only emitted within Cordova apps running on Android and
* Windows platforms. This event is not fired on iOS since iOS doesn't come
* with a hardware back button in the same sense an Android or Windows device
* does. It's important to note that this event does not emit when the Ionic
* app's back button within the navbar is clicked, but this event is only
* referencing the platform's hardward back button.
*/
backButton: EventEmitter<any> = new EventEmitter();
/**
* @private
* The pause event emits when the native platform puts the application
* into the background, typically when the user switches to a different
* application. This event would emit when a Cordova app is put into
* the background, however, it would not fire on a standard web browser.
*/
pause: EventEmitter<any> = new EventEmitter();
/**
* @private
* The resume event emits when the native platform pulls the application
* out from the background. This event would emit when a Cordova app comes
* out from the background, however, it would not fire on a standard web browser.
*/
resume: EventEmitter<any> = new EventEmitter();

View File

@ -179,12 +179,12 @@ Platform.register({
doc.addEventListener('backbutton', function() {
p.backButton.emit(null);
});
// doc.addEventListener('pause', function() {
// p.pause.emit(null);
// });
// doc.addEventListener('resume', function() {
// p.resume.emit(null);
// });
doc.addEventListener('pause', function() {
p.pause.emit(null);
});
doc.addEventListener('resume', function() {
p.resume.emit(null);
});
// cordova has fully loaded and we've added listeners
p.triggerReady();