apache / apache/cordova-plugin-inappbrowser

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

Open
#763 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1.1k
Forks
2.2k
PR merge metrics
No merged PRs in 30d

Description

# 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

Contributor guide

Open the contributing guide

Research direction

Start with the setIABPosstMessageHook, getIABFromSender, and exitCameraView entry points described in the report, and trace the InAppBrowser instance across navigation from page A to page B. Done means the instance remains available after the camera stops and iab.show() works from the close action.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.