Show correct app link to mobile users

addisonlee
Posts: 2
Joined: Thu Sep 12, 2013 5:30 am

Show correct app link to mobile users

Postby addisonlee » Thu Sep 12, 2013 6:02 am

Hi - I have a mobile app for iphone, blackberry and android. I'd like to use WURLF to detect the users OS and then print the correct URL to the app for the users operating operating system. Something like

Code: Select all

<a href="<?php echo $applink ?>">Download the <?php echo $appname ?></a>
. I can't seem to find any documentation regarding this. Can anyone help at all? I'm using Wordpress by the way. Thanks!

kamermans
Posts: 393
Joined: Mon Jun 06, 2011 9:50 am

Re: Show correct app link to mobile users

Postby kamermans » Thu Sep 12, 2013 11:37 am

You can certainly do this with WURFL. We can't really write up a full example, but this is essentially the what you would do in your page:

Code: Select all

<?php
// Create a WURFL Cloud Config
$config = new WurflCloud_Client_Config();

// Set your API Key here
$config->api_key = 'xxxxxx:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';

// Create a WURFL Cloud Client
$client = new WurflCloud_Client_Client($config, new WurflCloud_Cache_Null());

// Detect the visitor's device
$client->detectDevice();

$os = $client->getDeviceCapability('device_os');

if ($os == 'Android') {
	// Show Android app link
} else if ($os == 'iOS') {
	// Show iOS app link
}
Thanks,

Steve Kamerman
ScientiaMobile

Make sure you check out our WURFL Cloud, WURFL InSight and WURFL InFuze products!

addisonlee
Posts: 2
Joined: Thu Sep 12, 2013 5:30 am

Re: Show correct app link to mobile users

Postby addisonlee » Fri Sep 13, 2013 7:14 am

Great! Thanks for your helpful reply. If for example I wnated to include more than one OS (ie 'Windows Mobile OS' and 'Windows Phone OS') in one if statement. How do I do that?

Also, If I wanted to include a link to all unsupported devices, Do I end it with

Code: Select all

else {}
of do I use the

Code: Select all

else if ($os == 'Other Smartphone OS')
?

sm_support2
Posts: 294
Joined: Mon Jun 20, 2011 5:04 pm

Re: Show correct app link to mobile users

Postby sm_support2 » Fri Sep 13, 2013 8:20 am

The following link contains the list of all WURFL Cloud capabilities:

http://www.scientiamobile.com/wurflCapability

if you look for 'device_os' (we have a nice 'ajaxy' search field at the top), you'll find a list of all accepted values.

Thank you

kamermans
Posts: 393
Joined: Mon Jun 06, 2011 9:50 am

Re: Show correct app link to mobile users

Postby kamermans » Fri Sep 13, 2013 11:18 am

You can include more "else if" statements:

Code: Select all

if ($os == 'Android') {
   // Show Android app link
} else if ($os == 'iOS') {
   // Show iOS app link
} else if ($os == "RIM OS") {
   // Show BlackBerry app link
} else if ($os == "Windows Mobile OS" || $os == "Windows Phone OS") {
   // Show Windows app link
} else {
   // No app available
}
Thanks,

Steve Kamerman
ScientiaMobile

Make sure you check out our WURFL Cloud, WURFL InSight and WURFL InFuze products!


Who is online

Users browsing this forum: No registered users and 1 guest