diff --git a/config.xml b/config.xml
index 5fa06d260..e6e17803f 100644
--- a/config.xml
+++ b/config.xml
@@ -104,7 +104,7 @@
-
+
diff --git a/src/providers/utils/utils.ts b/src/providers/utils/utils.ts
index 36ff520d6..20122e7a8 100644
--- a/src/providers/utils/utils.ts
+++ b/src/providers/utils/utils.ts
@@ -756,17 +756,41 @@ export class CoreUtilsProvider {
this.iabInstance = this.iab.create(url, '_blank', options);
if (this.appProvider.isDesktop() || this.appProvider.isMobile()) {
+ let loadStopSubscription;
+ const loadStartUrls = [];
+
// Trigger global events when a url is loaded or the window is closed. This is to make it work like in Ionic 1.
const loadStartSubscription = this.iabInstance.on('loadstart').subscribe((event) => {
// Execute the callback in the Angular zone, so change detection doesn't stop working.
this.zone.run(() => {
+ // Store the last loaded URLs (max 10).
+ loadStartUrls.push(event.url);
+ if (loadStartUrls.length > 10) {
+ loadStartUrls.shift();
+ }
+
this.eventsProvider.trigger(CoreEventsProvider.IAB_LOAD_START, event);
});
});
+
+ if (this.platform.is('android')) {
+ // Load stop is needed with InAppBrowser v3. Custom URL schemes no longer trigger load start, simulate it.
+ loadStopSubscription = this.iabInstance.on('loadstop').subscribe((event) => {
+ // Execute the callback in the Angular zone, so change detection doesn't stop working.
+ this.zone.run(() => {
+ if (loadStartUrls.indexOf(event.url) == -1) {
+ // The URL was stopped but not started, probably a custom URL scheme.
+ this.eventsProvider.trigger(CoreEventsProvider.IAB_LOAD_START, event);
+ }
+ });
+ });
+ }
+
const exitSubscription = this.iabInstance.on('exit').subscribe((event) => {
// Execute the callback in the Angular zone, so change detection doesn't stop working.
this.zone.run(() => {
loadStartSubscription.unsubscribe();
+ loadStopSubscription && loadStopSubscription.unsubscribe();
exitSubscription.unsubscribe();
this.eventsProvider.trigger(CoreEventsProvider.IAB_EXIT, event);
});