fluttercommunity / fluttercommunity/flutter_webview_plugin

onUrlChanged.listen never called on iOS

Open
#661 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1.5k
Forks
938
PR merge metrics
No merged PRs in 30d

Description

## System info

Issue occurs on: iOS
Plugin version: xxx

#Problem

I am using onUrlChanged.listen in order to get the code of OAuth2 authentication. I get this code by listening to url changes, and it works fine on Android. When I launch it in iOS, I get a blank white screen. When I try to debug, I see that onUrlChanged.listen callback is never being called.

Here is my code:
void main() {
WidgetsFlutterBinding.ensureInitialized();
LoginController _loginController = new LoginController();
_loginController.getCodeWebView().then((FlutterWebviewPlugin flutterWebView) {
//deal here with webview and token request
flutterWebView.onUrlChanged.listen((String url) async {
if (url.length > 25) {
int endIndex = url.indexOf("&state");
if (url.contains("code=")) {
String code = url.substring(
url.indexOf('code') + 5, endIndex); //with "http://localhost:4200/
flutterWebView.close();
String accessToken = await _loginController.getAccessToken(code);
_loginController.decodeJwtAndPopulateUser(accessToken);
//Now that we have the token, we can instantiate layout with async calls that depends on token
runApp(
AppContainer(accessToken)
);
}
}
});
});
}

Can anyone help me please? I am struggling with it. I don't know if its a bug. I am testing it in iOS 13.3 and I already added the info.plist things to support webview_plugin:

`
NSAllowsArbitraryLoads

NSAllowsArbitraryLoadsInWebContent

`

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.