How we can implement add to any(Social networking) in MobileFirst

后端 未结 1 836
囚心锁ツ
囚心锁ツ 2021-01-06 09:33

How can we implement Add to any social network widget to share photos in facebook,twitter etc in Mobilefirst platform. I have tried the plugin from http://www.addthis.com/

相关标签:
1条回答
  • 2021-01-06 10:17

    Update: see this blog post for more information: https://developer.ibm.com/mobilefirstplatform/2015/08/03/integrating-3rd-party-cordova-plug-ins/

    The mentioned "plug-in" does not seem fitting for mobile apps IMO.
    You can google for Cordova social sharing plug-ins instead.

    One promising such plug-in for Android, iOS and Windows Phone is the PhoneGap Social Sharing plugin.

    Note: You cannot use the Cordova CLI installation steps to install the plug-in in Worklight/MobileFirst Platform. Instead, you need to follow the manual instructions that are provided.

    Before doing so it would be prudent to read the MFP tutorial for working with Cordova plug-ins so you will understand how it works in MFP.


    I got it to work on iOS with some extra tweaks.

    Note:

    • Step 2 is required for Android and Windows Phone 8 as well in their respective environment
    • Step 2 will need to be repeated after every build in MobileFirst Studio, because this file gets over-written on every build.

    Steps:

    1. There are two missing frameworks:
      • MessageUI.framework
      • Social.framework

    2. Updating (in Xcode) www\worklight\cordova_plugins.js with an extra section

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

      Note: SocialSharing.js should be placed in common\js as well as be referenced to in the HEAD element in index.html

    3. Edit SocialSharing.js by wrapping the entire contents with

      cordova.define("nl.x-services.plugins.socialsharing", function(require, exports, module) {
          // file contents
      ); 
      
    4. In your HTML, choose whichever sharing option you'd like from the available ones (see plug-in documentation for those).

    End result:

    enter image description here

    0 讨论(0)
提交回复
热议问题