danielsogl / awesome-cordova-plugins

Native features for mobile apps built with Cordova/PhoneGap and open web technologies. Complete with TypeScript support.
https://danielsogl.gitbook.io/awesome-cordova-plugins/
Other
2.41k stars 2.43k forks source link

beforeload event not triggered after calling _loadafterbeforeload #4237

Closed sebastiansinsin closed 2 years ago

sebastiansinsin commented 2 years ago

I'm submitting a ... (check one with "x") [X ] bug report [ ] feature request [ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or https://ionicworldwide.herokuapp.com/

Current behavior:

so the beforeload event will be called on first time, second time, fourth time, and so on. inside the beforeload event subscription, I called _loadAfterBeforeLoad to proceed calling the url that was intercept. ps: I log the beforeload event, loadstart event, and loadstop event. Currently, I'm debugging it on android emulator.

Expected behavior:

It should called the beforeload every time the url / page is called.

Steps to reproduce:

create the inAppBrowser Instance and open it. eg url : https://github.com/danielsogl/awesome-cordova-plugins you see on the console.log, the beforeload event was fired. then you can click on some navigation, eg Issues you see on the console.log the beforeload event was not fired, only loadstart event.

Related code:

navigateToInApp(url, video: boolean = false, closeBrowser: boolean = false, showLoc: boolean = true) {
const opts = optStr + ',clearcache=yes,beforeload=yes,hidespinner=no,hideurlbar=yes,toolbarcolor=#1d1d1b,hidenavigationbuttons=true,hardwareback=yes,closebuttoncaption=X,closebuttoncolor=#ffffff';
        let browser = this.inAppBrowser.create(url, '_blank', opts);
        browser.on('beforeload').subscribe(
            (event) => {
                console.log('beforeload event', event);
                if (url.includes('__store=id_ID') || url.includes('__store=en_US')) {
                    let modifiedUrl = localStorage.getItem('preferred_language') === 'id_ID' ? '?___store=id_ID' : '?___store=en_US';
                    console.log(event.url, modifiedUrl)
                    url = `${event.url}${modifiedUrl}`;
                    browser._loadAfterBeforeload(`${event.url}${modifiedUrl}`);
                }
            }
        );

        browser.on('loadstart').subscribe(event => {
            let url = event.url;
            console.log('loadstart', url)

        });
}

Other information:

Relevant Issues : https://github.com/apache/cordova-plugin-inappbrowser/issues/911 https://github.com/apache/cordova-plugin-inappbrowser/issues/571 Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):

Ionic:

   Ionic CLI                     : 6.16.3 (C:\Users\sebas\AppData\Roaming\npm\node_modules\@ionic\cli)
   Ionic Framework               : @ionic/angular 5.8.4
   @angular-devkit/build-angular : 0.803.29
   @angular-devkit/schematics    : 8.3.29
   @angular/cli                  : 8.3.29
   @ionic/angular-toolkit        : 2.3.3

Cordova:

   Cordova CLI       : 10.0.0 (cordova-lib@10.1.0)
   Cordova Platforms : not available
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.1.3, (and 34 other plugins)

Utility:

   cordova-res (update available: 0.15.4) : 0.15.3
   native-run (update available: 1.6.0)   : 1.4.0

System:

   Android SDK Tools : 26.1.1 (C:\Users\sebas\AppData\Local\Android\Sdk)
   NodeJS            : v14.17.4 (C:\Program Files\nodejs\node.exe)
   npm               : 6.14.15
   OS                : Windows 10

Package.json

{
  "name": "myApp",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "https://ionicframework.com/",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^8.2.14",
    "@angular/cdk": "^8.2.3",
    "@angular/common": "~8.2.14",
    "@angular/core": "~8.2.14",
    "@angular/forms": "~8.2.14",
    "@angular/http": "^7.2.16",
    "@angular/material": "^8.2.3",
    "@angular/material-moment-adapter": "^8.2.3",
    "@angular/platform-browser": "~8.2.14",
    "@angular/platform-browser-dynamic": "~8.2.14",
    "@angular/router": "~8.2.14",
    "@awesome-cordova-plugins/core": "^5.43.0",
    "@awesome-cordova-plugins/in-app-browser": "^5.43.0",
    "@comapi/sdk-js-foundation": "^1.1.6",
    "@ionic-native/app-rate": "^5.23.0",
    "@ionic-native/appsflyer": "^5.33.1",
    "@ionic-native/badge": "^5.23.0",
    "@ionic-native/call-number": "^5.28.0",
    "@ionic-native/clipboard": "^5.23.0",
    "@ionic-native/core": "^5.33.1",
    "@ionic-native/deeplinks": "^5.36.0",
    "@ionic-native/facebook": "^5.33.1",
    "@ionic-native/fcm": "^5.36.0",
    "@ionic-native/firebase-analytics": "^5.34.0",
    "@ionic-native/firebase-config": "^5.33.1",
    "@ionic-native/google-analytics": "^5.36.0",
    "@ionic-native/google-maps": "^5.5.0",
    "@ionic-native/google-plus": "^5.36.0",
    "@ionic-native/http": "^5.23.0",
    "@ionic-native/in-app-browser": "^5.28.0",
    "@ionic-native/launch-navigator": "^5.24.0",
    "@ionic-native/market": "^5.36.0",
    "@ionic-native/mixpanel": "^5.31.1",
    "@ionic-native/network": "^5.23.0",
    "@ionic-native/sign-in-with-apple": "^5.36.0",
    "@ionic-native/smartlook": "^5.34.0",
    "@ionic-native/social-sharing": "^5.28.0",
    "@ionic-native/splash-screen": "^5.36.0",
    "@ionic-native/status-bar": "^5.0.0",
    "@ionic-super-tabs/angular": "^6.4.0",
    "@ionic/angular": "^5.0.0",
    "@ionic/lab": "^3.1.3",
    "@ionic/storage": "^2.2.0",
    "@ngx-translate/core": "^12.1.2",
    "@ngx-translate/http-loader": "^4.0.0",
    "call-number": "^1.0.1",
    "compare-versions": "^3.6.0",
    "cordova-android-play-services-gradle-release": "^4.0.0",
    "cordova-clipboard": "^1.3.0",
    "cordova-plugin-actionsheet": "^2.3.3",
    "cordova-plugin-advanced-http": "^2.4.1",
    "cordova-plugin-androidx": "^1.0.2",
    "cordova-plugin-androidx-adapter": "^1.1.0",
    "cordova-plugin-apprate": "^1.5.0",
    "cordova-plugin-dialogs": "^2.0.2",
    "cordova-plugin-facebook4": "^6.4.0",
    "cordova-plugin-file": "^6.0.2",
    "cordova-plugin-nativestorage": "^2.3.2",
    "cordova-plugin-network-information": "^2.0.2",
    "cordova-plugin-x-socialsharing": "^6.0.1",
    "cordova-support-android-plugin": "^1.0.2",
    "cordova-support-google-services": "^1.4.0",
    "core-js": "^2.5.4",
    "date-fns": "^2.28.0",
    "es6-promise-plugin": "^4.2.2",
    "hammerjs": "^2.0.8",
    "i": "^0.3.6",
    "ionic-plugin-deeplinks": "^1.0.20",
    "jsrsasign": "^10.4.0",
    "moment": "^2.25.3",
    "mx.ferreyra.callnumber": "0.0.2",
    "ngx-captcha": "^8.0.1",
    "ngx-ionic-image-viewer": "^0.7.0",
    "ngx-pretty-date": "^1.1.0",
    "npm": "^6.14.5",
    "prettydate": "0.0.1",
    "rxjs": "~6.5.1",
    "tslib": "^1.9.0",
    "uk.co.workingedge.phonegap.plugin.launchnavigator": "^5.0.4",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.803.20",
    "@angular/cli": "~8.3.23",
    "@angular/compiler": "~8.2.14",
    "@angular/compiler-cli": "~8.2.14",
    "@angular/language-service": "~8.2.14",
    "@ionic/angular-toolkit": "^2.1.1",
    "@types/jasmine": "~3.3.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "^5.0.0",
    "cordova-android": "^10.1.1",
    "cordova-ios": "^6.2.0",
    "cordova-plugin-appsflyer-sdk": "^6.3.0",
    "cordova-plugin-device": "^2.0.2",
    "cordova-plugin-facebook-connect": "^2.3.0",
    "cordova-plugin-fcm-with-dependecy-updated": "^7.8.0",
    "cordova-plugin-firebase-analytics": "^6.0.1",
    "cordova-plugin-firebase-config": "^6.0.0",
    "cordova-plugin-googlemaps": "^2.7.1",
    "cordova-plugin-googlemaps-sdk": "git+https://github.com/mapsplugin/cordova-plugin-googlemaps-sdk.git",
    "cordova-plugin-googleplus": "^8.5.2",
    "cordova-plugin-idfa": "^2.0.0",
    "cordova-plugin-inappbrowser": "git+https://github.com/apache/cordova-plugin-inappbrowser.git",
    "cordova-plugin-ionic-keyboard": "^2.2.0",
    "cordova-plugin-ionic-webview": "^4.2.1",
    "cordova-plugin-market": "^1.2.0",
    "cordova-plugin-mixpanel": "^4.7.1",
    "cordova-plugin-sign-in-with-apple": "^0.1.2",
    "cordova-plugin-smartlook": "git+https://github.com/smartlook/cordova-smartlook.git",
    "cordova-plugin-splashscreen": "^6.0.0",
    "cordova-plugin-statusbar": "^2.4.2",
    "cordova-plugin-whitelist": "^1.3.3",
    "jasmine-core": "~3.4.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.1.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~2.0.1",
    "karma-jasmine-html-reporter": "^1.4.0",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.15.0",
    "typescript": "~3.4.3"
  },
  "description": "An Ionic project",
  "cordova": {
    "plugins": {
      "cordova-plugin-advanced-http": {
        "OKHTTP_VERSION": "3.10.0"
      },
      "cordova-plugin-network-information": {},
      "cordova-plugin-whitelist": {},
      "cordova-plugin-statusbar": {},
      "cordova-plugin-device": {},
      "cordova-plugin-ionic-keyboard": {},
      "cordova-plugin-androidx": {},
      "cordova-plugin-androidx-adapter": {},
      "uk.co.workingedge.phonegap.plugin.launchnavigator": {
        "GOOGLE_API_KEY_FOR_ANDROID": "API_KEY",
        "OKHTTP_VERSION": "3.10.0",
        "LOCATION_USAGE_DESCRIPTION": "This app requires access to your location for navigation purposes"
      },
      "cordova-plugin-apprate": {
        "PLAY_CORE_VERSION": "1.+"
      },
      "ionic-plugin-deeplinks": {
        "URL_SCHEME": "myApp",
        "DEEPLINK_HOST": "www.myApp.co.id",
        "DEEPLINK_SCHEME": "https"
      },
      "cordova-android-play-services-gradle-release": {
        "PLAY-SERVICES-LOCATION": "11.0.1",
        "PLAY-SERVICES-ANALYTICS-IMPL": "11.0.1",
        "PLAY-SERVICES-BASEMENT": "11.0.1",
        "PLAY-SERVICES-ADS": "18.0.0",
        "PLAY-SERVICES-ADS-IDENTIFIER": "17.0.0",
        "PLAY-SERVICES-ADS-LITE": "18.0.0",
        "PLAY-SERVICES-AFS-NATIVE": "17.0.0",
        "PLAY-SERVICES-ANALYTICS": "17.0.0",
        "PLAY-SERVICES-APPINVITE": "18.0.0",
        "PLAY-SERVICES-AUDIENCE": "17.0.0",
        "PLAY-SERVICES-AUTH": "17.0.0",
        "PLAY-SERVICES-AUTH-API-PHONE": "17.0.0",
        "PLAY-SERVICES-AWARENESS": "17.0.0",
        "PLAY-SERVICES-BASE": "17.0.0",
        "PLAY-SERVICES-CAST": "17.0.0",
        "PLAY-SERVICES-CAST-FRAMEWORK": "17.0.0",
        "PLAY-SERVICES-CLEARCUT": "17.0.0",
        "PLAY-SERVICES-CRONET": "17.0.0",
        "PLAY-SERVICES-DRIVE": "17.0.0",
        "PLAY-SERVICES-FIDO": "18.0.0",
        "PLAY-SERVICES-FITNESS": "17.0.0",
        "PLAY-SERVICES-FLAGS": "17.0.0",
        "PLAY-SERVICES-GAMES": "18.0.0",
        "PLAY-SERVICES-GASS": "18.0.0",
        "PLAY-SERVICES-GCM": "17.0.0",
        "PLAY-SERVICES-IDENTITY": "17.0.0",
        "PLAY-SERVICES-IID": "17.0.0",
        "PLAY-SERVICES-INSTANTAPPS": "17.0.0",
        "PLAY-SERVICES-MAPS": "17.0.0",
        "PLAY-SERVICES-MEASUREMENT": "17.0.0",
        "PLAY-SERVICES-MEASUREMENT-API": "17.0.0",
        "PLAY-SERVICES-MEASUREMENT-IMPL": "17.0.0",
        "PLAY-SERVICES-MEASUREMENT-SDK": "17.0.0",
        "PLAY-SERVICES-MEASUREMENT-SDK-API": "17.0.0",
        "PLAY-SERVICES-NEARBY": "17.0.0",
        "PLAY-SERVICES-OSS-LICENSES": "17.0.0",
        "PLAY-SERVICES-PANORAMA": "17.0.0",
        "PLAY-SERVICES-PHENOTYPE": "17.0.0",
        "PLAY-SERVICES-PLACES": "17.0.0",
        "PLAY-SERVICES-PLACES-PLACEREPORT": "17.0.0",
        "PLAY-SERVICES-PLUS": "17.0.0",
        "PLAY-SERVICES-SAFETYNET": "17.0.0",
        "PLAY-SERVICES-STATS": "17.0.0",
        "PLAY-SERVICES-TAGMANAGER": "17.0.0",
        "PLAY-SERVICES-TAGMANAGER-API": "17.0.0",
        "PLAY-SERVICES-TAGMANAGER-V4-IMPL": "17.0.0",
        "PLAY-SERVICES-TASKS": "17.0.0",
        "PLAY-SERVICES-VISION": "18.0.0",
        "PLAY-SERVICES-VISION-COMMON": "18.0.0",
        "PLAY-SERVICES-VISION-IMAGE-LABEL": "18.0.0",
        "PLAY-SERVICES-WALLET": "17.0.0",
        "PLAY-SERVICES-WEARABLE": "17.0.0"
      },
      "cordova-clipboard": {},
      "cordova-plugin-inappbrowser": {},
      "cordova-plugin-x-socialsharing": {
        "PHOTO_LIBRARY_ADD_USAGE_DESCRIPTION": "This app requires photo library access to function properly.",
        "PHOTO_LIBRARY_USAGE_DESCRIPTION": "This app requires photo library access to function properly."
      },
      "cordova-plugin-ionic-webview": {
        "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
      },
      "mx.ferreyra.callnumber": {},
      "call-number": {},
      "cordova-plugin-mixpanel": {},
      "cordova-plugin-googlemaps": {
        "LOCATION_WHEN_IN_USE_DESCRIPTION": "This app wants to get your location while this app runs only.",
        "LOCATION_ALWAYS_USAGE_DESCRIPTION": "This app wants to get your location always, even this app runs in background."
      },
      "cordova-plugin-appsflyer-sdk": {},
      "cordova-plugin-idfa": {
        "ANDROID_PLAY_ADID_VERSION": "17.0.+"
      },
      "cordova-plugin-smartlook": {},
      "cordova-plugin-facebook-connect": {
        "APP_ID": "myAPP ID",
        "APP_NAME": "myApp",
        "FACEBOOK_URL_SCHEME_SUFFIX": " ",
        "FACEBOOK_AUTO_LOG_APP_EVENTS": "true",
        "FACEBOOK_HYBRID_APP_EVENTS": "false",
        "FACEBOOK_ADVERTISER_ID_COLLECTION": "true",
        "FACEBOOK_ANDROID_SDK_VERSION": "9.1.1",
        "FACEBOOK_IOS_SDK_VERSION": "9.2.0",
        "FACEBOOK_BROWSER_SDK_VERSION": "v9.0"
      },
      "cordova-plugin-google-analytics": {},
      "cordova-plugin-sign-in-with-apple": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-firebase-config": {
        "ANDROID_FIREBASE_CONFIG_VERSION": "21.0.+",
        "IOS_FIREBASE_CONFIG_VERSION": "~> 8.2.0"
      },
      "cordova-plugin-fcm-with-dependecy-updated": {
        "IOS_FIREBASE_MESSAGING_VERSION": "~> 8.2.0",
        "ANDROID_DEFAULT_NOTIFICATION_ICON": "@drawable/fcm_push_icon",
        "ANDROID_FCM_VERSION": "21.0.0",
        "ANDROID_FIREBASE_BOM_VERSION": "26.0.0",
        "ANDROID_GOOGLE_SERVICES_VERSION": "4.3.4",
        "ANDROID_GRADLE_TOOLS_VERSION": "4.1.0"
      },
      "cordova-plugin-firebase-analytics": {
        "ANALYTICS_COLLECTION_ENABLED": "true",
        "AUTOMATIC_SCREEN_REPORTING_ENABLED": "true",
        "ANDROID_FIREBASE_ANALYTICS_VERSION": "19.0.+"
      },
      "cordova-plugin-market": {}
    },
    "platforms": [
      "ios",
      "android"
    ]
  }
}
github-actions[bot] commented 2 years ago

There has been no recent activity and this issue has been marked inactive.

crebuh commented 1 year ago

I'm experiencing the same issue on android. After _loadAfterBeforeload was called no click inside the IAB is triggering the "beforeload" event any more. In comparison on iOS this works fine.

Ionic:

Ionic CLI : 6.20.1 (/Users/.nvm/versions/node/v18.4.0/lib/node_modules/@ionic/cli) Ionic Framework : @ionic/angular 6.4.0 @angular-devkit/build-angular : 14.2.10 @angular-devkit/schematics : 13.3.10 @angular/cli : 14.2.10 @ionic/angular-toolkit : 6.1.0

Capacitor:

Capacitor CLI : 4.5.0 @capacitor/android : 4.6.1 @capacitor/core : 4.6.1 @capacitor/ios : 4.6.1

Utility:

cordova-res : 0.15.4 native-run : 1.7.1

System:

NodeJS : v18.4.0 (/Users/.nvm/versions/node/v18.4.0/bin/node) npm : 8.12.1 OS : macOS Monterey