hotwired / hotwire-native-ios

Hotwire Native for iOS
MIT License
73 stars 7 forks source link

redirect_to not calling that handle method in the NavigatorDelegate #29

Closed trobrock closed 1 month ago

trobrock commented 1 month ago

We have a rails action that runs:

def index
  redirect_to :other_action if turbo_native_app?
end

When this runs we get a call into handle on the NavigatorDelegate for the request to :index, but we don't get another call for the move to :other_action.

Are we doing something wrong, what's the best way to intercept and act on redirects?

Here is our delegate code:

extension SceneDelegate: NavigatorDelegate {
    func handle(proposal: VisitProposal) -> ProposalResult {
        print("Trying to handle \(proposal.viewController) \(proposal.url.absoluteString)")
        return .accept
    }
}
trobrock commented 1 month ago

Turns out this is only happening because this action :index is our initial page load, and the turbo bridge is not setup yet to intercept the redirect.

Will close for now and will try and update with whatever solution we end up with.

trobrock commented 1 month ago

We are sort of hacking around this for now by setting the start route to /native and in that action we are using Turbo.visit to redirect once turbo is loaded. Feels hacky, but I'm not sure what other solutions exist.