apache / apache/cordova-plugin-inappbrowser

postmessage not available on iOS

Open
#988 8 comments 7 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1.1k
Forks
2.2k
PR merge metrics
No merged PRs in 30d

Description

Hello

I need to close cordova iab after login, and I would do this with post message from browser in app to hybrid app
I've done with this code:

```
function dLogin() {
var messageObj = {
status: 200,
error: false,
message: "test",
user: {
id: 1,
token: "ABCDEF"
}
};
var stringifiedMessageObj = JSON.stringify(messageObj);
window['webkit'].messageHandlers['cordova_iab'].postMessage(stringifiedMessageObj);
}
```

Android build: all works fine
iOS build: window['webkit'] is not defined. I've tried with:
- window.
- webkit.
- (window as any).webkit

what I'm wrong?

thanks in advance

Contributor guide

Open the contributing guide

Research direction

Start with dLogin() in the issue body and reproduce the iOS build, checking whether window.webkit.messageHandlers.cordova_iab is exposed in the InAppBrowser page. Compare the documented iOS messaging path with the working Android behavior; done means the login page can send the message and close the Cordova InAppBrowser on iOS.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, javascript
Domain
mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.