Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/230.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
Javascript 社交共享插件在爱奥尼亚科尔多瓦不起作用_Javascript_Android_Ionic Framework_Cordova Plugins_Socialshare - Fatal编程技术网

Javascript 社交共享插件在爱奥尼亚科尔多瓦不起作用

Javascript 社交共享插件在爱奥尼亚科尔多瓦不起作用,javascript,android,ionic-framework,cordova-plugins,socialshare,Javascript,Android,Ionic Framework,Cordova Plugins,Socialshare,我已经在我的Ionic应用程序中为ngCordova安装了社交共享插件 cordova plugin add https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin.git 我已经在我的应用程序中实现了它,如说明所示 但它在控制台中显示了“未定义的社会共享”错误。 我还为android构建了它,并尝试在我的设备上以调试模式运行,但它仍然显示了webview的相同错误 有人知道为什么这不起作用吗 index.html <

我已经在我的Ionic应用程序中为ngCordova安装了社交共享插件

cordova plugin add https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin.git
我已经在我的应用程序中实现了它,如说明所示

但它在控制台中显示了“未定义的社会共享”错误。 我还为android构建了它,并尝试在我的设备上以调试模式运行,但它仍然显示了webview的相同错误

有人知道为什么这不起作用吗

index.html

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <title></title>

    <link rel="manifest" href="manifest.json">

    <!-- un-comment this code to enable service worker
    <script>
      if ('serviceWorker' in navigator) {
        navigator.serviceWorker.register('service-worker.js')
          .then(() => console.log('service worker installed'))
          .catch(err => console.log('Error', err));
      }
    </script>-->

    <link href="lib/ionic/css/ionic.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">

    <!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
    <link href="css/ionic.app.css" rel="stylesheet">
    -->

    <!-- ionic/angularjs js -->
    <script src="lib/ionic/js/ionic.bundle.js"></script>

    <!-- cordova script (this will be a 404 during development) -->
   <script src="lib/ngCordova/dist/ng-cordova.js"></script> 
<!--     <script src="js/cordova.js"></script>
 -->
    <!-- your app's js -->
    <script src="js/app.js"></script>
    <script src="js/controllers.js"></script>
    <script src="http://maps.google.com/maps/api/js?key=AIzaSyCQsTMbMnnBg8qbneW1oY4PEzN12gEF25M&sensor=true"></script>
    <script src= "https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.17.1/moment.min.js"></script>
  </head>

  <body ng-app="starter">
    <ion-nav-view></ion-nav-view>
  </body>
</html>
控制器

angular.module('starter.controllers',[])
.controller('Social', ['$scope', function($scope){
    $scope.share = function(t, msg, img, link){  
        if(t == 'w')
            window.plugins.socialsharing
            .shareViaWhatsApp(msg, '', link);
        else if(t == 'f')
            window.plugins.socialsharing
            .shareViaFacebook(msg, img, link);    
        else if(t == 't')
            window.plugins.socialsharing
            .shareViaTwitter(msg, img, link);    
        else if(t == 'sms')
            window.plugins.socialsharing
            .shareViaSMS(msg+' '+img+' '+link);    
        else
        {
            var sub = 'Beautiful images inside ..';
            window.plugins.socialsharing
            .shareViaEmail(msg, sub, '');        
        }    
    }
}])
这就是问题所在:

<!--     <script src="js/cordova.js"></script>
 -->

Cordova已被注释掉,因此从未加载。如中所述,您需要具备以下条件:

<script src="lib/ngCordova/dist/ng-cordova.js"></script>
<script src="cordova.js"></script>

这就是问题所在:

<!--     <script src="js/cordova.js"></script>
 -->

Cordova已被注释掉,因此从未加载。如中所述,您需要具备以下条件:

<script src="lib/ngCordova/dist/ng-cordova.js"></script>
<script src="cordova.js"></script>

您必须在config.xml中手动添加几行。请参阅


我认为这很有帮助。

您必须在config.xml中手动添加几行。请参阅


我认为这很有帮助。

你可以在js中包含你的代码来调用问题中添加的plugincode吗?我想cordova.js文件不见了。你在哪里使用social controller。你应该在设备就绪功能中或加载后使用window.plugins.socialsharing。你可以在js中包含调用问题中添加的plugincode的代码吗?我猜cordova.js文件丢失了。你在哪里使用social controller。您应该在设备就绪功能或加载后使用window.plugins.socialsharing。