Giter Site home page Giter Site logo

deeplinkkit's People

Contributors

alinradut avatar atlcto avatar buttonpairing avatar chrismaddern avatar clyde-labs avatar daikimat avatar dasmer avatar dependabot[bot] avatar dkhamsing avatar edwardaux avatar ehlersd avatar getaaron avatar jimmy-btn avatar jonwinton avatar jou avatar kylebshr avatar lapfelix avatar levitrammell avatar lxcid avatar mliberatore avatar patrick-kladek avatar pavelpantus avatar platedbay avatar rishabhtayal avatar senfi avatar uson1x avatar vojtechbartos avatar wehriam avatar wessmith avatar zkrige avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

deeplinkkit's Issues

Confusing use of leading slash to define routes

I'd be surprised if this wasn't a common point of confusion... when looking at the sample project, and code such as:

        self.router.registerHandlerClass(DPLMessageRouteHandler.self, forRoute: "/say/:title/:message")

Most will presume this translates to an URL such as my-app://say/someTitle/someMessage... but in reality you must register the route without the leading slash

I'd propose making examples and README more explicit by showing corresponding external URL for each and every registration example, including, perhaps, comments in the sample source itself.

Internal DeepLink Routing

Purpose

We build a deep link routing mechanism to route incoming URIs to states within our apps, delegating responsibility to handlers for fetching and processing data and ViewControllers for presenting the resources we request.

Ideally we create and maintain one navigation system and this should be the URI -> app state mapping mechanism that we current delegate only to deep link handling.

High Level Requirements

  • All ViewController states have URIs which are a way of serializing and reproducing the current state
  • There is an object responsible for managing the presentation of ViewControllers based on incoming URI & current state
  • Current states can be 'drilled from' by adding partial URLs (e.g. if at /products/123 navigating to "related" navigates to /products/123/related)
  • More to come..

Add a handler for an empty path

This may or may not be a controversial request, but it would be nice to have a handler for an empty path.

In my app, because of reasons, we have a url like http://ourapp.com/?certainId={id} come in. I thought I could handle it with self.router.registerBlock(block, forRoute: "") but it didn't catch it...

Use as internal router

I would like to use this library as an internal router, too. Has anyone used for this yet?

In my view, for this use case, it would be nice to have a method in DPLDeepLinkRouter that returns the configured ViewController for a URL. To make it easier customizing transitions or even setting cached values on the target ViewController.

Another thing that may help is to separate the logic for matching and creating the DPLDeepLink. With this I could subclass the DPLDeepLinkRouter to make the above mentioned functionality available much easier.

Any thoughts on this? I could do it and create PR.

Route is matching partial string

Given 2 'host' routes "me" and "home":

self.router[@"me"] = ^(DPLDeepLink *link) { .. }
self.router[@"home"] = ^(DPLDeepLink *link) { .. }

entering via [protocol]://home actually matches the first handler for "me" (since ho[me])

This can be worked around by swapping the order of the route handlers, but I figured it would be a good thing to fix the matching regexp.

Deep Links to Routes with a Single Path Component Break with Trailing Slash

Using 1.2.1, I’m noticing an issue with routes that consist of a single path component failing to be handled when a trailing slash is included in the URL. This issue is not present when there is more than one path component in the registered route.

Example

In Info.plist, I have the following scheme, test, set up so that my test app opens from Mobile Safari for URLs that begin with test://.

screen shot 2016-11-08 at 4 16 51 pm

This is the entirety of AppDelegate.m in an otherwise empty test project, in which I demonstrate the issue:

#import "AppDelegate.h"
#import <DeepLinkKit/DeepLinkKit.h>

@interface AppDelegate ()

@property (nonatomic) DPLDeepLinkRouter *router;

