Titanium - Android: Intent - getData(), getAction() 始终等于 nul



当我为我的项目使用深层链接并尝试访问Ti.Android.currentActivity.getIntent().getData()时,它总是返回Ti SDK 6.2.0及以上版本的null,但是如果我将SDK降级到6.1.2,那么它工作正常。它无法从传入的意向中读取数据。

重现步骤:

  1. 创建新的合金应用程序并使用以下测试代码
  2. 在任何安卓设备上安装该应用程序。
  3. 转到浏览器并浏览以链接app name://videoURL
  4. 它将打开应用程序,但getData()始终为空,但它应返回一个 URL

预期结果: 从深层链接打开应用时,它应返回 URL。

以下是测试代码:

合金.js:

Alloy.Globals.getDeepLinkURL = function() {
    Alloy.Globals.deepLinkURLAndroid =Ti.Android.currentActivity.getIntent().getData();
    console.log("Alloy.Globals.deepLinkURLAndroid");
    console.log(Alloy.Globals.deepLinkURLAndroid);
    console.log(Ti.Android.currentActivity.getIntent());
};

在索引中.js:

$.index.addEventListener('open',function(){
    if(OS_ANDROID){
        Alloy.Globals.getDeepLinkURL();
    }
});
Ti.Android.currentActivity.addEventListener('newintent', function (e) {
    var data = e.intent.getData();
    alert(`data: ${data}`);
});

返回数据,但此代码仅适用于索引.js文件

最新更新