Skip to content

Commit 532096b

Browse files
committedApr 22, 2016
feat(platform): cordova pause/resume events
1 parent fae16fa commit 532096b

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed
 

‎ionic/platform/platform.ts

+18-4
Original file line numberDiff line numberDiff line change
@@ -290,25 +290,39 @@ export class Platform {
290290
// called by engines (the browser)that do not provide them
291291

292292
/**
293-
* @private
293+
* The `exitApp` method is useful when running from a native platform,
294+
* such as Cordova. This adds the ability to place the Cordova app
295+
* in the background.
294296
*/
295297
exitApp() {}
296298

297299
// Events meant to be triggered by the engine
298300
// **********************************************
299301

300302
/**
301-
* @private
303+
* The back button event is emitted when the user presses the native
304+
* platform's back button, also referred to as the "hardware" back button.
305+
* This event is only emitted within Cordova apps running on Android and
306+
* Windows platforms. This event is not fired on iOS since iOS doesn't come
307+
* with a hardware back button in the same sense an Android or Windows device
308+
* does. It's important to note that this event does not emit when the Ionic
309+
* app's back button within the navbar is clicked, but this event is only
310+
* referencing the platform's hardward back button.
302311
*/
303312
backButton: EventEmitter<any> = new EventEmitter();
304313

305314
/**
306-
* @private
315+
* The pause event emits when the native platform puts the application
316+
* into the background, typically when the user switches to a different
317+
* application. This event would emit when a Cordova app is put into
318+
* the background, however, it would not fire on a standard web browser.
307319
*/
308320
pause: EventEmitter<any> = new EventEmitter();
309321

310322
/**
311-
* @private
323+
* The resume event emits when the native platform pulls the application
324+
* out from the background. This event would emit when a Cordova app comes
325+
* out from the background, however, it would not fire on a standard web browser.
312326
*/
313327
resume: EventEmitter<any> = new EventEmitter();
314328

‎ionic/platform/registry.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,12 @@ Platform.register({
179179
doc.addEventListener('backbutton', function() {
180180
p.backButton.emit(null);
181181
});
182-
// doc.addEventListener('pause', function() {
183-
// p.pause.emit(null);
184-
// });
185-
// doc.addEventListener('resume', function() {
186-
// p.resume.emit(null);
187-
// });
182+
doc.addEventListener('pause', function() {
183+
p.pause.emit(null);
184+
});
185+
doc.addEventListener('resume', function() {
186+
p.resume.emit(null);
187+
});
188188

189189
// cordova has fully loaded and we've added listeners
190190
p.triggerReady();

0 commit comments

Comments
 (0)
Please sign in to comment.