我们如何在MobileFirst中实现添加到任何(社交网络)

时间:2014-12-19 10:28:50

标签: ibm-mobilefirst

我们如何实施添加到任何社交网络小部件以在Mobilefirst平台中分享Facebook,Twitter等中的照片。 我试过http://www.addthis.com/的插件 它正在开发公共资源预览,但在Android和Windows 8模拟器和设备中失败。

任何人都可以为MobileFirst Platform建议任何其他插件吗? 通过以下代码尝试了jquery共享,但没有工作。

$('#mydiv').share({
        networks: ['facebook','pinterest','googleplus','twitter','linkedin','tumblr','in1','email','stumbleupon','digg']
    });

 <div id="mydiv"></div>

1 个答案:

答案 0 :(得分:5)

更新:有关详细信息,请参阅此博文:https://developer.ibm.com/mobilefirstplatform/2015/08/03/integrating-3rd-party-cordova-plug-ins/

上述“插件”似乎不适合移动应用程序IMO 您可以谷歌搜索Cordova社交共享插件。

Android,iOS和Windows Phone的一个很有前途的插件是PhoneGap Social Sharing plugin

注意:您无法使用Cordova CLI安装步骤在Worklight / MobileFirst Platform中安装插件。相反,您需要遵循提供的手动说明。

在此之前,请务必阅读MFP tutorial for working with Cordova plug-ins,以便了解它在MFP中的工作原理。


我通过一些额外的调整让它在iOS上工作。

注意:

  • Android和Windows Phone 8以及各自的环境中都需要第2步
  • 在MobileFirst Studio中的每次构建之后都需要重复步骤2,因为此文件会在每次构建时被覆盖。

步骤:

  1. 有两个缺少的框架:
    • MessageUI.framework
    • Social.framework

  2. 使用额外部分更新(在Xcode中)www \ worklight \ cordova_plugins.js

     {
         "file": "../js/SocialSharing.js",
         "id": "nl.x-services.plugins.socialsharing",
         "clobbers": [
             "window.plugins.socialsharing"
         ]
     }
    

    注意: SocialSharing.js应该放在普通的\ js中,并且在index.html的HEAD元素中引用

  3. 使用

    包装整个内容来编辑SocialSharing.js
    cordova.define("nl.x-services.plugins.socialsharing", function(require, exports, module) {
        // file contents
    ); 
    
  4. 在您的HTML中,从可用的选项中选择您想要的任何共享选项(请参阅插件文档)。

  5. 最终结果:

    enter image description here