Click to correct app store


#1

Hi there,

I tried searching for this on the forum but maybe I’m not using the correct keywords. I want this element at the end of my ad to redirect the user to their proper app store (Apple App Store or Play Store) when clicked in order to download the app. Do I need to run a specific javascript code for this or is there a tool already in Hype that can help me do this? Thank you!


#2

@jamboreebop

…or is there a tool already in Hype that can help me do this?

Will this fill the bill?


#3

No because if you read my post, this doesn’t automatically direct the user
to the correct App Store.


#4

The closest thing I could find was this: https://stackoverflow.com/questions/24464602/redirect-to-appstore-or-google-play

But I’m not so sure how to implement this into Hype.


#5

@jamboreebop

Store Selector.hype.zip (15.6 KB)

The above Hype project works with my Android (v7) phone; my “Hype Reflect” set-up & Safari for detecting my iPad.

This demo is not intended to be complete - just a starter kit.

Overview:
There are two buttons in the Scene:
One links to the “Apple Store” the other to “Google Play”; each has an ID.

The “On Scene Load” handler runs a userAgent detect script (“uAgentDetect”) and if it’s an iOS device it hides the “Google Play” button; if an Android device it hides the “Apple Store” button.

Just be aware that these kinds of scripts are only as good as the info they are checking. If “iPad” were to be replaced with some other name for the iPad device this script will not work properly for iPad detection; ditto all the others. I got the userAgent script here. This “original” userAgent script is commented out at the top of the script for reference.

/*if (/Android|webOS|iPhone|iPad|BlackBerry|Windows Phone|Opera Mini|IEMobile|Mobile/i.test(navigator.userAgent))
	alert("Mobile Device");*/

if (/iPhone|iPad/i.test(navigator.userAgent)) {
	//alert("iOS");
	document.getElementById("gPlay").style.display = "none";
} else if (/Android/i.test(navigator.userAgent)) {
	//alert("Android");
	document.getElementById("appleStore").style.display = "none";
}

#6

Thanks so much! This worked perfectly for the project.