diiiary / capacitor-plugin-ios-swipe-back

9 stars 25 forks source link

Dead project? #6

Open jcroucher opened 3 years ago

jcroucher commented 3 years ago

Looks like this project is dead. The developers site is also dead https://diiiary.com Is there a fork we could point to as a new base?

PowerOfM commented 3 years ago

It probably is. The only line you really need is bridge.getWebView()?.allowsBackForwardNavigationGestures = true;

We ended up just making a "plugin" directly in the App folder that does this on load.

ollyde commented 2 years ago

@PowerOfM learning Capacitor here, where do I find 'bridge'. It doesn't say in the docs https://capacitorjs.com/docs/core-apis/ios

And it's not JS?

Screenshot 2022-08-18 at 23 18 01
ollyde commented 2 years ago

For anyone else who got stuck.

Screenshot 2022-08-18 at 23 26 45
lmfmaier commented 2 years ago

For anyone else who got stuck.

Screenshot 2022-08-18 at 23 26 45

This is not working for me. Do I need anything else?

ollyde commented 2 years ago

@lmfmaier it only works for swiping back in iOS.

lmfmaier commented 2 years ago

After some more research I came up with this code which works for me (forward and backward navigation gestures working in the ios web view)

In AppDelegate.swift

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        (window?.rootViewController as? CAPBridgeViewController)?.loadViewIfNeeded()
        (window?.rootViewController as? CAPBridgeViewController)?.bridge?.webView?.allowsBackForwardNavigationGestures = true
        return true
    }
ollyde commented 2 years ago

@lmfmaier how does this handle links? It goes forwards? Do you have a video?

lmfmaier commented 2 years ago

@lmfmaier how does this handle links? It goes forwards? Do you have a video?

What links do you mean? App/router links are handled by this. I just goes back and forward in the history. I use vue router in history mode.

I open external links in a separate browser window rand not in the web view.

ollyde commented 2 years ago

@lmfmaier we're talking about capacitor here and default web-views as we are using Svelte and not including any framework supplied by Ionic.

How does this handle default links when it moves forward? Does it slide to the next screen?

lmfmaier commented 2 years ago

@lmfmaier we're talking about capacitor here and default web-views as we are using Svelte and not including any framework supplied by Ionic.

How does this handle default links when it moves forward? Does it slide to the next screen?

A "regular" link that opens a new document in the same web view's history is handled by this, just like in Safari.

ollyde commented 2 years ago

@lmfmaier ah ok so i doesn't fix the issue. We'll stick to Flutter 😂

sergiusvet commented 1 year ago

After some more research I came up with this code which works for me (forward and backward navigation gestures working in the ios web view)

In AppDelegate.swift

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        (window?.rootViewController as? CAPBridgeViewController)?.loadViewIfNeeded()
        (window?.rootViewController as? CAPBridgeViewController)?.bridge?.webView?.allowsBackForwardNavigationGestures = true
        return true
    }

This actually works. Only it has a strange issue/behavior. We use Vue + Vuetify, and the router-view is surrounded by a transition. And the transition is buggy on iOS. On Google Pixel it works fine btw.

ollyde commented 1 year ago

@sergiusvet it doesn't work going forwards though which makes the app seem very janky.

sergiusvet commented 1 year ago

@ollydixon Nah, I tested my app in Safari, and it has nothing to do with this approach, the app is "janky" there too, and I suppose it's because of the combination of how the vuetify + vue router transition works and how safari handles back/forward navigation animation.

ollyde commented 1 year ago

@sergiusvet I mentioned before; not using and wrappers for navigation animations; would be nice to get this native; I guess that would require multiple webviews and a native overlying :-).

khromov commented 2 months ago

Thanks @ollyde and @sergiusvet for your excellent examples!

I am trying sergiusvet last version of the code and it works great, except that the user can go back from the first page the landed on to a completely white page. Then a few seconds later you go back to the page you were previously on, has any of you run into this issue and know how you can prevent navigating to this empty blank page?

ollyde commented 2 months ago

@khromov it won't go back if it's the last page :-)