@end

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.router = [[DPLDeepLinkRouter alloc] init];
    
    self.router[@"search"] = ^(DPLDeepLink *link) {
        // Called for `test://search`
        // Not called for `test://search/` <-- THE ISSUE
        NSLog(@"Handled Search Link");
    };
    
    self.router[@"settings/about"] = ^(DPLDeepLink *link) {
        // Called for `test://settings/about`
        // Called for `test://settings/about/`
        NSLog(@"Handled settings/about Link");
    };
    
    return YES;
}

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
    return [self.router handleURL:url withCompletion:NULL];
}

@end

In summary, the issue shown in this example is that when attempting to open test://search/ in Mobile Safari the handler that logs the message "Handled Search Link" is not called.

Workaround

There is a workaround to the issue, and that is to specify /? to the end of the registered route to allow for an optional trailing slash. In the example above, that’d change the registration of search to be:

self.router[@"search/?"] = ^(DPLDeepLink *link) {
    // Called for `test://search`
    // Called for `test://search/`
    NSLog(@"Handled Search Link");
};

However, this is not ideal as it requires treating routes with different numbers of components differently.

Clean up DPLRegularExpression

Clean up DPLRegularExpression to know less about routes & delegate responsibility for pre-cleanup to DPLRouteMatcher (?)

pod try fails

➜  ios-deeplink-sdk git:(master) ✗ pod try DeepLinkSDK
Updating spec repositories

Trying DeepLinkSDK
Analyzing dependencies
Fetching podspec for `DeepLinkSDK` from `.`
Pre-downloading: `Specta` from `https://github.com/specta/specta.git`, commit `16949f4021a5560b1c78c439ad07d596c36cbac3`
[!] Unable to satisfy the following requirements:

- `DeepLinkSDK (from `.`)` required by `Podfile`
- `DeepLinkSDK (from `.`)` required by `Podfile`
- `DeepLinkSDK (= 0.1.0)` required by `Podfile.lock`
Opening '/private/tmp/CocoaPods/Try/DeepLinkSDK/DeepLinkSDK.xcworkspace'

The demo project will not build even after running this command.

This occurs both when running the command in an empty folder, and when running it in a cloned copy of the repo.

Route pattern matching

Hi, first of all your library is great and now we are using it in second project, and we are more than happy.
But I have first problem, and I would like you to ask if I am doing something wrong or this type of route is not possible.

I have several deep links that look like application://something?somethingElse=value and i wanted to handle route like ":type?:parameter", and extract value by using query.parameters. But this block never gets called. It is ok when I do something?:parameters something2:parameters ... but it is quite too much code in my opinion.

Defining an array of routes to the block or subclass

It would be better if there is support for multiple routes as array when defining routes, in case there are multiple ways to reach a url.

So a situation i came across is my domain.com/contact was the same route as support.domain.com/request/new so i had to create two routes like this.

self.router[@"contact"] = ^(DPLDeepLink *link) {
    NSLog(@"DeepLink: Opening Support Page");
    [weakself feedbackAction];
  };

self.router[@"/requests/new/"] = ^(DPLDeepLink *link) {
    NSLog(@"DeepLink: Opening Support Page");
    [weakself feedbackAction];
  };

If it was possible to create to something like this would be awesome:

self.router[@"contact", @"/requests/new/"] = ^(DPLDeepLink *link) {
    NSLog(@"DeepLink: Opening Support Page");
    [weakself feedbackAction];
  };

Xcode 8.3 beta compilation fails

On Xcode 8.3 beta (8W109m) compilation fails with the following error :
redefinition of module 'DeepLinkKit'

not sure if it is a DeepLinkKit issue or a Cocoapods issue ..

Better type support for Swift

I was using this in my app, and I was having difficulties with using the subscripting to get/set block route handlers. This is because the subscript method returns id, which in Swift was coming up as AnyObject. It wasn't let me cast the return value to DPLRouteHandlerBlock, because closures aren't objects.

There is probably some elegant solution that I didn't think of, but I just ended up writing a wrapper around it

Route to already instantiated ViewControllers

This is mostly a question (you can tag it as question), on what's the best approach to route a deeplink to an already instantiated UIViewController.
Like having N viewControllers on a UITabBarController, I would like to have one of them to present itself or push another one to the stack.

