apache / apache/cordova-plugin-inappbrowser

Is there any way to transfer data say variable defined in inappbrowser and inject it into javascript file in executeScript, I am getting undefined.

Open
#481 0 comments 1 reaction 0 assignees View on GitHub
question
Dominant language
Java
Stars
1.1k
Forks
2.2k
PR merge metrics
No merged PRs in 30d

Description

# Bug Report

## Problem
Is there any way to transfer data say variable defined in inappbrowser and inject it into javascript file in executeScript

### What is expected to happen?
How to inject this "FCMtoken" value in postFCMToken.js ?

### What does actually happen?
I am Unable to access the variable that is defined in inappbrowser. Now I want to access it in javascript file that is being executed in executeScript function.

postFCMToken.js is being executed successfully and I can see the output.

But I am unable to access this variable,FCMtoken, in postFCMToken.js

## Information

### Command or Code

var myObj = {value: '1'};

var FCMtoken = JSON.stringify(myObj);

ref.addEventListener("loadstop", function() { ref.executeScript({ file: window.location.host + '/assets/postFCMToken.js ' });
});

**FIle -> postFCMToken.js**

```
obj = JSON.parse(FCMtoken);
console.log(obj.value);
// getting undefined here
```

### Environment, Platform, Device
Android using Cordova 9.0.0

### 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 loadstop handler that calls executeScript and the referenced postFCMToken.js file. Determine whether the FCMtoken value is available in the execution context used by the script, using the supplied Android and Cordova 9.0.0 details; done means the reported variable-access behavior is clearly reproduced and its supported behavior is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.