swift 下 universalLink 制作配置制

发布时间:2022-06-13 23:56:26

编写universalLink,由于我们是spring boot 项目,所以会用spring mvc实现. 另外我们暂时只是使用在微信登录

1.授权

打开apple developer账号 再打开Certificates, Identifiers & Profiles 菜单,再选择Identifiers,再选择你的项目点击进去,再选中 Capabilities中的Associated Domains选项

2.再找到项目中targets中的项目,在general中添加Associated Domains并配置上相应的域名,如applinks:hudiepm.com

3.编写链接

 /**
     * 唤起ios
     * 使用@PathVariable(value="params") 是因为编号universalLink需要在配置时使用通配符* 这样才可以访问 并不会报错
     * @return
     */
    @RequestMapping(value = "/arouse/{params}", name = "唤起ios")
    public void  arouseIos(HttpServletRequest request,@PathVariable(value="params") String params) {
    	logger.error(request.getRequestURL().toString());
    	logger.error(params);
    }
    

4.配置

4.1.在网站的根目录创建一个文件夹 .well-known,由于带.的是隐藏目录 需要使用ls -a才能看到

4.2.再在里面创建一个apple-app-site-association,这个文件没有后缀,格式是json

4.3.配置(AB72NULFZC 这个值是指的team Id 在apple developer中可以找到,Membership详情中,com.xx.app这个是项目使用的包名,也就是项目中的Bundle Identifier)

"applinks" : {
         "apps" : [],
         "details" : [
             {
                 "appID" :  "AB72NULFZC.com.xx.app" ,
                 "paths" : [ "/arouse/*" ]
           }
         ]
     }
}

5.测试

5.1 首页保证上面写的RequestMapping带参可以访问成功

5.2可以在手机端的safari访问,然后下拉就会出现"打开‘xxxx’"

5.3也可以写在iphone手机的备忘录中,然后长按链接,也会有个菜单“在xxxapp”中打开


Card image cap
APP STORE
Card image cap
应用宝
Card image cap
小米
Card image cap
华为