【问题标题】:branch.io deeplink not working as expected in ionic 3在 ionic 3 中,branch.io deeplink 无法按预期工作
【发布时间】:2018-04-05 10:34:08
【问题描述】:

我在我的 ionic 3 应用程序中集成了 branch.io 深层链接。我已成功生成链接,链接打开了应用程序。但是,我想打开一个特定的页面而不是应用程序的主页。

所以,我将以下代码集成到所需的页面:

  dl(){
      // only on devices
      if (!this.platform.is('cordova')) { return }
      const Branch = window['Branch'];

        //only canonicalIdentifier is required
        let properties = {
          canonicalIdentifier: 'content/123',
          canonicalUrl: 'https://example.com/content/123',
          title: 'Content 123 Title',
          contentDescription: 'Content 123 Description ' + Date.now(),
          price: 12.12,
          currency: 'GBD',
          contentIndexingMode: 'private',
          contentMetadata: {
            custom: 'data',
            testing: 123,
            this_is: true
          }
        }
              //create a branchUniversalObj variable to reference with other Branch methods
        let branchUniversalObj = null
        Branch.createBranchUniversalObject(properties).then(function (res) {
          branchUniversalObj = res
          //alert(JSON.stringify(res));          
          // optional fields

        }).catch(function (err) {
          alert('Error: ' + JSON.stringify(err))
        })



        let message = 'Check out this link'

        Branch.initSession(function(data) {
          if (data['+clicked_branch_link']) {
            // read deep link data on click
            alert('Deep Link Data: ' + JSON.stringify(data))
          }
        }).then(function(res) {
          // create deep link
          var analytics = { 
            channel: Date.now() 
          }
          var properties = {}
          branchUniversalObj.generateShortUrl(analytics, properties).then(function (res) {
            alert('Response: ' + JSON.stringify(res.url))


          }).catch(function (err) {
            alert('Error: ' + JSON.stringify(err))
          })

          branchUniversalObj.onLinkShareResponse(function (res) {
            alert('Goosebumps:'  + JSON.stringify(res))
          })
        });




  }

我将该功能添加到按钮单击中。但是,当我点击创建的链接时,它仍然会打开应用主页。

【问题讨论】:

    标签: ionic-framework ionic3 deep-linking branch.io


    【解决方案1】:

    您的深层链接路由设置似乎不正确。请参考此分支文档以获得最佳结果:https://docs.branch.io/pages/deep-linking/routing/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-09-22
      • 2018-06-11
      • 1970-01-01
      • 2019-04-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多