ain / smartbanner.js

Customisable smart app banners for iOS and Android
https://npmjs.com/package/smartbanner.js
GNU General Public License v3.0
609 stars 178 forks source link

Add capability to open app or redirect to AppStore #72

Open victorjspinto opened 6 years ago

victorjspinto commented 6 years ago

Hello!!

Nice project that you have here!

I would like to improve this project with a simple snipet that detect that app is already installed and redirect to it or app wans't installed and redirect to app store.

It could improve the user experience =D

Here are the proposal:

iOS

When smartbanner opens on iOS, the following snippet may apply:

var ifrm = document.getElementById("innerFrame");
function redirect_to_store() {
  if (!document.hidden) {
    window.location.href = store_link;
  }
}
try {
  ifrm.src = app_link;
} catch (e) {
  window.location.href = store_link;
}
setTimeout (redirect_to_store, 1000);

Android

On android, we can use something called Intent Links. Here is a post with better explanation.

https://developer.chrome.com/multidevice/android/intents

We can define some metas with data needed and i can made an PullRequest =)

Hope i can help :)

ain commented 6 years ago

Thanks for the ticket @victorjspinto!

Interesting proposition. During the creation of smartbanner.js I dont think Android intents were there for us to use, but it definitely sounds good. If you're willing to put in the work, I'd love to merge it.

Few things for you to consider when submitting the PR:

ain commented 6 years ago

If we need a breaking change, we could also bump to 2.0.0. I think this feature would be big enough to go up one major version anyway.

ryuran commented 6 years ago

Hello @victorjspinto , @ain Do you have a branch somewhere to test or give some help ?

cAstraea commented 5 years ago

Is it possible to know if the app is installed and say open instead of view ?

ain commented 5 years ago

@cAstraea currently not, but as you see from the above exchange, @victorjspinto had a rough idea how this could be implemented for iOS.

I'd be more than glad to work on a Pull Request if some of you can jump start the work needed.

Hanzofm commented 3 years ago

Hi @ain It is currently possible to detect if is app installed then redirect to it or its planning to implement it?

ain commented 3 years ago

@Hanzofm time has moved on since this discussion was originally opened and things have changed. Which of course also reveals how high maintenance such a feature would be.

There are scenarios for both Android and iOS that could deliver the feature. PR is welcome!