我们有一个Facebook连接的游戏 - 我们有一个Facebook画布,也是ios和android的本机移动应用程序,在facebook仪表板中定义,并启用深度链接。 我们希望在我们的粉丝页面中共享一个链接,该链接将在用户点击时执行此操作:
我们知道如何从我们的脸书粉丝页面深入链接(使用Facebook?)到我们的移动应用程序?
谢谢!
答案 0 :(得分:1)
对于iOS,您可以使用url schemes将用户定向到您的应用,检查该应用是否已安装在设备上,执行此操作。
if([[UIApplication sharedApplication] canOpenURL:[NSURL urlwithString:@"YourAppsScheme"]])
{
//your app is installed on the device, open your app using
[[UIApplication sharedApplication] openURL:[NSURL urlwithString:@"YourAppsScheme"]]
}
else
{
[[UIApplication sharedApplication] openURL:[NSURL urlwithString:@"your applications itunes url"]] //
}
对于Android,您可以执行相同类型的操作但是检查设备上是否存在pacakge名称,How to check programmatically if an application is installed or not in Android?
Android的示例代码:
installed = isPackageInstalled(APPPACKAGE);
if (installed) {
Intent i;
PackageManager manager = getPackageManager();
try {
i = manager.getLaunchIntentForPackage(APPPACKAGE);
if (i == null)
throw new PackageManager.NameNotFoundException();
i.addCategory(Intent.CATEGORY_LAUNCHER);
startActivity(i);
} catch (PackageManager.NameNotFoundException e) {
}
}
else
{
// open google play app details page of your app
final String appName = ...;
try
{
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id="+appName)));
}
catch (android.content.ActivityNotFoundException anfe) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id="+appName)));
}
}
private boolean isPackageInstalled(String packagename, Context context) {
PackageManager pm = context.getPackageManager();
try {
pm.getPackageInfo(packagename, GET_ACTIVITIES);
return true;
} catch (NameNotFoundException e) {
return false;
}
}
从网页上执行此操作
<script type="text/javascript">
function startMyApp()
{
document.location = 'yourAppScheme://';
setTimeout( function()
{
if( confirm( 'You do not seem to have Your App installed, do you want to go download it now?'))
{
document.location = 'http://itunes.apple.com/us/app/yourAppId';
}
}, 300);
}
</script>