Giter Club home page Giter Club logo

browser-deeplink's People

Contributors

dcocchia avatar hampusohlsson avatar johngibb avatar martnst avatar mindplay-dk 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

browser-deeplink's Issues

storeUrl fallback problem

In my case we use http://distimo.com tracking service to count redirects.
This service provides custom link that redirects to store like this: http://app.lk/BaW.
So I override fallback redirect accordingly.

deeplink.setup({
    iOS: {
        storeUrl: "http://app.lk/BaW",
    }
});

And if an app is installed and user returns from the app to the browser timeout function fires.
Thank you!

Android and ios always leads to opening the Play Store

Android and ios always open into the app store even app is installed
<--! library file ->

<button type="button" class="view"><a href="javascript:void(0)" data-uri="myapp://example.com" onclick="openApp(this.dataset.uri)"> view</a></button>


<script>
 deeplink.setup({
    iOS: {
        appName: "App name",
        appId: "app_id",
    },
    android: {
        appId: "app id"
    }
});

    function openApp(url){
    deeplink.open(url);    
    return false;
}

</script>

Several problems on Android

Hi! Cool script, but I've been doing investigation on how it interacts with Android and I've found a couple of issues.

First:

if (isAndroid() && !navigator.userAgent.match(/Firefox/)) {

This assumes that all Android browsers other than Firefox handle Intent-style links properly, but this doesn't seem to be the case. For example, in my testing Opera will launch an installed app from an Intent-style URI, but won't properly use either the browser or app-store fallback. So if the app isn't installed, Opera just breaks with a "protocol not supported" page when using Intents. I suspect the right approach is to change this to a positive match with Chrome, rather than a negative match with Firefox.

Second:

var iframe = document.createElement("iframe");
iframe.onload = function() {
    clearTimeout(timeout);
    iframe.parentNode.removeChild(iframe);
    window.location.href = uri;
};

The purpose of this section seems muddy. The iframe.onload handler only ever triggers when the iframe loads a "not supported" error page (and that only on some browsers). So the next step should be to redirect to the store. But instead you're redirecting to the same URI that just failed to load in the iframe.

This actually works in many cases, but sort of by accident. In the newest versions of Chrome, the Intent URI set in the iframe works, and the onload never fires. This is only in the case of a direct click, though... if the redirect happens during page load Chrome usually (although not always) interprets this as not being a "user gesture" and blocks the iframe app launch without firing the iframe onload. It ends up falling back to the timeout to redirect to the store, but that's not ideal since the Intent fallback is instant.

In medium-aged versions of Chrome (~19-40ish, which includes the vendor-specific browsers in many popular modern phones) the iframe load fails immediately and fires the onload, which redirects the window to the failed URI. But these versions of Chrome only fail in the iframe, so once you set the window location to the same thing, the regular Intent behavior kicks in and everything appears to work. So it works, but by accident.

In Firefox the onload is never fired, so this section is being ignored when the app isn't installed, and the timeout is catching it.

This does fail in non-Chrome/FF browsers though. Because when the URI is not Intent-based then this code basically says "if the iframe loads a 'not supported' page, set the window location to this thing we know is not supported". This is guaranteed to break execution and prevent the timeout ever firing. Instead you'd need to set the window to the store link in the onload handler.

But that brings me to the third problem. Once you fix the purpose of the onload handler for non-Chrome browsers to redirect to the store, you then break Chrome 19-40 which refuse to load the Intent URI in the iframe, and are relying on the onload handler to bounce the URI up to the top level for ALL cases, installed and not installed. To fix this you need to either make the iframe redirect conditional (URI if Intents, store link if not Intents) or avoid the iframe approach with Chrome entirely. I'm partial to the second, as it seems to play better with non-user-click cases as noted above.

Finally, it's worth noting that FF doesn't appear to halt script execution when the app is launched, so you need to use a visibilitychange handler or a polling loop on document["hidden"] to detect when it's been backgrounded instead. As it is, it just launches the store every time, even when the app launches successfully.

All together this would take a pretty big overhaul of the script, so I wanted to run it past you in an issue and see what you think.

Not working with iOS

I've added this script in web page. When URL opens in Android Device it's working fine. But it is not working iOS device it redirects to APP store..

iframe and firefox on android

Hi Hampus,

I found bug with firefox on android. When user click to link with installed app he got forced redirect to android market. I think it's happend bc iframe.onload event not working correct in ff.

I haven't found a solution yet. What do you think about it?

P.S. bug is reproduced in firefox version 36+

Not working on load event in some case and in some scenario opening both.

Below is my code trying to work with onload event but gives me error in some case so I also try the same with click event as per given in example. I am attaching a screenshot or every cases and result. Please find it and can you please help me to run this.

2017-01-18_2014

<script src="~/Scripts/browser-deeplink.js" type="text/javascript"></script>
<script type="text/javascript">
deeplink.setup({
iOS: {
appId: "333903271",
appName: "twitter",
},
android: {
appId: "com.twitter.android"
}
});
window.onload = function () {
deeplink.open("twitter://user?screen_name=TimSeverien");
}
function clickHandler(uri) {
deeplink.open(uri);
return false;
}
</script>

<body>
<a href="#" data-uri="twitter://user?screen_name=TimSeverien" onclick="clickHandler(this.dataset.uri)">open</a>
</body>

how to check if app installed on device

hi there this plugin opening app store if the app installed or not installed we need to open the app insted of open app store if the application is installed on our device

please advice

callback if going to appstore

Is it possible to have custom code if app is not installed and going to the appstore?

This would be useful for deferred deep-link, etc.

Using intent:// URLs on Android always leads to opening the Play Store

As far as I understood browser-deeplink it is supposed to stay on that website if they corresponding app is not installed. But since on Android it will transform the deepening into an intent url, it will actually always open the Google Play Store App as it's apparently listing to those URLs.

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.