I guess this could be done with a block like this, where I have available the existingTargetVC:

    self.router[@"link"]    = ^(DPLDeepLink *link) { 
        [weakself.existingTargetVC doSomeForwardNavigation];
    };

but I can't see any way to do it in a DPLRouteHandlersubclass. I would prefer to have that logic separated.

Any ideas?

Swift demo or examples?

Great framework, thanks! Is there a Swift demo or examples anywhere? It would be immensely appreciated and a step in the right direction for better Swift support.

@"".DPL_parametersFromQueryString crashes on iOS7

Apparently @"".stringByRemovingPercentEncoding returns nil on iOS7. The following lines:

NSString *key = [[pairs firstObject] DPL_stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
paramsDict[key] = @"";

crash for e.g. customscheme:/whatever?# for obvious reasons.

Can I use this library in my Swift 3 project?

I see this is written in Obj-C and all the documentation is in Obj-C. Does anybody know if there are swift 3 API's for this library? If not does anybody recommend any other libraries?

Swift Port

Hey guys,

First of all, thank you very much for this framework. It saves us so much time I can't thank you enough.

I know this is a delicate subject, there are those that are forward and against this, but do you guys plan on doing a Swift port of the framework?

Add support for arrays in query parameters

Queries may contain parameters like the following:

items[]=item1&items[]=item2

This should be interpreted as

NSArray *items = @[ @"item1", @"item2"];

Currently it is represented as:

@{ @"items[]" = @"item2" }

Related: #15

Regex schemes

Is it possible to use a regex in the scheme? Specifically to match:
one://www.host.com/callback
and
two://www.host.com/callback
but not
three://www.host.com/callback

I expected this to work but it doesn't:
(one|two)://www.host.com/callback

There seems to be a commit that added this but no mention in the docs.

first path component stripped out

it seems that the first path component is stripped out in the route matcher, which is not what I would expect

i.e. given a route declared as

 self.router[@"routeA/:param1/:param2/:param3"] = ^(DPLDeepLink *link) {
    };

I would expect a URL in the form

scheme://routeA/param1/param2/param3
to match, but it matches only if there is an additional path component after the scheme, e.g.
scheme://x/routeA/param1/param2/param3
.

Using v0.1.1 from cocoapods

registerHandlerClass function is not there?

I have been upgrading to swift 3 for the passed hours i have put everything to work, except for DeepLinkKit. I am not able to find the function registerHandlerClass anymore. The weird thing is it is in the DPLDeepLinkRouter.h but when i command click on DeepLinkKit within my own code i get the following:

dlk

I am not sure that this is a problem I have or this is a problem in the pod. I have deleted the pods, deleted Podfile.lock, deleted derived data, cleaned my project, everything, but it still doesn't show up. Does anyone know what to do?

Should we use didFinishLaunch to handle app URL or openUrl is enough?

Just a question to understand

According apple documentation we don't need to handle URL in both places openUrl and didFinishLaunch. Have you any trouble if using only openUrl? Don't you have duplicated reaction if using both?

Your implementation of this method should open the specified URL and update its user interface accordingly. If your app had to be launched to open the URL, the app calls the application:willFinishLaunchingWithOptions: and application:didFinishLaunchingWithOptions: methods first, followed by this method. The return values of those methods can be used to prevent this method from being called. (If the app is already running, only this method is called.)

https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplicationDelegate_Protocol/index.html#//apple_ref/occ/intfm/UIApplicationDelegate/application:openURL:sourceApplication:annotation:

DPLMutableDeepLink set queryParameters are not retreived by objectForKeyedSubscript

Use of the ivar in objectForKeyedSubscript causes it to not work on the mutable subclass as the property is redefined to be mutable.

e.g...

DPLMutableDeepLink *mutableDeeplink = [[DPLMutableDeepLink alloc] initWithString:@"scheme://some/link"];

mutableDeepLink.queryParameters[@"this"] = @"that";

NSString *that = mutableDeepLink[@"this"];

// that is nil

[!] Invalid `Podfile` file: [!] Unsupported options `{:exclusive=>true}` for target `SenderDemo`

I use git clone, pod install; and then I have a proplem as below:

[!] Invalid `Podfile` file: [!] Unsupported options `{:exclusive=>true}` for target `SenderDemo`..

 #  from /private/var/folders/3y/q_lrv8s56wlc5kv0r8g_35nh0000gn/T/CocoaPods/Try/DeepLinkKit/Podfile:5
 #  -------------------------------------------
 #  
 >  target 'SenderDemo', :exclusive => true do
 #      pod 'DeepLinkKit', :path => '.'
 #  -------------------------------------------

A a few hours, I got a solution,it's a problem of cocoapods version.
Here is the solution of the issue.
I followed the step,change the podfile like below, it works. Maybe help others.

xcodeproj 'DeepLinkKit.xcodeproj', 'Test' => :debug
inhibit_all_warnings!
use_frameworks!

target 'SenderDemo' do
    pod 'DeepLinkKit', :path => '.'
end

target 'ReceiverDemo' do
    pod 'DeepLinkKit', :path => '.'
end

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

target 'Tests' do
    pod 'Spectra'
    pod 'Expecta'
    pod 'OCMock'
    pod 'KIF'
end

Allow multiple targetViewControllers of the same type in a navigation stack.

The method - (void)placeTargetViewController:(UIViewController *)targetViewController inNavigationController:(UINavigationController *)navigationController in DPLRouteHandler.mprevents having multiple instances of the same view controller type in a navigation stack. It does that by popping all view controllers above a certain type of controller, and then replacing that controller with the new one.

Doing this messes up the navigation stack for the user when it comes to the back button. If they are looking at a controller, then they hit a deep link, and then hit back, they are not where they started before they hit the deep link.

Why not just always present the targetViewController() in top, or at least have an option to not wipe the navigation stack before presenting the targetViewController?

Have optionnal parameter

Hi,

I would like to track a campaign code in the deep link to see where some of the users come from.
So I can have something like @"/account" but also @"/account/:campaign_code".
It would be nice to do that !

DPLRouteMatcher Incorrectly Matches URL Without Host or Path

Using the ReceiverDemo project as an example, which supports the scheme dpl://, registering a route with a single, variable component, e.g. : log_message causes a false match for this route when the URL dpl:// with nothing after the scheme is opened.

This is caused by the URL having a nil host and a nil path, and not accounting for that possibility in -[DPLRouteMatcher deepLinkWithURL:].

The following route registration in ReceiverDemo can demonstrate the issue:

self.router[@":log_message"] = ^(DPLDeepLink *link) {
    NSLog(@"%@", link[@"log_message"]);
};

With this route registered, opening the URL dpl://hello from e.g. Mobile Safari will cause the message hello to be logged to the console, which works as expected. However, when opening the URL dpl:// from Mobile Safari, the same route is still matched, and (null)(null) is logged to the console.

I have a fix incoming for this.

Rename iOS DeepLink SDK -> ??

Would love any comments on this... currently thinking something like:

  • RouteKit
  • DeepLinkKit
  • DeepLinkRouter

The term SDK isn't really a good description of the 'weight' of this library so we wanted to drop it.

DPL_stringBy* method implementations use deprecated CFURLCreateString* APIs

CFURLCreateStringByAddingPercentEscapes and CFURLCreateStringByReplacingPercentEscapesUsingEncoding are deprecated as of iOS 9.0. The recommended replacements are -[NSString stringByAddingPercentEncodingWithAllowedCharacters:] and -[NSString stringByRemovingPercentEncoding] which are both available starting in iOS 7.

RFC 3986 Section 2.3 specifies the unreserved characters for URIs, namely ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.~. This is probably a reasonable set to pass to -stringByAddingPercentEncodingWithAllowedCharacters:.

Pull request forthcoming…

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.