Turbolinks 5 iOS app link not pushing VisitableViewController onto stack

281 views Asked by At

I've been playing around with Turbolinks 5 and I can't seem to get it to visit a new page correctly after clicking a link within my application. The app loads the new view as if it was replaced inside the webview and doesn't push a new view controller on to the stack like I would expect. It's as if it doesn't perform a Turblonks.visit

I'm running a rails 5.1 application with the Turbolinks 5 enabled. My link looks like this:

<%= link_to 'View', test_path(test_id), class: 'btn btn-secondary btn-block marginTop_short' %>

As you can see there is nothing special about this link!

My iOS app code is very basic:

import UIKit
import Turbolinks

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

  var window: UIWindow?
    var navigationController = UINavigationController()
    var session = Session()


    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
      // Override point for customization after application launch.
      window?.rootViewController = navigationController
        startApplication()
        return true
    }

  func startApplication() {
    session.delegate = self
      visit(URL: NSURL(string: "http://localhost:3000")!)
  }

  func visit(URL: NSURL) {
    print("visiting", URL)
      let visitableViewController = VisitableViewController(url: URL as URL)
      navigationController.pushViewController(visitableViewController, animated: true)
      session.visit(visitableViewController)
  }

}

extension AppDelegate: SessionDelegate {
  func session(_ session: Session, didProposeVisitToURL URL: URL, withAction action: Action) {
    print("trying to visit", URL)
      print("action", action)
      visit(URL: URL as NSURL)
  }

  func session(_ session: Session, didFailRequestForVisitable visitable: Visitable, withError error: NSError) {
    let alert = UIAlertController(title: "Error", message: error.localizedDescription, preferredStyle: .alert)
      alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
      navigationController.present(alert, animated: true, completion: nil)
  }
}

When I click a link it doesn't fire the func session(_ session: Session, didProposeVisitToURL URL: URL, withAction action: Action) callback.

Maybe it's more accurate to say when a link is clicked the webview is not responding to or createing a visit proposal?

What am I missing? Any help would be appreciated.

Let me know if any more detail is require or clarification.

0

There are 0 answers