From fe1197bc524d9dbc62fc01499eb32f6c0d3429b4 Mon Sep 17 00:00:00 2001 From: Wes Smith Date: Fri, 12 Jun 2015 05:45:05 -0700 Subject: [PATCH 1/6] update pods --- Podfile.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Podfile.lock b/Podfile.lock index d0e10b6..b51dfce 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,11 +1,11 @@ PODS: - DeepLinkKit (1.0.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 `.`) @@ -21,8 +21,8 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: DeepLinkKit: 5d7deb38ad7bc7daf8670eb8878cd8b806ef9689 Expecta: 32604574add2c46a36f8d2f716b6c5736eb75024 - KIF: b0bd762b0c7890b04920cf618021d6d4fd5127bd + KIF: a94bffe9c97e449e44f8fa481c53243d21309e1e OCMock: a10ea9f0a6e921651f96f78b6faee95ebc813b92 - Specta: 96fe05fe5c7348b5223f85e862904f6e832abb14 + Specta: 9cec98310dca411f7c7ffd6943552b501622abfe COCOAPODS: 0.37.1 From 7fff8ab231c60ae1f9ed38361057378631e131b3 Mon Sep 17 00:00:00 2001 From: Wes Smith Date: Fri, 12 Jun 2015 05:45:46 -0700 Subject: [PATCH 2/6] add api for handling NSUserActivity --- DeepLinkKit/Router/DPLDeepLinkRouter.h | 12 +++++++- DeepLinkKit/Router/DPLDeepLinkRouter.m | 9 ++++++ .../ReceiverDemo/DPLReceiverAppDelegate.m | 8 ++++++ Tests/Router/DPLDeepLinkRouterSpec.m | 28 +++++++++++++++++++ 4 files changed, 56 insertions(+), 1 deletion(-) diff --git a/DeepLinkKit/Router/DPLDeepLinkRouter.h b/DeepLinkKit/Router/DPLDeepLinkRouter.h index 434fed4..9c15a49 100644 --- a/DeepLinkKit/Router/DPLDeepLinkRouter.h +++ b/DeepLinkKit/Router/DPLDeepLinkRouter.h @@ -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. @@ -86,6 +86,16 @@ typedef void(^DPLRouteCompletionBlock)(BOOL handled, NSError *error); - (BOOL)handleURL:(NSURL *)url withCompletion:(DPLRouteCompletionBlock)completionHandler; +/** + Attempts to 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 diff --git a/DeepLinkKit/Router/DPLDeepLinkRouter.m b/DeepLinkKit/Router/DPLDeepLinkRouter.m index a81e2c8..d07d148 100644 --- a/DeepLinkKit/Router/DPLDeepLinkRouter.m +++ b/DeepLinkKit/Router/DPLDeepLinkRouter.m @@ -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]; diff --git a/SampleApps/ReceiverDemo/DPLReceiverAppDelegate.m b/SampleApps/ReceiverDemo/DPLReceiverAppDelegate.m index 168b1c4..74ef827 100644 --- a/SampleApps/ReceiverDemo/DPLReceiverAppDelegate.m +++ b/SampleApps/ReceiverDemo/DPLReceiverAppDelegate.m @@ -47,4 +47,12 @@ - (BOOL)application:(UIApplication *)application return [self.router handleURL:url withCompletion:NULL]; } + +- (BOOL)application:(nonnull UIApplication *)application + continueUserActivity:(nonnull NSUserActivity *)userActivity + restorationHandler:(nonnull void (^)(NSArray * __nullable))restorationHandler { + + return [self.router handleUserActivity:userActivity withCompletion:NULL]; +} + @end diff --git a/Tests/Router/DPLDeepLinkRouterSpec.m b/Tests/Router/DPLDeepLinkRouterSpec.m index cdc179f..a0ef2ae 100644 --- a/Tests/Router/DPLDeepLinkRouterSpec.m +++ b/Tests/Router/DPLDeepLinkRouterSpec.m @@ -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 From 58ed5ac53ac95781d33f0610ed87ddd14e53c356 Mon Sep 17 00:00:00 2001 From: Wes Smith Date: Fri, 12 Jun 2015 06:18:16 -0700 Subject: [PATCH 3/6] add docs for user activity handling --- README.md | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3c929c2..36b2e3c 100644 --- a/README.md +++ b/README.md @@ -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) +
+_**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:(nonnull UIApplication *)application + continueUserActivity:(nonnull NSUserActivity *)userActivity + restorationHandler:(nonnull 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 From ce7066463885f6fb943430915ba7c3722c225c54 Mon Sep 17 00:00:00 2001 From: Wes Smith Date: Fri, 12 Jun 2015 06:24:20 -0700 Subject: [PATCH 4/6] bump to 1.1.0 --- DeepLinkKit.podspec | 2 +- Podfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DeepLinkKit.podspec b/DeepLinkKit.podspec index 87cb6f3..204a8a6 100644 --- a/DeepLinkKit.podspec +++ b/DeepLinkKit.podspec @@ -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. diff --git a/Podfile.lock b/Podfile.lock index b51dfce..ad11872 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,5 +1,5 @@ PODS: - - DeepLinkKit (1.0.0) + - DeepLinkKit (1.1.0) - Expecta (1.0.0) - KIF (3.2.3): - KIF/XCTest (= 3.2.3) @@ -19,7 +19,7 @@ EXTERNAL SOURCES: :path: . SPEC CHECKSUMS: - DeepLinkKit: 5d7deb38ad7bc7daf8670eb8878cd8b806ef9689 + DeepLinkKit: 3979713c8a0b6bd3259fb7917e572acf56645a35 Expecta: 32604574add2c46a36f8d2f716b6c5736eb75024 KIF: a94bffe9c97e449e44f8fa481c53243d21309e1e OCMock: a10ea9f0a6e921651f96f78b6faee95ebc813b92 From 22c667de146353c53ef052019b714a4130c70a2c Mon Sep 17 00:00:00 2001 From: Wes Smith Date: Fri, 12 Jun 2015 06:34:49 -0700 Subject: [PATCH 5/6] fix missing word in docs --- DeepLinkKit/Router/DPLDeepLinkRouter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DeepLinkKit/Router/DPLDeepLinkRouter.h b/DeepLinkKit/Router/DPLDeepLinkRouter.h index 9c15a49..30080c8 100644 --- a/DeepLinkKit/Router/DPLDeepLinkRouter.h +++ b/DeepLinkKit/Router/DPLDeepLinkRouter.h @@ -87,7 +87,7 @@ typedef void(^DPLRouteCompletionBlock)(BOOL handled, NSError *error); /** - Attempts to an incoming user activity. + 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. From 3331b4d7db97b1535875e76252634e5bc368af4b Mon Sep 17 00:00:00 2001 From: Wes Smith Date: Fri, 12 Jun 2015 06:38:41 -0700 Subject: [PATCH 6/6] remove nonnull for now --- README.md | 6 +++--- SampleApps/ReceiverDemo/DPLReceiverAppDelegate.m | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 36b2e3c..8fe7927 100644 --- a/README.md +++ b/README.md @@ -88,9 +88,9 @@ self.router[@"/log/:message"] = ^(DPLDeepLink *link) { _**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:_ ```objc -- (BOOL)application:(nonnull UIApplication *)application - continueUserActivity:(nonnull NSUserActivity *)userActivity - restorationHandler:(nonnull void (^)(NSArray *))restorationHandler { +- (BOOL)application:(UIApplication *)application + continueUserActivity:(NSUserActivity *)userActivity + restorationHandler:(void (^)(NSArray *))restorationHandler { return [self.router handleUserActivity:userActivity withCompletion:NULL]; } diff --git a/SampleApps/ReceiverDemo/DPLReceiverAppDelegate.m b/SampleApps/ReceiverDemo/DPLReceiverAppDelegate.m index 74ef827..685a8e4 100644 --- a/SampleApps/ReceiverDemo/DPLReceiverAppDelegate.m +++ b/SampleApps/ReceiverDemo/DPLReceiverAppDelegate.m @@ -48,9 +48,9 @@ - (BOOL)application:(UIApplication *)application } -- (BOOL)application:(nonnull UIApplication *)application - continueUserActivity:(nonnull NSUserActivity *)userActivity - restorationHandler:(nonnull void (^)(NSArray * __nullable))restorationHandler { +- (BOOL)application:(UIApplication *)application + continueUserActivity:(NSUserActivity *)userActivity + restorationHandler:(void (^)(NSArray *))restorationHandler { return [self.router handleUserActivity:userActivity withCompletion:NULL]; }