Skip to content

Commit de4d90f

Browse files
committed
add block based registration example
1 parent ac6a8a5 commit de4d90f

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

SampleApps/ReceiverDemoSwift/DPLReceiverSwiftAppDelegate.swift

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,21 @@ class DPLReceiverSwiftAppDelegate: UIResponder, UIApplicationDelegate {
88

99
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
1010

11+
// Register a block to a route (matches dpl:///product/93598)
12+
self.router.registerRoute("/product/:sku") { link in
13+
print("\(link!.url.absoluteString)")
14+
15+
if let rootViewController = application.keyWindow?.rootViewController as? UINavigationController {
16+
if let storyboard = rootViewController.storyboard {
17+
if let controller = storyboard.instantiateViewController(withIdentifier: "detail") as? DPLTargetViewController {
18+
controller.configure(with: link)
19+
rootViewController.pushViewController(controller as! UIViewController, animated: false)
20+
}
21+
}
22+
}
23+
}
1124

12-
// Register a class to a route using object subscripting
13-
self.router["/product/:sku"] = DPLProductRouteHandler.self
14-
15-
// Register a class to a route using the explicit registration call
25+
// Register a class to a route.
1626
self.router.registerHandlerClass(DPLMessageRouteHandler.self, forRoute: "/say/:title/:message")
1727

1828
return true

0 commit comments

Comments
 (0)