Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/223.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 以Cordova/Ionic格式接收Url_Android_Cordova_Typescript_Ionic2_Cordova Plugins - Fatal编程技术网

Android 以Cordova/Ionic格式接收Url

Android 以Cordova/Ionic格式接收Url,android,cordova,typescript,ionic2,cordova-plugins,Android,Cordova,Typescript,Ionic2,Cordova Plugins,我想在我的cordova应用程序中接收来自facebooks或youtube等其他应用程序的url。我认为: 我安装插件,然后编写这段代码 window.plugins.webintent.hasExtra(window.plugins.webintent.EXTRA_TEXT, function(url) { // url is the value of EXTRA_TEXT }, function() { // Something re

我想在我的cordova应用程序中接收来自facebooks或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与typescript结合使用 我有一些问题: 第一:我把这段代码放在哪里?放在方法中?放在构造函数中? 第二:我有这个错误->属性插件在类型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)
    });
  })
}

根据文档,如果您使用了ionic native

import {WebIntent} from 'ionic-native';

WebIntent.hasExtra(WebIntent.EXTRA_TEXT).then(onSuccess, onError);
以后你可以用它

platform.ready().then(() => {
//use plugin
})

你在哪里用它?我的帖子中的代码只有在启动时才工作,他在控制台中打印false。如果我试图重新共享它不起作用,我的控制台中没有任何东西将代码放入我家的构造函数中是正确的。ts?不,没有任何改变。ionic2中有一个使用typescript的工作示例?我到处都搜索过!!我也没什么主意了..看看这里关于自定义url方案的部分看起来像是你在找的东西你还在找错误吗?不,我没有错误,但是,当我在youtube上点击共享按钮时,我的应用程序不在列表中。我可以告诉你是否放入了一些代码。我添加了结构,你需要首先启动活动
WebIntent.startActivity({action:any,url:string})。然后().catch()