fluttercommunity / flutter_webview_plugin

Community WebView Plugin - Allows Flutter to communicate with a native WebView.
https://pub.dev/packages/flutter_webview_plugin
Other
1.48k stars 933 forks source link

Listening for redirect #218

Open willladislaw opened 6 years ago

willladislaw commented 6 years ago

Using WebView Plugin to launch facebook oauth connection flow. It seems user has to be logged-in first (see image) to display facebook oauth permission dialog.

One option will be to open facebook login screen then redirect back to app (on successful login) before launching oauth connection flow.

For this to work I need to be able to listen for a redirect from fb's login screen to fb's home screen (after login) at which point, return back to the app and launch connection flow. It seems plugin is not able to detect the redirect - plugin.onUrlChanged() is not triggered after authentication (redirect from login screen to home screen).

new FlatButton(
      child: const Text("Ok"),
      onPressed: () {
        launchWebView();

      }),

void launchWebView(){
    flutterWebviewPlugin.launch(
      'https://m.facebook.com/',
      withJavascript: true,
      withLocalStorage: true,
    );
//Not triggered
    flutterWebviewPlugin.onUrlChanged.listen((String changed) {
      if(changed.contains('https://m.facebook.com/home.php')){
        setState(() {
          //reload webview with connection flow url
        });
      }

    });
  }

enter image description here

feelfreelinux commented 6 years ago

Can confirm, i am unable to extract redirection from simillar oauth flow. Any progress? @slightfoot