Receive Url in Cordova/Ionic



我想在我的Cordova应用程序中从其他应用程序或YouTube等其他应用程序中接收一个URL。我查看此信息:

  • 文档
  • 插件

我安装插件,然后写这件代码。

window.plugins.webintent.hasExtra(window.plugins.webintent.EXTRA_TEXT,
    function(url) {
        // url is the value of EXTRA_TEXT
    }, function() {
        // Something really bad happened.
    }
);

我将Cordova/ionic与打字稿一起使用我有一个问题:首先:我将此代码放在哪里?用方法?在构造函数中?第二:我有这个错误 ->属性插件在类型Windows

上不存在

编辑:这是构造函数

    constructor(public navCtrl: NavController,platform: Platform) {
    platform.ready().then(() => {
      WebIntent.hasExtra(WebIntent.EXTRA_TEXT).then(
        function(url) {
    console.log("succes" + url);
  }, function(url) {
      console.log("error" + url)
    });
  })
}

如果您使用了离子本,则根据文档

import {WebIntent} from 'ionic-native';
WebIntent.hasExtra(WebIntent.EXTRA_TEXT).then(onSuccess, onError);

您可以在

之后使用它
platform.ready().then(() => {
//use plugin
})