DeepLinkRouter
DeepLinkRouter 是 Swift 的深链接管理器。
安装
CocoaPods
pod 'DeepLinkRouter'
Carthage
github "shotastage/DeepLinkRouter" "0.0.3"
基本用法
首先,导入 DeepLinkRouter,然后覆盖 func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey :Any] = [:]) -> Bool
并注册主机与路径,如下所示:
URL:your-app://host/path
示例 your-app://next/movie
import UIKit
import DeepLinkRouter
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
...
func application(_ app: UIApplication,
open url: URL,
options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
let router = Router(from: url)
router
.register(path: "next/movie", {
NSLog("LOG: Movie action has been launched!")
})
.register(path: "next/photo", {
NSLog("LOG: Photo action has been launched!")
})
.register(path: "next/music", {
NSLog("LOG: Music action has been launched!")
})
.performRouter()
return true
}
...
}
许可
本软件免费分发,遵循 MIT 协议,详细请参阅 LICENSE