-
Notifications
You must be signed in to change notification settings - Fork 282
Add a Swift Receiver Demo #68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ab46a54
3db8b17
f1ab57b
24ada7c
013f8d0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import UIKit | ||
|
|
||
| @UIApplicationMain | ||
| class DPLReceiverSwiftAppDelegate: UIResponder, UIApplicationDelegate { | ||
|
|
||
| var window: UIWindow? | ||
| lazy var router: DPLDeepLinkRouter = DPLDeepLinkRouter() | ||
|
|
||
| func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { | ||
|
|
||
| // Register a class to a route using object subscripting | ||
| self.router["/product/:sku"] = DPLProductRouteHandler.self | ||
|
|
||
| // Register a class to a route using the explicit registration call | ||
| self.router.registerHandlerClass(DPLMessageRouteHandler.self, forRoute: "/say/:title/:message") | ||
|
|
||
| return true | ||
| } | ||
|
|
||
| func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject?) -> Bool { | ||
| self.router.handleURL(url, withCompletion: nil) | ||
| return true | ||
| } | ||
|
|
||
| func application(application: UIApplication, continueUserActivity userActivity: NSUserActivity, restorationHandler: ([AnyObject]!) -> Void) -> Bool { | ||
|
|
||
| self.router.handleUserActivity(userActivity, withCompletion: nil) | ||
| return true | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
| <plist version="1.0"> | ||
| <dict> | ||
| <key>CFBundleDevelopmentRegion</key> | ||
| <string>en</string> | ||
| <key>CFBundleExecutable</key> | ||
| <string>$(EXECUTABLE_NAME)</string> | ||
| <key>CFBundleIdentifier</key> | ||
| <string>com.usebutton.$(PRODUCT_NAME:rfc1034identifier)</string> | ||
| <key>CFBundleInfoDictionaryVersion</key> | ||
| <string>6.0</string> | ||
| <key>CFBundleName</key> | ||
| <string>$(PRODUCT_NAME)</string> | ||
| <key>CFBundlePackageType</key> | ||
| <string>APPL</string> | ||
| <key>CFBundleShortVersionString</key> | ||
| <string>1.0</string> | ||
| <key>CFBundleSignature</key> | ||
| <string>????</string> | ||
| <key>CFBundleURLTypes</key> | ||
| <array> | ||
| <dict> | ||
| <key>CFBundleTypeRole</key> | ||
| <string>Editor</string> | ||
| <key>CFBundleURLName</key> | ||
| <string>io.dpl</string> | ||
| <key>CFBundleURLSchemes</key> | ||
| <array> | ||
| <string>dpl</string> | ||
| </array> | ||
| </dict> | ||
| </array> | ||
| <key>CFBundleVersion</key> | ||
| <string>1.0</string> | ||
| <key>LSRequiresIPhoneOS</key> | ||
| <true/> | ||
| <key>UILaunchStoryboardName</key> | ||
| <string>Main</string> | ||
| <key>UIMainStoryboardFile</key> | ||
| <string>Main</string> | ||
| <key>UIRequiredDeviceCapabilities</key> | ||
| <array> | ||
| <string>armv7</string> | ||
| </array> | ||
| <key>UISupportedInterfaceOrientations</key> | ||
| <array> | ||
| <string>UIInterfaceOrientationPortrait</string> | ||
| </array> | ||
| </dict> | ||
| </plist> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| #import <DeepLinkKit/DeepLinkKit.h> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you have to make this explicitly? If so, should we include it in DLK for all to use?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In order to expose the Objective-c based pod to the Swift code, you do have to add the pod's framework into your bridging header. Cocoapods did add the That said, no you wouldn't include this in the actual pod. |
||
| #import "DPLProduct.h" | ||
| #import "DPLProductDataSource.h" | ||
| #import "DPLProductTableViewController.h" | ||
| #import "DPLProductDetailViewController.h" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import Foundation | ||
|
|
||
| public class DPLMessageRouteHandler: DPLRouteHandler { | ||
| public override func shouldHandleDeepLink(deepLink: DPLDeepLink!) -> Bool { | ||
| if let title = deepLink.routeParameters["title"] as? String, | ||
| message = deepLink.routeParameters["message"] as? String { | ||
| UIAlertView(title: title, message: message, delegate: nil, cancelButtonTitle: "OK").show() | ||
| } | ||
| return false | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import Foundation | ||
|
|
||
| public class DPLProductRouteHandler: DPLRouteHandler { | ||
| public override func targetViewController() -> UIViewController! { | ||
| if let storyboard = UIApplication.sharedApplication().keyWindow?.rootViewController?.storyboard { | ||
| return storyboard.instantiateViewControllerWithIdentifier("detail") as! DPLProductDetailViewController | ||
| } | ||
|
|
||
| return UIViewController() | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe make it clear that you're showing registration using two different methods here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also,
;?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Silly copy pasta 😉