0
votes

I’m using an Ionic 3 app, trying to get social sharing working.

I followed the steps to install the Ionic Native Social Sharing plugin from: https://ionicframework.com/docs/v3/native/social-sharing/

Ran:

$ ionic cordova plugin add cordova-plugin-x-socialsharing
$ npm install --save @ionic-native/social-sharing@4

Imported the plugin (version 4.x.x) via my app module and added SocialSharing to the providers array.

Imported the plugin via my app.component using:

import { SocialSharing } from '@ionic-native/social-sharing';

Added to the constructor:

private socialSharing: SocialSharing

This share function, also in app.component is triggered via a button in the html (side menu):

async share() {
    try {
      // Pop the native social sharing sheet, allowing the user to choose how to share the app.
      await this.socialSharing.share(this.shareMessage, this.shareSubject, this.shareFile, this.getShareUrl());
      this.toast.show('Thanks for sharing!', 3000);
    }
    catch(err) {
      console.error(err);
      alert(err);
    }
  }

I’m using platforms: ios, android and browser.

When I call the method from a build on a real device I get the error:

"Plugin is not installed"

Tried:

  • Checking logs for installation errors. None seen.

  • Reinstalled plugin.

  • Checked plugin present using $ionic cordova plugin list. cordova-plugin-x-socialsharing 5.4.7 “SocialSharing” is present.

  • Removed and added all platforms again.

  • Wrapped the share method inside a platform.ready().

Nothing seems to be working. I cannot get the app to recognise the plugin is installed!

PLEASE HELP! :slight_smile: What can I try next?

Thanks

$ionic info:

Ionic:

Ionic CLI : 5.2.3 (/usr/local/lib/node_modules/ionic) Ionic Framework : ionic-angular 3.9.5 @ionic/app-scripts : 3.2.2

Cordova:

Cordova CLI : 9.0.0 ([email protected]) Cordova Platforms : android 8.0.0, browser 6.0.0, ios 5.0.1 Cordova Plugins : cordova-plugin-ionic 5.4.0, cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.5.1, (and 13 other plugins)

Utility:

cordova-res : 0.4.0 (update available: 0.6.0) native-run : not installed

System:

ios-deploy : 1.9.4 ios-sim : 8.0.2 NodeJS : v11.2.0 (/usr/local/Cellar/node/11.2.0/bin/node) npm : 6.9.2 OS : macOS Mojave Xcode : Xcode 10.2 Build version 10E125

2
can you do Ionic info or run another command that shows exactly the versions of ionic you are using? - Sergey Rudenko
Hi Sergey, I've edited the above with my ionic info. Thanks for taking a look! - Mark Reiner

2 Answers

1
votes

So according to your information your current installed plugin is version 5.4.7, to make plugins work with Ionic 3 you need to ensure you have installed 4.* version of the plugin.

Seems like you are using the right command for the install (adding @4 after the plugin install command).

Can you try uninstall the plugin and then attempt to reinstall and note which version its installing. You may have to try and install 4.* version:

npm install --save @ionic-native/[email protected]
0
votes

I got an issue with cordova-plugin-x-socialsharing in Ionic3 and main issue was couldn't install cordova-plugin-x-socialsharing plugin properly(error: can't find plugin.xml for es6-promise-plugin).

Steps to fix:

  1. Installed es6-promise-plugin : ionic cordova plugin add https://github.com/vstirbu/PromisesPlugin

  2. Installed cordova-plugin-x-socialsharing : ionic cordova plugin add cordova-plugin-x-socialsharing

  3. npm install --save @ionic-native/social-sharing@4