无法获取新AppLinks工作在iOS或Android [英] Cannot get the new AppLinks to work on iOS or Android

查看:601
本文介绍了无法获取新AppLinks工作在iOS或Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现AppLinks为我的两个iOS和Android的应用程序: http://applinks.org

I'm trying to implement AppLinks for BOTH my iOS AND Android apps : http://applinks.org

我已经做了以下内容:

  1. 设置为我的应用程序自定义URL方案:inacho://
  2. 安装在我的应用程序的委托: - (BOOL)申请:(的UIApplication *)应用程序的OpenURL:(NSURL *)网址sourceApplication:(的NSString *)sourceApplication注释:(ID)注释
  3. 添加meta标签到我的网站: http://www.nachorater.com
  1. setup a custom url scheme for my app: inacho://
  2. Setup in my App Delegate: - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
  3. Add meta tags to my website at http://www.nachorater.com :

<meta property="al:ios:app_store_id" content="581815579"/>
<meta property="al:ios:app_name" content="iNacho" />
<meta property="al:ios:url" content="inacho://default" />

我已验证的URL方案的伟大工程,通过键入类似inacho链接://默认为注释,点击它会创建的链接。 WA-LA!它会打开我的应用程序。

I've verified that the url scheme works great by typing in a link like inacho://default into Notes and clicking the link it creates. Wa-la! It opens my app.

但是,当我尝试点击来自Facebook或妙语链接到www.nachorater.com,无论是应用程序自动似乎采取的站点有这些应用程序的链接设置任何通知,它只是加载网页在浏览器(S)而不是试图打开我的应用程序。

But when I try clicking on a link to www.nachorater.com from Facebook or Quip, neither app automatically seems to take any notice that the site has these app links setup and it just loads the website in their browser(s) instead of trying to open my app.

有没有人有这方面的工作?

Has anyone got this working?

我有一个问题与一些meta标签未中的&lt内;头>我的模板部分,我固定它。

I had an issue with some meta tags not being in the < head > portion of my templates and I fixed it.

现在的链接: http://www.nachorater.com 从iOS Facebook应用程序增加了一个可爱的小弹出,让你打开网址在iNacho应用程序像这样:

Now the link: http://www.nachorater.com from the iOS Facebook app adds a nice little popup that lets you open the url in the iNacho app like so:

但我的链接,我的动态评价似乎并没有奏效,但调试应用程序,明指出表明meta标签看起来正确它们。

But my links to my dynamic reviews do not seem to be working, yet the Debug app that Ming pointed out shows that the meta tags look correct for them.

例如,<一个href="http://www.nachorater.com/getReview?reviewID=6396169718595584">http://www.nachorater.com/getReview?reviewID=6396169718595584

在调试的时候用<一个meta标签href="https://developers.facebook.com/tools/debug/og/object?q=http%3A%2F%2Fwww.nachorater.com%2FgetReview%3FreviewID%3D6396169718595584">https://developers.facebook.com/tools/debug/og/object?q=http%3A%2F%2Fwww.nachorater.com%2FgetReview%3FreviewID%3D6396169718595584

我发布了一个新纳乔回顾链接到我的iNacho Facebook的时间线,然后试着点击它从Facebook的移动应用程序。

I posted a new nacho review link to my iNacho Facebook timeline and then tried to click on it from the Facebook Mobile app.

它开始加载页面和弹出方便的指标,可以让你在iNacho打开应用程序,但随后一次加载页面时,指示灯就走了(之前,我可以单击它)。

It started to load the page and popped up the handy indicator that lets you open the app in iNacho but then once the page loaded, the indicator went away (before I could click it).

从Facebook的应用程序,我现在就可以触发inacho网址为我的评论,但它只有当我点击小弹出在iNacho它消失之前打开。如果我让页面完全加载Facebook的内置Web视图,小弹出消失还在。

From the Facebook app, I can now trigger an inacho URL for my reviews BUT it's ONLY if I click the little popup to open in iNacho before it disappears. If I let the page completely load in Facebook's built-in web view, the little popup disappears still.

这是与Applinks有问题?或者与Facebook的应用程序有问题?或者通过设计,为什么?

Is this a problem with Applinks? Or a problem with the Facebook app? Or by design and why?

我知道是什么问题。在浏览页面依次加载了对纳乔评审动态图像。所以通过加载网页,它具有指向一个动态链接加载该图象的一个IMG SRC标记。难道这被误认为是某种形式的重定向行动?

I may know what the problem is. The review page in turn loads up a dynamic image for the nacho review. So by loading the page, it has an img src tag that points to a dynamic url that loads the image. Is this being mistaken for a 'redirect' action of some sort?

img标签(渲染)的例子:&LT; IMG WIDTH =300SRC =/?getReviewImage imageID = 6125868501958656&GT;&LT; / IMG&GT;

