In the following code snippet, I am using angular.js
to detect the mobile platform and redirect to the native app. If the app is not installed, it will redirect to the market:
$scope.isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS: function() {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},
Opera: function() {
return navigator.userAgent.match(/Opera Mini/i);
},
Windows: function() {
return navigator.userAgent.match(/IEMobile/i);
},
any: function() {
return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
}
};
if($scope.isMobile.Android()){
$timeout(function() {
$window.open(
'https://play.google.com/store/apps/details?id=***&referrer=' + $routeParams.inviteId,
'_self'
);
}, 500);
}
if($scope.isMobile.iOS()){
window.location = '***://?referrer=' + $scope.inviteId;
setTimeout("window.location = 'https://itunes.apple.com/us/app/****/id***';", 1000);
}
Now, my question arises:
How can I achieve this functionality on the windows phone
platform?
Does the windows phone self-recognize if the app is installed like android does, or do I need a similar approach to what is done for iOS
? Also, how can I pass parameters to the application like on android?