美文网首页
iOS 微信 解决两次跳转

iOS 微信 解决两次跳转

作者: 一抹风情 | 来源:发表于2020-11-17 09:22 被阅读0次

    iOS Associated Domains 和 微信SDK 的升级 1.8.6 以上,导致旧版本登录分享出现跳转两次的问题,网上大多数写的不够简单易懂,今天根据自己的经验来写写:

    假设域名是:https://xxx.com 你要匹配的是:https://xxx.com/app/link/

    1、进入苹果开发者中心:如图-1

    • 选择 Certificates, Identifiers & Profiles

      图-1.png
    • 选择 Identifiers, 右侧找到APP 对应 Identifier,点击进入,找到Associated Domains,勾选。如图-2、图-3

      图-2.png
    图-3.png

    2、 进入微信开发者平台 ,微信开发者 Universal Link 填写:https://xxx.com/app/link/
    3、 在你关联的域根目录下(域名:https://xxx.com), 创建 apple-app-site-association 文件,文件格式参照https://developer.apple.com/documentation/safariservices/supporting_associated_domains 这里我们使用:{"applinks":{"apps":[],"details":[{"appID":"teamID.bundleID","paths":["/app/link/*"]}]}}
    4、 Xcode 的 Associated Domains 添加 applinks:xxx.com (applinks:域名)
    5、 在代码中写你的登录、分享方法即可。(首次还是会跳两次,第二次就不会了)

    注意:

    • 可使用 checkUniversalLinkReady 调试,调试好了要移除代码
      //调用自检函数
      [WXApi checkUniversalLinkReady:^(WXULCheckStep step, WXCheckULStepResult* result) {
      NSLog(@"%@, %u, %@, %@", @(step), result.success, result.errorInfo, result.suggestion);
      }];
      WXULCheckStep值说明:
    • step = WXULCheckStepParams: 参数检查
    • step = WXULCheckStepSystemVersion: 当前系统版本检查
    • step = WXULCheckStepWechatVersion: 微信客户端版本检查
    • step = WXULCheckStepSDKInnerOperation: 微信SDK内部操作检查
    • step = WXULCheckStepLaunchWechat: App拉起微信检查
    • step = WXULCheckStepBackToCurrentApp: 由微信返回当前App检查
    • step = WXULCheckStepFinal: 最终检查

    可参考: https://developers.weixin.qq.com/doc/oplatform/Mobile_App/Access_Guide/iOS.html

    希望对您有所帮助,如果有用的话,劳烦您顺手给个赞!

    相关文章

      网友评论

          本文标题:iOS 微信 解决两次跳转

          本文链接:https://www.haomeiwen.com/subject/pglfmktx.html