Example of img tag (rendered): <img width="300" src="/getReviewImage?imageID=6125868501958656"></img>

请注意:现在有很多其他的脚本/ AJAX是被加载动态过,但(Facebook和Twitter的小部件等)

Note: There are a bunch of other scripts/ajax that gets loaded dynamically too though (Facebook and twitter widgets and the like).

这是AppLinks或Facebook的移动应用程序中的错误?难道不应该不关心如AJAX和动态画面?后台加载对象

14年7月15日 - 这是仍然发生与最新的Facebook应用程序。当我点击从我iNacho Facebook页面链接到我的iNacho的网站,它弹出来的应用程序打开的一瞬间页面加载完成前一秒的选项。然后,它隐藏它。

7/15/14 - This is still happening with latest Facebook app. When I click a link from my iNacho Facebook page to my iNacho website, it pops up the option to open it in the app for a split second before the page finishes loading. Then it hides it.

对于Twitter的应用程序,它甚至不给我弹出的一瞬间。它似乎并没有认识到链路appslink都启用。

As for the twitter app, it does not even give me the popup for a split second. It doesn't seem to recognize the link is appslink enabled at all.

讽刺,另一方面,我粘贴一个纳乔链接和我第一次点击它,它去到其内置的Safari浏览器,没有选择在我的应用程序打开。但第二次我点击它,它直接打开我的应用程序,而不是。

Quip on the other hand, I pasted a nacho link in and the first time I clicked on it, it went to its built-in safari with no option to open in my app. BUT the second time I clicked it, it directly opened my app instead.

摘要:到目前为止,似乎或许有些应用程序不正确或东西实施AppLinks导航部分。妙语似乎工作,但即使是Facebook的自己的应用程序好像它不工作。

Summary: So far, it seems like maybe some apps are implementing the AppLinks Navigation portion incorrectly or something. Quip seems to work but even Facebook's own app seems like it's not working.

推荐答案

我有同样的问题与AppLinks,并决定只完全放弃它们,只需使用Facebook的应用程序的链接主机:<一href="https://developers.facebook.com/docs/applinks/hosting-api">https://developers.facebook.com/docs/applinks/hosting-api

I was having the same problem with AppLinks and decided to just forego them altogether and just use facebook's app link host: https://developers.facebook.com/docs/applinks/hosting-api

我的应用程序是真正的手机而已,我误解了如何AppLinks在第一次担任。我想我可以把 al_ios _ * meta标签的单一,通用的网页上,但这是错误的。那里将需要为每一条内容我的网站上一个单独的页面,并且这些页中的每一个都需要有其自身的AppLinks元标记该特定内容发送URL回我的应用程序

My app is really mobile only, and I misunderstood how AppLinks worked at first. I thought I could just put the al_ios_* meta tags on a single, universal web page but this is wrong. There would need to be a separate page for every piece of content on my site, and each one of those pages needs to have its own AppLinks meta tags to send a URL for that specific content back to my app.

当我做错了,我在facebook的拍了拍我的OpenGraph的故事,它会在Web浏览器中打开我的网站,并有底部工具栏上的操作图标,我可以挖掘和必须打开选项我应用程序。或者我将不得不precision抽头我在OpenGraph故事的应用程序的名称。无论是那些快速切换到我的应用程序,但是URL不会具体到我想我的应用程序导航到的内容。另外,无论这些选择吸 - 我只是想在任何地方挖掘的故事,直接进入我的应用程序,这就是为什么我们都在这里

When I was doing it wrong, when I tapped on my OpenGraph story in facebook, it would open my site in the web browser and there was an action icon in the bottom toolbar that I could tap and have the option to open my app. Or I would have to precision-tap the name of my app in the OpenGraph story. Either of those fast-switch to my app, but the URL would not be specific to the content I want my app to navigate to. Also, both of those options suck -- I just want to tap anywhere on the story and go straight to my app, which is why we're all here.

解决方案

我要使用OpenGraph故事作为例子共享对话框。

I am going to use an OpenGraph story with the share dialog as an example.

首先,你需要在你的服务器上创建一个托管应用程序链接的,而不是在应用程序。在创建您的OpenGraph故事,或任何被共享,拨打电话到你的服务器来完成两件事情

First, you need to create a hosted app link on your server, not in the app. Before creating your OpenGraph story or whatever is being shared, make a call to your server to accomplish 2 things:

1)调用API来创建一个新的Facebook应用程序的链接,这会给你回一个ID

1.) Make an API call to create a new facebook app link, which will give you back an ID

2)使用这个ID来进行第2次的API调用来获取URL到您的托管应用程序的链接

2.) Use that ID to make a 2nd API call to get the URL to your hosted app link

