Open one-adam-nolan opened 6 years ago
Hello @one-adam-nolan , I need exactly the same thing and I am interested in your implementation of the dismiss call for SafariViewController. Can you please provide a link to your branch? I checked this repository but I couldn't find the implementation. Thanks.
@alexmeia Sorry about not getting back with you sooner. I need to check my work computer to see if I still have that repo locally. At the time, I hadn't really used git and had some trouble setting up my fork.
I'm using this plugin to implement an OAuth flow and ran into this issue aswell. After some searching i found the following solution, which seems to work and close the SafariViewController.
This might help to implement the close() feature or for other people having the same issue.
import * as application from 'application';
// Only for IOS
const controller = application.ios.nativeApp.windows[0].rootViewController;
controller.dismissViewControllerAnimatedCompletion(true, () => {
console.log('Safari dismissed')
});
thanks @Aqu1nt that works !!
@bradmartin I'll try to implement the same in Android, and if theres a reliable way to do both in Android and iOS, you can maybe add a method in the library itself that does it !
actually if launchMode
is singleTop
in Android, it automatically closes!
Two months ago I was in a rush to make it close the advanced webview in iOS after login, and I did a little edit to the plugin to return the SFSafariViewController (or the AdvancedWebView in Android) when the method openAdvancedUrl is called. In this way, you can close the WebView calling the native methods (in my case, as @championswimmer said, this was needed only in iOS).
let advancedWebView: any;
advancedWebView = openAdvancedUrl(opts);
export function closeAdvancedWebView(animated: boolean) {
// No need to manually close advancedWebView in Android.
if (advancedWebView && platform.isIOS) {
advancedWebView.dismissViewControllerAnimatedCompletion(animated, null);
}
}
If this can be useful, you can see iOS the edit here: https://github.com/phoops/nativescript-advanced-webview/blob/master/advanced-webview.ios.ts#L79 Pretty same for Android. I'm using our custom version as dependency in my projects, for now.
This would be really helpful for OpenId Connect using a Hybrid Authorization Workflow. For my case, I launch to the external browser for login (Identity Server 4) and use the redirect with UrlHandler. If the server redirect is something like
adams.app://authorized
I want to programmatically be able to close the webview and pop back into the app.I have a created a branch locally and have implemented the dismiss call for the SafariViewController (iOS) in the Demo app. Unfortunately, its been sometime since I have dealt with native Android; so I am not sure where to start there.