Code Monkey home page Code Monkey logo

Comments (8)

Aqu1nt avatar Aqu1nt commented on May 28, 2024 3

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')
});

from nativescript-advanced-webview.

championswimmer avatar championswimmer commented on May 28, 2024 1

actually if launchMode is singleTop in Android, it automatically closes!

from nativescript-advanced-webview.

alexmeia avatar alexmeia commented on May 28, 2024 1

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.

from nativescript-advanced-webview.

alexmeia avatar alexmeia commented on May 28, 2024

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.

from nativescript-advanced-webview.

one-adam-nolan avatar one-adam-nolan commented on May 28, 2024

@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.

from nativescript-advanced-webview.

championswimmer avatar championswimmer commented on May 28, 2024

thanks @Aqu1nt that works !!

from nativescript-advanced-webview.

championswimmer avatar championswimmer commented on May 28, 2024

@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 !

from nativescript-advanced-webview.

triniwiz avatar triniwiz commented on May 28, 2024

@championswimmer the lib is => here feel free to send a pr 😄

from nativescript-advanced-webview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.