这已经在服务器上完成,因为这些API调用需要应用访问标记,而不是用户的访问令牌。此令牌的应用程序级别的权限,而不是用户级权限。你不能,不应该在任何地方存放你的Facebook应用程序的秘密您的移动应用程序,因为有人可以反编译你的应用程序并更改你的Facebook应用程序。不好。使用你的服务器,因为它可以安全地了解你的应用程序的秘密。

This has to be done on the server because these API calls require an app access token, not a user access token. This token has app level permissions, not user level permissions. You cannot and should not store your facebook app secret anywhere in your mobile application because someone could decompile your app and make changes to your facebook app. No good. Use your server because it can safely know your app secret.

我的服务器端是PHP所以这里是如何做到这一点的一个例子。与API处理是不是一个特别愉快的经历,所以我会分享,希望它可以帮助别人与格式的要求:

My server side is in PHP so here is an example of how to accomplish this. Dealing with the API wasn't a particularly pleasant experience, so I'll share in hopes that it helps someone else with formatting the requests:

# create a new facebook app link using cURL
$metadata = <what to handle in AppDelegate application:openURL:sourceApplication:annotation>;
$url = "https://graph.facebook.com/v2.1/app/app_link_hosts";
$ch = curl_init($url);

# create form post data
$deepLinkURL = "<myApp>://" . $metadata;
$iosArray = json_encode(array(array("url"          => $deepLinkURL,
                                    "app_store_id" => <appStoreId (number)>,
                                    "app_name"     => "<myAppName>")
                              )
                       );
$webFallbackArray = json_encode(array("should_fallback" => false));

$formQuery = http_build_query(array("access_token" => "<appId>|<appSecret>",
                                    "name"         => $metadata,
                                    "ios"          => $iosArray,
                                    "web"          => $webFallbackArray)
                              );

# options
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $formQuery);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

# get response
$responseJson = curl_exec($ch);
curl_close($ch);

# decode response from facebook
$jsonResponse = json_decode($responseJson, true);
$appLinkId = "";

# get appLinkId
foreach ($jsonResponse as $key => $val) {

    # get status
    if($key == "id") {
        $appLinkId = $val;
    }
}

# if response is good, need to request canonical URL from appLinkId
$errorMessage = "";
$canonicalUrl = "";

if(!empty($appLinkId)) {

    # create another instance of cURL to get the appLink object from facebook using the ID generated by the previous post request
    $getAppLinkUrl = "https://graph.facebook.com/" . $appLinkId;
    $ch2 = curl_init();

    # cURL options
    $queryString = http_build_query(array("access_token" => "<appId>|<appSecret>",
                                          "fields"       => "canonical_url",
                                          "pretty"       => true)
                                    );
    curl_setopt($ch2, CURLOPT_URL, $getAppLinkUrl . "?" . $queryString);
    curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);

    # get response
    $urlResponseJson = curl_exec($ch2);
    curl_close($ch2);

    # decode response from facebook
    $urlJsonResponse = json_decode($urlResponseJson, true);

    # parse response to get canonical URL
    foreach ($urlJsonResponse as $key => $val) {
        # get canonical URL
        if($key == "canonical_url") {
            $canonicalUrl = $val;
        }
    }

    # check for result
    if(empty($canonicalUrl)) {
        $errorMessage = "Unable to retreive URL.";
    }

} else {
    $errorMessage = "Unable to publish appLink.";
}

# encode response back to your app
if(empty($errorMessage)) {
    $response = json_encode(array("result"        => "success",
                                  "canonical_url" => $canonicalUrl));
} else {
    $response = json_encode(array("result" => "failed",
                                  "errorMessage" => $errorMessage));
}

#send response back to your app

回到您的应用程序,一旦你确定了良好的反响,把你回来的网​​址参数 [FBGraphObject openGraphObjectForPostWithType规范网址: 下面。现在,当你在Facebook应用程序点击你的故事,它会直接进入你的应用程序。没有Web废话。

Back in your app, once you confirm a good response, put the canonical URL you get back as the url parameter in [FBGraphObject openGraphObjectForPostWithType: below. Now when you click on your story in the facebook app, it will go straight to your app. No web nonsense.

// Create an action
id<FBOpenGraphAction> action = (id<FBOpenGraphAction>)[FBGraphObject graphObject];

// Create an object
id<FBGraphObject> object;

// set shareDialog parameters
FBOpenGraphActionParams *params = [[FBOpenGraphActionParams alloc] init];
params.action = action;
params.actionType = @"<myApp>:<myAction>";
params.previewPropertyName = @"<key>";
object = [FBGraphObject openGraphObjectForPostWithType:@"<myApp>:<myObject>"
                                                 title:<title>
                                                 image:<urlToPic>
                                                   url:<fb.me/xyz canonical URL>
                                           description:<someDescription>];

[action setObject:object forKey:@"<key>"];

etc...

这篇关于无法获取新AppLinks工作在iOS或Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