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
2 changes: 1 addition & 1 deletion DeepLinkKit.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "DeepLinkKit"
s.version = "1.0.0"
s.version = "1.1.0"
s.summary = "A splendid route-matching, block-based way to handle your deep links."
s.description = <<-DESC
DeepLink Kit is a splendid route-handling block-based way to handle deep links. Use DeepLink Kit to parse incoming URLs, extract parameters from the host, url etc.. and even build outgoing deeplinks. All with a simple, block-based interface.
Expand Down
12 changes: 11 additions & 1 deletion DeepLinkKit/Router/DPLDeepLinkRouter.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ typedef void(^DPLRouteCompletionBlock)(BOOL handled, NSError *error);

/**
Attempts to handle an incoming URL.
@param url The incoming URL from `application:didFinishLaunchingWithOptions:' or `application:openURL:sourceApplication:annotation:'
@param url The incoming URL from `application:openURL:sourceApplication:annotation:'
@param completionHandler A block executed after the deep link has been handled.
@return YES if the incoming URL is handled, otherwise NO.

Expand All @@ -86,6 +86,16 @@ typedef void(^DPLRouteCompletionBlock)(BOOL handled, NSError *error);
- (BOOL)handleURL:(NSURL *)url withCompletion:(DPLRouteCompletionBlock)completionHandler;


/**
Attempts to handle an incoming user activity.
@param userActivity The incoming user activity from `application:continueUserActivity:restorationHandler:'
@param completionHandler A block executed after the user activity has been handled.
@return YES if the incoming user activity is handled, otherwise NO.

@see DPLRouteCompletionBlock
*/
- (BOOL)handleUserActivity:(NSUserActivity *)userActivity withCompletion:(DPLRouteCompletionBlock)completionHandler;


///--------------------
/// @name Configuration
Expand Down
9 changes: 9 additions & 0 deletions DeepLinkKit/Router/DPLDeepLinkRouter.m
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,15 @@ - (BOOL)handleURL:(NSURL *)url withCompletion:(DPLRouteCompletionBlock)completio
}


- (BOOL)handleUserActivity:(NSUserActivity *)userActivity withCompletion:(DPLRouteCompletionBlock)completionHandler {
if ([userActivity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) {
return [self handleURL:userActivity.webpageURL withCompletion:completionHandler];
}

return NO;
}


- (BOOL)handleRoute:(NSString *)route withDeepLink:(DPLDeepLink *)deepLink error:(NSError *__autoreleasing *)error {
id handler = self[route];

Expand Down
16 changes: 8 additions & 8 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
PODS:
- DeepLinkKit (1.0.0)
- DeepLinkKit (1.1.0)
- Expecta (1.0.0)
- KIF (3.2.2):
- KIF/XCTest (= 3.2.2)
- KIF/XCTest (3.2.2)
- KIF (3.2.3):
- KIF/XCTest (= 3.2.3)
- KIF/XCTest (3.2.3)
- OCMock (3.1.2)
- Specta (1.0.0)
- Specta (1.0.2)

DEPENDENCIES:
- DeepLinkKit (from `.`)
Expand All @@ -19,10 +19,10 @@ EXTERNAL SOURCES:
:path: .

SPEC CHECKSUMS:
DeepLinkKit: 5d7deb38ad7bc7daf8670eb8878cd8b806ef9689
DeepLinkKit: 3979713c8a0b6bd3259fb7917e572acf56645a35
Expecta: 32604574add2c46a36f8d2f716b6c5736eb75024
KIF: b0bd762b0c7890b04920cf618021d6d4fd5127bd
KIF: a94bffe9c97e449e44f8fa481c53243d21309e1e
OCMock: a10ea9f0a6e921651f96f78b6faee95ebc813b92
Specta: 96fe05fe5c7348b5223f85e862904f6e832abb14
Specta: 9cec98310dca411f7c7ffd6943552b501622abfe

COCOAPODS: 0.37.1
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,24 @@ self.router[@"/log/:message"] = ^(DPLDeepLink *link) {
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {

[self.router handleURL:url withCompletion:NULL];
return [self.router handleURL:url withCompletion:NULL];
}
```
**6. Passing `NSUserActivity` objects to the router** (optional)
<br/>
_**Note:** If your application supports [Apple's new universal links](https://developer.apple.com/library/prerelease/ios/releasenotes/General/WhatsNewIniOS/Articles/iOS9.html#//apple_ref/doc/uid/TP40016198-DontLinkElementID_2), implement the following in your app delegate:_

return YES;
```objc
- (BOOL)application:(UIApplication *)application
continueUserActivity:(NSUserActivity *)userActivity
restorationHandler:(void (^)(NSArray *))restorationHandler {

return [self.router handleUserActivity:userActivity withCompletion:NULL];
}
```



Learn more about the DeepLinkKit by reading our [Integration Guide](http://www.usebutton.com/sdk/deep-links/integration-guide).

## Route Registration Examples
Expand Down
8 changes: 8 additions & 0 deletions SampleApps/ReceiverDemo/DPLReceiverAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,12 @@ - (BOOL)application:(UIApplication *)application
return [self.router handleURL:url withCompletion:NULL];
}


- (BOOL)application:(UIApplication *)application
continueUserActivity:(NSUserActivity *)userActivity
restorationHandler:(void (^)(NSArray *))restorationHandler {

return [self.router handleUserActivity:userActivity withCompletion:NULL];
}

@end
28 changes: 28 additions & 0 deletions Tests/Router/DPLDeepLinkRouterSpec.m
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,34 @@
expect(isHandled).to.beFalsy();
});
});

it(@"handles an incoming user activity that is a web browsing activity type", ^{
waitUntil(^(DoneCallback done) {

NSUserActivity *activity = [[NSUserActivity alloc] initWithActivityType:NSUserActivityTypeBrowsingWeb];
activity.webpageURL = [NSURL URLWithString:@"https://dlc.com/say/hello"];;

router[@"/say/:word"] = ^{};

BOOL isHandled = [router handleUserActivity:activity withCompletion:^(BOOL handled, NSError *error) {
expect(handled).to.beTruthy();
expect(error).to.beNil();
done();
}];
expect(isHandled).to.beTruthy();
});
});

it(@"does NOT handle an incoming user activity that is a NOT web browsing activity type", ^{

NSUserActivity *activity = [[NSUserActivity alloc] initWithActivityType:@"derpType"];
activity.webpageURL = [NSURL URLWithString:@"https://dlc.com/say/hello"];;

router[@"/say/:word"] = ^{};

BOOL isHandled = [router handleUserActivity:activity withCompletion:NULL];
expect(isHandled).to.beFalsy();
});
});

SpecEnd