bradmartin / nativescript-advanced-webview

NativeScript plugin for Chrome CustomTabs on Android and SafariViewController on iOS.
Other
60 stars 28 forks source link

Feature: provide interface for controlling the advanced webview #17

Open jonnysamps opened 7 years ago

jonnysamps commented 7 years ago

I'm trying to use the advanced webview for an oauth workflow. The problem is that I need programatic access to the webview so that I can close it when the workflow completes. Right now it only allows user interaction to control it.

PS. I'd be happy to collaborate on it.

bradmartin commented 7 years ago

I'd have to look but I don't recall seeing any native methods on the APIs that allow programmatically closing chrome/safari. Can you look into the native APIs and see if closing them is a method exposed? If not there likely isn't anything we can do. You might be better off with the core webview in nativescript that is exposed.

On Thu, Jun 29, 2017, 1:11 PM Jonathan Samples notifications@github.com wrote:

I'm trying to use the advanced webview for an oauth workflow. The problem is that I need programatic access to the webview so that I can close it when the workflow completes. Right now it only allows user interaction to control it.

PS. I'd be happy to collaborate on it.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/bradmartin/nativescript-advanced-webview/issues/17, or mute the thread https://github.com/notifications/unsubscribe-auth/AFulhOID0S7KVkk6KMUSdjlf4V2KQgtoks5sI-jHgaJpZM4OJrUz .

jonnysamps commented 7 years ago

I know iOS has it: https://developer.apple.com/documentation/uikit/uiviewcontroller/1621505-dismissviewcontrolleranimated

Not sure about Android

jonnysamps commented 7 years ago

Also, I can't use the built-in webview because of Google's restricted requirements for OAuth.

bradmartin commented 7 years ago

Gotcha. Well if android has something then that would be a great addition to add. Id like to add more of the options for it I just don't have time right now to do a lot. Can definitely help with questions and PRs :)

On Thu, Jun 29, 2017, 1:40 PM Jonathan Samples notifications@github.com wrote:

Also, I can't use the built-in webview because of Google's restricted requirements for OAuth.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/bradmartin/nativescript-advanced-webview/issues/17#issuecomment-312061368, or mute the thread https://github.com/notifications/unsubscribe-auth/AFulhMQ6Kgnmr6weJOtjfHll1NYwcgOQks5sI--ngaJpZM4OJrUz .

jonnysamps commented 7 years ago

Looks like you can close any active activity on Android if you have access to it. Just need to figure that part out. Disclosure: never written a native Android app.

I'll put together a PR.

bradmartin commented 7 years ago

Poke around here on the android docs: https://developer.android.com/reference/android/support/customtabs/CustomTabsIntent.Builder.html - my quick glance didn't look promising on the API for customtabs - but yea closing the Chrome activity seems reasonable 👍 I wasn't thinking that direction to be honest.

chrisbellman commented 7 years ago

@jonnysamps trying to do something similar (use WebView to login / grab token from WebView then close WebView). How did you end up implementing?

alexmeia commented 6 years ago

Hello, any progress on this? I think this is a major issue for developers using advanced webview for OAuth authentication flow. Especially in iOS, the plugin should expose e method to closed automatically Safari View Controller after redirect to custom URL.

etelford commented 5 years ago

The way I handle this: from my web app that completes OAuth, I use an x-callback-url that my native app receives. Based on that, I dispatch an event globally to dismiss/close the SafariViewController.