简体   繁体   English

配置 apple-app-site-association 文件并上传到服务器

[英]Configure apple-app-site-association file and upload on server

I am new on iOS development.我是 iOS 开发的新手。 I am implementing Universal Links in iOS App with ASP.net application.我正在使用 ASP.net 应用程序在 iOS 应用程序中实现通用链接。
I have define my associate domain in capabilities under Associated Domains: applinks:www.abcd.com我在关联域下的功能中定义了我的关联域:applinks:www.abcd.com
And also configure in App Ids on Apple Developer Account.并在 Apple Developer Account 上的 App Id 中进行配置。 I think app side work is all set .我认为应用程序方面的工作已准备就绪。

But I think problem with apple-app-site-association file.但我认为 apple-app-site-association 文件有问题。

I have written json in a simple text file like below我在一个简单的文本文件中编写了 json,如下所示

{
  "applinks": {
    "apps": [],
    "details": [
    {
      "appID": "8T8932TY.com.AppName”,
      "paths": ["*"]
    }
    ]
  }
}

Now I am stuck here.现在我被困在这里。 My application targeting on iOS 9 and above.我的应用程序针对 iOS 9 及更高版本。 I am confused that what is the extension of this file with naming apple-app-site-association.我很困惑这个文件的扩展名是什么,命名为 apple-app-site-association。 If I need to signed in with new certificates or not.如果我需要使用新证书登录。 And how upload it on server side.以及如何在服务器端上传它。

Please guys help me out.请大家帮帮我。 I am searching lot for this but not get satisfactory answer.我正在为此寻找很多,但没有得到满意的答案。

Thanks谢谢

Your example JSON looks fine if substituted with real values for the AppID/AppName. 如果用AppID / AppName的实际值替换,您的示例JSON看起来很好。 You may want to be specific about what routes you handle but that's up to you - it's a better user experience to only try to handle routes that there's some chance you'll be able to handle, rather than opening your app for every link on your domain and kicking the user out to Safari again if that turns out not to be true. 您可能希望具体了解您处理的路线,但这取决于您 - 只有尝试处理您可能能够处理的路线才能获得更好的用户体验,而不是为您的每个链接打开应用程序域名并将用户再次踢出Safari,如果结果不是真的那样。

The apple-app-site-association file should not have any file extension, and should be served from the root of your site, https://example.com/apple-app-site-association , and/or from https://example.com/.well-known/apple-app-site-association . apple-app-site-association文件不应包含任何文件扩展名,应该从您网站的根目录https://example.com/apple-app-site-association和/或https://example.com/.well-known/apple-app-site-association

You say you're supporting iOS 9 and above - the change to check the .well-known route, which is checked first, came in iOS 9.3, so if you want to support below that OS, you're best off putting the file in both locations. 你说你支持iOS 9及更高版本 - 检查.well-已知路由的更改是在iOS 9.3中进行的,所以如果你想支持低于该操作系统,你最好放置文件在这两个地方。 See this answer for details. 有关详情,请参阅此答案

It's also important that the file is served with the correct MIME-type, for Universal Links it can be served as application/json , and there's no need to sign/encrypt it. 使用正确的MIME类型提供文件也很重要,对于Universal Links,它可以作为application/json ,并且不需要对其进行签名/加密。 Getting it served with the correct MIME-type can be a little annoying if you're not familiar with configuration on your web server, as typically servers will determine the MIME-type from the file extension. 如果您不熟悉Web服务器上的配置,那么使用正确的MIME类型提供服务可能会有点烦人,因为服务器通常会从文件扩展名中确定MIME类型。 You can't give it an extension, as iOS won't check the url with an extension and (IIRC) redirects are not allowed so you can't fake it by doing that either. 你不能给它一个扩展名,因为iOS不会检查带扩展名的网址,并且不允许(IIRC)重定向,所以你也不能通过这样做来伪造它。

So that's a summary of what you're trying to accomplish, but how you do that depends on the web server you're using. 这是对您要完成的内容的总结,但您如何做到这一点取决于您正在使用的Web服务器。 For an ASP app that's likely to be IIS, in which case this question and its answers may help you configure your web server correctly. 对于可能是IIS的ASP应用程序,在这种情况下, 此问题及其答案可能有助于您正确配置Web服务器。 The details of how you upload a file to the root of that server will very much depend on how you've configured it as well. 如何将文件上传到该服务器的根目录的细节在很大程度上取决于您如何配置它。

