MOBILE-2431 sso: Make SSO work in Inappbrowser v3
parent
bfd4dd8ac7
commit
28e3313a7c
|
@ -104,7 +104,7 @@
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin name="cordova-plugin-device" spec="1.1.6" />
|
<plugin name="cordova-plugin-device" spec="1.1.6" />
|
||||||
<plugin name="cordova-plugin-globalization" spec="1.0.7" />
|
<plugin name="cordova-plugin-globalization" spec="1.0.7" />
|
||||||
<plugin name="cordova-plugin-inappbrowser" spec="1.7.1" />
|
<plugin name="cordova-plugin-inappbrowser" spec="^3.0.0" />
|
||||||
<plugin name="cordova-plugin-network-information" spec="1.3.3" />
|
<plugin name="cordova-plugin-network-information" spec="1.3.3" />
|
||||||
<plugin name="cordova-plugin-statusbar" spec="2.2.3" />
|
<plugin name="cordova-plugin-statusbar" spec="2.2.3" />
|
||||||
<plugin name="cordova-plugin-whitelist" spec="1.3.2" />
|
<plugin name="cordova-plugin-whitelist" spec="1.3.2" />
|
||||||
|
|
|
@ -756,17 +756,41 @@ export class CoreUtilsProvider {
|
||||||
this.iabInstance = this.iab.create(url, '_blank', options);
|
this.iabInstance = this.iab.create(url, '_blank', options);
|
||||||
|
|
||||||
if (this.appProvider.isDesktop() || this.appProvider.isMobile()) {
|
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.
|
// 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) => {
|
const loadStartSubscription = this.iabInstance.on('loadstart').subscribe((event) => {
|
||||||
// Execute the callback in the Angular zone, so change detection doesn't stop working.
|
// Execute the callback in the Angular zone, so change detection doesn't stop working.
|
||||||
this.zone.run(() => {
|
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);
|
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) => {
|
const exitSubscription = this.iabInstance.on('exit').subscribe((event) => {
|
||||||
// Execute the callback in the Angular zone, so change detection doesn't stop working.
|
// Execute the callback in the Angular zone, so change detection doesn't stop working.
|
||||||
this.zone.run(() => {
|
this.zone.run(() => {
|
||||||
loadStartSubscription.unsubscribe();
|
loadStartSubscription.unsubscribe();
|
||||||
|
loadStopSubscription && loadStopSubscription.unsubscribe();
|
||||||
exitSubscription.unsubscribe();
|
exitSubscription.unsubscribe();
|
||||||
this.eventsProvider.trigger(CoreEventsProvider.IAB_EXIT, event);
|
this.eventsProvider.trigger(CoreEventsProvider.IAB_EXIT, event);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue