onUrlChanged.listen never called on iOS
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:
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSAllowsArbitraryLoadsInWebContent</key>
<true/>
</dict>
@davik4life @charafau Can you guys help me please?
I would suggest you ask this in stackoverflow because I don't think this is a support forum...BUT you need to call flutterWebView.launch() or similar (check examples for better understanding) before any listening can happen.
So this is not a bug. You aren't just using it correctly.
Getting the same here.. but if using the example app it works
@villematti So Sorry, I just saw your message now. Were you able to find a fix? Pls let us know, Thanks.