URLScheme router than supports auto creation of UIViewControllers for associated url parameters to allow creation of navigation stacks

Overview

IKRouter

What does it do?

Once you have made your UIViewControllers conform to Routable you can register them with the parameters that they represent in your registered url-scheme routes. IKRouter is then able to create an array of UIViewControllers for you to display when a valid url is handled. All you need to do then is display them!

IKRouter can also handle routes in the traditional way by simply registering a route and handling it with a funciton/closure and the two methods can also be used together.

An example route is:

myapp://project/:projectId/item/:itemId

Note that routes must include the scheme (myapp://), url parameters need to be prefixed with a colon (:) and query strings dont need to be included when registering a route as they are included when the route is matched.

Using Routables

To use the Routables to automatically create your UI stack

  1. Make any UIViewController that can be linked to a route parameter conform to Routable.
  2. Register these with your IKRouter instance.
  3. Register the routes that use those parameters.
  4. Handle the chain of UIViewControllers via the routableHandler closure/function.

The Routable protocol

The Routable protocol consists of a single simple method which when give a MatchedRoute returns an instance of the Routable.

protocol Routable {
    static func instanceForRoute(route: MatchedRoute) -> Routable?
}

MatchedRoute instances provide all the details needed to pass information through to Routables like matched parameters and their values as well as query string.

Routable Example

Once your UIViewControllers are Routable simply do the following:

let navController = UINavigationController()
let router = IKRouter()
router
    .registerRoutableWithParameter(ProjectViewController.self, parameter: ":projectId")
    .registerRoutableWithParameter(ItemViewController.self, parameter: ":itemId")
    .registerRouteHandler("myapp://project/:projectId/item/:itemId")
    .registerRouteHandler("myapp://project/:projectId")
    .routableHandler = { match, viewControllers in
        navController.setViewControllers(viewControllers, animated: true)
    }

Things to note about using Routable

  • As many routes can be registered as you want in any combination as long as each one is:
    • Unique
    • Has a Routable registered for all parameters
  • If a route comes through and there is a parameter without a Routable the default handler will be used (if provided)
  • When registering a route there is a handler parameter. This can be omitted when using Routables.

Non Routable Example

If you have routes which might not suit the automatic functionality provided by Routables you can also register individual routes with their own handlers

let router = IKRouter()
router
    .registerRouteHandler("myapp://project/:projectId/item/:itemId") { match in
        //create view controllers and show here...
        return true
    }
    .registerRouteHandler("myapp://project/:projectId/users/:userId") { match in
        //create view controllers and show here...
        return true /* return false if we didn't handle the route */
    }

NOTE: The handler for each route is used here (unlike above)

UIViewController Presentation

Every app has a slightly different UI hierarchy/architecture... for this reason IKRouter does not provide and automatic handling of UIViewController presentation but instead allows you to handle that yourself. Instead I have provided a UINavigationController extension that you can use to display the stack in different ways.

Currently there is just a simple method that will take a stack of UIViewControllers; push all but the last and present the last item in the stack like so:

router.routableHandler = { match, viewControllers in
    navController.setViewControllersPresentingLast(viewControllers, animatedSet: true, animatedPresent: true)
}

If there are other means of displaying a stack you think would be useful here feel free to add an issue or pull request, both are welcome!

Installation

Install via cocoapods by adding the following to your Podfile

1.0" ">
pod "IKRouter", "~>1.0"

or manually by adding the source files from the IKRouter subfolder to your project.

The rest...

There is an included app so you can see it in action.

You might also like...
An easier way to handle third-party URL schemes in iOS apps.
An easier way to handle third-party URL schemes in iOS apps.

IntentKit ========= IntentKit is an easier way to handle third-party URL schemes in iOS apps. Linking to third-party apps is essentially broken on iOS

URL routing library for iOS with a simple block-based API

JLRoutes What is it? JLRoutes is a URL routing library with a simple block-based API. It is designed to make it very easy to handle complex URL scheme

DZURLRoute is an Objective-C implementation that supports standard-based URLs for local page jumps.

DZURLRoute Example To run the example project, clone the repo, and run pod install from the Example directory first. Requirements s.dependency 'DZVie

RxFlow is a navigation framework for iOS applications based on a Reactive Flow Coordinator pattern
RxFlow is a navigation framework for iOS applications based on a Reactive Flow Coordinator pattern

About Navigation concerns RxFlow aims to Installation The key principles How to use RxFlow Tools and dependencies GitHub Actions Frameworks Platform L

🍞 [Beta] A view controller that can unwind like presentation and navigation.

FluidPresentation - no more handling presented or pushed in view controller A view controller that supports the interactive dismissal by edge pan gest

Easy and maintainable app navigation with path based routing for SwiftUI.

Easy and maintainable app navigation with path based routing for SwiftUI.

🛣 Simple Navigation for iOS
🛣 Simple Navigation for iOS

Router Reason - Get Started - Installation Why Because classic App Navigation introduces tight coupling between ViewControllers. Complex Apps navigati

Protocol oriented, Cocoa UI abstractions based library that helps to handle view controllers composition, navigation and deep linking tasks in the iOS application. Can be used as the universal replacement for the Coordinator pattern. Monarch Router is a Declarative URL- and state-based router written in Swift.
Monarch Router is a Declarative URL- and state-based router written in Swift.

Monarch Router is a declarative routing handler that is capable of managing complex View Controllers hierarchy transitions automatically, decoupling View Controllers from each other via Coordinator and Presenters. It fits right in with Redux style state flow and reactive frameworks.

Crossroad is an URL router focused on handling Custom URL Scheme
Crossroad is an URL router focused on handling Custom URL Scheme

Crossroad is an URL router focused on handling Custom URL Scheme. Using this, you can route multiple URL schemes and fetch arguments and parameters easily.

iOS routing done right. Handles both URL recognition and controller displaying with parsed parameters. All in one line, controller stack preserved automatically!
iOS routing done right. Handles both URL recognition and controller displaying with parsed parameters. All in one line, controller stack preserved automatically!

Developed and Maintained by Ipodishima Founder & CTO at Wasappli Inc. (If you need to develop an app, get in touch with our team!) So what is this lib

SwiftRouter - A URL Router for iOS, written in Swift

SwiftRouter A URL Router for iOS, written in Swift, inspired by HHRouter and JLRoutes. Installation SwiftRouter Version Swift Version Note Before 1.0.

LOL Champions app: a small Multi-Module demo application to demonstrate modern iOS application tech-stacks with a Multi-module and MVVM architecture
LOL Champions app: a small Multi-Module demo application to demonstrate modern iOS application tech-stacks with a Multi-module and MVVM architecture

LOL Champions app: a small Multi-Module demo application to demonstrate modern iOS application tech-stacks with a Multi-module and MVVM architecture

Easily create UIViewControllers for news articles similar to those in the News app.
Easily create UIViewControllers for news articles similar to those in the News app.

MRArticleViewController This framework allows you to easily setup View Controllers to display News Articles inspired by those from the Apple News App.

A Swift wrapper for URL bookmarks which allow a file to be located regardless of whether it is moved or renamed.

Bookmark A Swift wrapper for URL bookmarks which allow a file to be located regardless of whether it is moved or renamed. This class wraps Swift's URL

An experimental navigation router for SwiftUI

SwiftUIRouter 🔗 An ⚠️ experimental ⚠️ navigation router for SwiftUI Usage 💡 Check out ExampleApp for more. Define your routes: import SwiftUIRouter

SmartString - A powerful and small library that will allow the creation of complex String Styles
SmartString - A powerful and small library that will allow the creation of complex String Styles

SmartString A powerful and small library that will allow the creation of complex

A Safari Web Extension to allow auto-refreshing of individual tabs

Safari Web Extension - AutoRefresh See article on Medium. App store download (free and no Ads). There are a few websites that I visit and that time ou

Manage multi-domain url auto mapping ip address table.
Manage multi-domain url auto mapping ip address table.

Domainer Multi-domain mapper. This library provides manage multi-domain table. Features Manage multi-domain mapping main domain. Find best domain whic

Owner
Ian Keen
Ian Keen
Crossroad is an URL router focused on handling Custom URL Scheme

Crossroad is an URL router focused on handling Custom URL Scheme. Using this, you can route multiple URL schemes and fetch arguments and parameters easily.

Kohki Miki 331 May 23, 2021
iOS routing done right. Handles both URL recognition and controller displaying with parsed parameters. All in one line, controller stack preserved automatically!

Developed and Maintained by Ipodishima Founder & CTO at Wasappli Inc. (If you need to develop an app, get in touch with our team!) So what is this lib

null 589 Dec 24, 2022
SwiftRouter - A URL Router for iOS, written in Swift

SwiftRouter A URL Router for iOS, written in Swift, inspired by HHRouter and JLRoutes. Installation SwiftRouter Version Swift Version Note Before 1.0.

Chester Liu 259 Apr 16, 2021
An experimental navigation router for SwiftUI

SwiftUIRouter ?? An ⚠️ experimental ⚠️ navigation router for SwiftUI Usage ?? Check out ExampleApp for more. Define your routes: import SwiftUIRouter

Orkhan Alikhanov 16 Aug 16, 2022
A demonstration to the approach of leaving view transition management to a router.

SwiftUI-RouterDemo This is a simplified demonstration to the approach of leaving view transition management to a router.

Elvis Shi 3 May 26, 2021
Interface-oriented router for discovering modules, and injecting dependencies with protocol in Objective-C and Swift.

ZIKRouter An interface-oriented router for managing modules and injecting dependencies with protocol. The view router can perform all navigation types

Zuik 631 Dec 26, 2022
An extremely lean implementation on the classic iOS router pattern.

Beeline is a very small library that aims to provide a lean, automatic implementation of the classic iOS router pattern.

Tim Oliver 9 Jul 25, 2022
Helm - A graph-based SwiftUI router

Helm is a declarative, graph-based routing library for SwiftUI. It fully describ

Valentin Radu 99 Dec 5, 2022
A bidirectional Vapor router with more type safety and less fuss.

vapor-routing A routing library for Vapor with a focus on type safety, composition, and URL generation. Motivation Getting started Documentation Licen

Point-Free 68 Jan 7, 2023
A bidirectional router with more type safety and less fuss.

swift-url-routing A bidirectional URL router with more type safety and less fuss. This library is built with Parsing. Motivation Getting started Docum

Point-Free 242 Jan 4, 2023