Skip to content

Example of routing URLs, NSUserActivity and UIApplicationShortcutItems in an iOS app.

Notifications You must be signed in to change notification settings

agiletortoise/Router

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Router

There are an increasing array of ways an application on iOS may be launched with a context/command passed to it requiring routing within the app. These methods include:

  • NSUserActivity(s) generated by Handoff or Spotlight.
  • UIApplicationShortcutItems generated by 3D Touch shortcuts.
  • URL schemes (x-callback-url, univeral app links, or other) for deep linking into the app.

This is a sample application demonstrating a technique for abstracting routing of similar incoming commands from these sources through a router and router delegate.

This project was built with Swift 3 on Xcode 8 beta 6 and is not intended for reuse, or meant to be complete, it's just a demostration put out there to solicit feedback on this method.

The Router object should be created in the AppDelegate, and assigned a router delegate early in the app lifecycle.

The AppDelegate passes off NSUserActivity(s), UIApplicationShortcutItem(s) and URLs to the router, which handles translating them into a generic RouterRequest struct and asking the router delegate to handle the actual command. In the case of x-callback-url requests the callback URLs are parsed and included with the RouterRequest to be called when appropriate by the router delegate.

It was made by @agiletortoise. If you have comments, please let me know.

About

Example of routing URLs, NSUserActivity and UIApplicationShortcutItems in an iOS app.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages