Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
239 changes: 239 additions & 0 deletions DeepLinkKit.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ target 'ReceiverDemo', :exclusive => true do
pod 'DeepLinkKit', :path => '.'
end

target 'ReceiverDemoSwift', :exclusive => true do
pod 'DeepLinkKit', :path => '.'
end

target 'Tests', :exclusive => true do
pod 'Specta'
pod 'Expecta'
Expand Down
14 changes: 7 additions & 7 deletions SampleApps/ReceiverDemo/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6254" systemVersion="14A388a" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="Mxc-im-9AM">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7706" systemVersion="14E46" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="Mxc-im-9AM">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
</dependencies>
<scenes>
<!--View Controller-->
Expand Down Expand Up @@ -93,7 +93,7 @@
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Beer" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="4gq-4c-TFd">
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="$0.00" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="3qi-7w-OX8">
Expand Down Expand Up @@ -133,15 +133,15 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Beer Name" textAlignment="center" lineBreakMode="wordWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="270" translatesAutoresizingMaskIntoConstraints="NO" id="ePO-uQ-SAF">
<rect key="frame" x="25" y="271" width="269" height="26.5"/>
<rect key="frame" x="25" y="271" width="269" height="27"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="22"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="$0.00" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="200" translatesAutoresizingMaskIntoConstraints="NO" id="hTB-1e-KBy">
<rect key="frame" x="139" y="305" width="43" height="20.5"/>
<rect key="frame" x="139" y="305" width="43" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="gwo-qw-10k">
Expand Down
31 changes: 31 additions & 0 deletions SampleApps/ReceiverDemoSwift/DPLReceiverSwiftAppDelegate.swift
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")
Copy link
Contributor

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?

// 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")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, ;?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Silly copy pasta 😉


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
}
}

51 changes: 51 additions & 0 deletions SampleApps/ReceiverDemoSwift/Info.plist
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>
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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 use_frameworks! in 0.36 which would mean you don't have to do this but I believe that only supports iOS 8 and above.

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()
}
}