Social share doesn't work on android device


#1

We are implementing twitter share using socialshare of ionic native.
Below is the source code.
It will work fine when running with ionic view, but it will be an error when running on an actual machine with ionic cordova run android.

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

  constructor(private socialSharing: SocialSharing) {
  }

  twitterShare(){
    this.socialSharing.shareViaTwitter(this.shareContent, null, this.shareURL)
    .then(()=>{
    }).catch(() => {
      alert("error");
    });
  }

My ionic info is below.

cli packages: (/usr/local/lib/node_modules)

    @ionic/cli-utils  : 1.19.2
    ionic (Ionic CLI) : 3.20.0

global packages:

    cordova (Cordova CLI) : 8.0.0 

local packages:

    @ionic/app-scripts : 3.1.8
    Cordova Platforms  : android 7.0.0 browser 5.0.3
    Ionic Framework    : ionic-angular 3.9.2

System:

    Android SDK Tools : 26.1.1
    Node              : v8.11.1
    npm               : 2.15.12 
    OS                : macOS Sierra

Environment Variables:

    ANDROID_HOME : /Users/nakamurakota/Library/Android/sdk

Misc:

    backend : pro

#2

Get the error message, and show it using alert.
Modified your code:
twitterShare(){
this.socialSharing.shareViaTwitter(this.shareContent, null, this.shareURL)
.then(()=>{
},err => {
alert(err);
});