There is no extension for this apple-app-site-association file. apple-app-site-association文件没有扩展名。 This is just a plain file. 这只是一个普通的文件。 You have to host it on the top level of your domain meaning the file location will be https://www.abcd.com/apple-app-site-association Once you host it you can check/validate by using this link https://branch.io/resources/aasa-validator/ 您必须在域的顶层托管它,这意味着文件位置将为https://www.abcd.com/apple-app-site-association一旦您托管它,您可以使用此链接https检查/验证: //branch.io/resources/aasa-validator/

For detailed info please refer: https://blog.branch.io/how-to-setup-universal-links-to-deep-link-on-apple-ios-9/ 有关详细信息,请参阅: https//blog.branch.io/how-to-setup-universal-links-to-deep-link-on-apple-ios-9/

This worked for me.这对我有用。

  1. Created an empty .NET Core project and deployed it to the corresponding Azure web app service.创建了一个空的 .NET Core 项目并将其部署到相应的 Azure Web 应用服务。
  2. Using, Advanced tools in Azure portal, nvaigated to the Kudu files of the deployed app service.使用 Azure 门户中的高级工具,访问已部署应用服务的 Kudu 文件。
  3. Inside the folder "site/wwwroot/wwwroot" created a new folder named ".well-known".在文件夹“site/wwwroot/wwwroot”中创建了一个名为“.well-known”的新文件夹。
  4. Inside the newly created folder, created a new file named "apple-app-site-association.json".在新创建的文件夹中,创建了一个名为“apple-app-site-association.json”的新文件。
  5. Edited the newly created json file to hold the app details.编辑新创建的 json 文件以保存应用程序详细信息。
  6. Modifed the file "site/wwwroot/web.config" for the following reasons:修改了“site/wwwroot/web.config”文件,原因如下:

a) Since iOS always calls the URLs without file extension mentioned ( https://webapp-sftpint-employeeapp-dev.azurewebsites.net/apple-app-site-association ) we need to forcefully reqrite such URLs to have the file extension. a) 由于 iOS 总是调用没有提到文件扩展名的 URL ( https://webapp-sftpint-employeeapp-dev.azurewebsites.net/apple-app-site-association ) 我们需要强制重新编写这些 URL 以具有文件扩展名。 Hence, added the rule in web.config因此,在 web.config 中添加了规则

b) Since the response header should have "application/json" for the content returned from the static file "apple-app-site-association.json", we added the explicit mentioning of the mimeType as "application/json". b) 由于响应标头应该为静态文件“apple-app-site-association.json”返回的内容包含“application/json”,我们添加了对 mimeType 的明确提及为“application/json”。

So, the web.config file looks somewhat like this.所以,web.config 文件看起来有点像这样。 (only the 'rewrite' and 'staticContent' blocks needs to be added additionally) (仅需要额外添加 'rewrite' 和 'staticContent' 块)

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="dotnet" arguments=".\yourproject.dll" stdoutLogEnabled="false" stdoutLogFile=\\?\%home%\LogFiles\stdout hostingModel="inprocess" />
      <rewrite>
          <rules>`enter code here`
              <rule name="apple_json_file">
                  <match url="^apple-app-site-association" />
                  <action type="Rewrite" url=".well-known/apple-app-site-association.json" />
              </rule>
          </rules>
      </rewrite>
      <staticContent>
          <mimeMap fileExtension=".json" mimeType="application/json" />
      </staticContent>      
    </system.webServer>
  </location>
</configuration>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何上传文件 apple-app-site-association 以在 iOS 应用程序的服务器中进行通用链接? - How to upload file apple-app-site-association for universal linking in server for iOS app? Apple-app-site-association:横幅显示,而服务器中没有文件 - Apple-app-site-association : banner displays while no file in server apple-app-site-association文件的位置 - Location for apple-app-site-association file 如何在 ReactJS 中的 /apple-app-site-association 页面上提供 apple-app-site-association 文件 - How to serve apple-app-site-association file on /apple-app-site-association page in ReactJS 如何在第三方域 (mydomain.app.link) 中上传 AASA (apple-app-site-association) 文件 - How to Upload AASA (apple-app-site-association) file in third Party Domain (mydomain.app.link) 苹果应用站点关联文件无法为某些用户下载 - Apple-app-site-association file fails to download for certain users iOS 通用链接 apple-app-site-association 文件问题 - iOS Universal links apple-app-site-association file issue DeepLinking apple-app-site-association文件是否需要签名? - Does DeepLinking apple-app-site-association file need signing? apple-app-site-association文件格式错误 - The apple-app-site-association file format error >= 400 错误代码与 apple-app-site-association json 文件 - >= 400 error code with apple-app-site-association json file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM