cordova-plugin-inappbrowser icon indicating copy to clipboard operation
cordova-plugin-inappbrowser copied to clipboard

InAppBrowser on .show() undefined and instance is vanished from the scope when passed from page to page?

Open sardapv opened this issue 5 years ago • 1 comments

Bug Report

Problem

Ok question may sound weird. (you can also reproduce this by following below)

I have 2 pages in my ionic 5 app. page A has a login screen, call its .service.ts file as a.service.ts page B has the Camera Preview plugin installed a.service.ts has a method to pass InAppBrowser instance to page B from page A. ( so I can add hook of postMessage) When inappbrowser instance is passed successfully to a.service.ts from A and to B as well.

Looks like below

inside a.service.ts

setIABPosstMessageHook(iab) {
   this.iabInstance = iab; // set iab passed from page A here
   this.router.navigateByUrl('camera-rdc'); // navigated to page success
   this.cameraRdcController.getIABFromSender(this.iabInstance); // check below for method
}

inside B (camera controller)

getIABFromSender(iabInstance) {
iabInstance.on('message').subscribe((callbackData) => {
  iabInstance.hide(); // hidie inappbrowser works
  this.iab = iabInstance // iab set successfully to global variable this.iab
  this.cameraTriggeredInIAB(callbackData.data.cameraSide); //starts camera
});

}

now on camera page, I have a close button which calls below method -

  exitCameraView() {
    this.cameraPreview.stopCamera().then(() => { //stop cammera
      this.screenOrientation.unlock(); // unlock landscape orientation
      this.iab.show(); // ERROR COMES HERE AS show  on undefined!!!! how?
    });
  }

in debug mode, I see that its there in 'this' but after I click close button, somehow this iab is gone from this!! I can't seem to find how does this object got vanished.

because of that, my IAB is not showing up again. Help, please. I haven't faced any such issue in the angular or ionic side till today, but now I don't have any clue. Thanks.

What is expected to happen?

show should work, but iab object is gone

What does actually happen?

error as show on undefined

Information

check above

Environment, Platform, Device

latest ionic 5, testing on pixel 2 xl

Version information

Checklist

  • [ x] I searched for existing GitHub issues
  • [ x] I updated all Cordova tooling to most recent version
  • [ x ] I included all the necessary information above

sardapv avatar Aug 17 '20 18:08 sardapv

@sardapv Did you ever find a solution to this?

relyks48 avatar Oct 25 '24 18:10 relyks48