使用cordova插件在Ionic中实现社交共享

时间:2015-05-22 11:11:18

标签: angularjs cordova ionic-framework ionic

我正试图在离子中实现社交分享。我按照本教程https://blog.nraboy.com/2014/10/implement-social-media-sharing-ionicframework/

进行了操作

我收到错误

TypeError:无法读取未定义的属性“socialsharing”

at Object.share (ng-cordova.min.js:9)
at Scope.$scope.shareAnyWhere (shareController.js:10)
at $parseFunctionCall (ionic.bundle.js:21037)
at ionic.bundle.js:53344
at Scope.$get.Scope.$eval (ionic.bundle.js:23093)
at Scope.$get.Scope.$apply (ionic.bundle.js:23192)
at HTMLButtonElement.<anonymous> (ionic.bundle.js:53343)
at HTMLButtonElement.eventHandler (ionic.bundle.js:11706)
at triggerMouseEvent (ionic.bundle.js:2863)
at tapClick (ionic.bundle.js:2852)

我已经安装了教程中提到的插件。

2 个答案:

答案 0 :(得分:2)

首先确保在cordova.js之前加入ng-cordova。然后看看工作示例here,尝试一下。

其次,确保您在真实设备或模拟器上进行测试,社交共享插件旨在用于您所定位的操作系统上的本机共享功能,它不是预期的,也不适用于浏览器。如果您使用的是浏览器,那么这就是原因!

您可以使用Ionic CLI来运行测试。

答案 1 :(得分:1)

您可以使用 window.plugins.socialsharing 对象并调用 shareViaFacebook 等函数。这在我的所有项目中都适用于我。< / p>

有关详细信息和完整代码,您可以在此处查看视频Social Sharing Plugin: Ionic App