Skip to content

Commit

Permalink
feat(platform): cordova pause/resume events
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley committed Apr 22, 2016
1 parent fae16fa commit 532096b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
22 changes: 18 additions & 4 deletions ionic/platform/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,25 +290,39 @@ 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() {}

// Events meant to be triggered by the engine
// **********************************************

/**
* @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();

Expand Down
12 changes: 6 additions & 6 deletions ionic/platform/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 532096b

Please sign in to comment.