您的位置:首页 > 移动开发 > 微信开发

微信或QQ分享跳转到APP指定页面

2018-06-01 11:02 886 查看
分享链接通过浏览器跳转到APP页面
iOS分享通过safari浏览器实现都是按照URL Scheme,但是在QQ或者微信就无法实现,原因是QQ、微信将这种唤醒app的方式给禁止掉了,
因此这种方式就不可以再被使用,如果需求仍然需要就要换一种方式了
在iOS9以后苹果提供Universal Links
官方文档原话的意思:
When you support universal links, iOS users can tap a link to your website and get seamlessly redirected to your installed app without going through Safari. If your app isn’t installed, tapping a link to your website opens your website in Safari.
就是不通过safari也可以跳转到自己的app
以下是步骤:
1.如何配置Universal Links
Create an apple-app-site-association file that contains JSON data about the URLs that your app can handle.
Upload the apple-app-site-association file to your HTTPS web server. You can place the file at the root of your server or in the .well-known subdirectory.
Prepare your app to handle universal links.
首先需要创建apple-app-site-association的文件,注意这里不是.json文件
{
    “applinks”: {
        “apps”: [],
        “details”: [
            {
                “appID”: “9JA89QQLNQ.com.apple.wwdc”,
                “paths”: [ “/wwdc/news/”, “/videos/wwdc/2015/*”]
            },
            {
                “appID”: “ABCD1234.com.apple.wwdc”,
                “paths”: [ “*” ]
            }
        ]
    }
}
paths如果是第二个是没有限制的,如果选取第一个则是需要限制的路径
appID是由teamID。bundleId的形式,teamID在账号设置里面找,每个账号都有一个唯一的teamID
2.验证apple-app-site-association 苹果又验证网站https://search.developer.apple.com/appsearch-validation-tool/ 
3.app IDS配置
开启associate domains 并且更新相应的证书
4.app只需要在Capablities下打开并且增加指定的域名
这里需要特别注意的是:打开页面的域名和提供苹果访问apple-app-site-association的域名以及项目配置的域名要保持一致,但是分享页面的域名不可和该域名保持一致,也就是需要跨域访问


代码
-(BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler
{
    return YES;
}
如何在url里取参数,这时候需要通过userActivity获取url然后进行对比
</div>
阅读更多
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