Open jcroucher opened 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.
@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?
For anyone else who got stuck.
For anyone else who got stuck.
This is not working for me. Do I need anything else?
@lmfmaier it only works for swiping back in iOS.
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
}
@lmfmaier how does this handle links? It goes forwards? Do you have a video?
@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.
@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 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.
@lmfmaier ah ok so i doesn't fix the issue. We'll stick to Flutter 😂
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.
@sergiusvet it doesn't work going forwards though which makes the app seem very janky.
@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.
@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 :-).
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?
@khromov it won't go back if it's the last page :-)
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?