EddyVerbruggen / SocialSharing-PhoneGap-Plugin

👨‍❤️‍💋‍👨 Cordova plugin to share text, a file (image/PDF/..), or a URL (or all three) via the native sharing widget
MIT License
1.78k stars 907 forks source link

App restarts aftr sharing. #300

Closed philecom closed 8 years ago

philecom commented 9 years ago

Thank you for such a great plugin. I have an issue. I am able to share both images and text to whatsapp and email, however after i finish sharing and hit the back button on android my App restarts instead of going back to the page on my app that has the content i shared. I am using Angularjs as a framework.

I will be glad if someone can help me resolve this, thank you.

sabithasharma commented 9 years ago

Facing the same issue

chrisbenseler commented 9 years ago

+1

Also with me. On Android. App built with Ionic.

EddyVerbruggen commented 9 years ago

Can you guys please tell me which version of the plugin you're using and the exact line of code that's being called? Not .share(msg, ..), but .share('the message', .. please.

chrisbenseler commented 9 years ago

cordova plugin list outputs:

nl.x-services.plugins.socialsharing 4.3.19-dev "SocialSharing"

in my html template, I have this: button ng-click="share()">Share!</button

in my js: $scope.share = function() { window.plugins.socialsharing.share($scope.newsdata.description, $scope.newsdata.title, null, $scope.newsdata.url); }

EddyVerbruggen commented 9 years ago

Hi @chrisbenseler can you please let me know what the values of those variables are at runtime? $scope.newsdata.description etc? And is your trouble also with WhatsApp only?

chrisbenseler commented 9 years ago

The values are:

$scope.newsdata.description: essa é a descrição do item 1 $scope.newsdata.title: Título 1 $scope.newsdata.url: http://eucomi.com.br/

I tried with several other values, used without special characters, but it still happens.

It happens also with Whatsapp.

EddyVerbruggen commented 9 years ago

On WhatsApp only, or also on others? If also on others: all others, or specific apps?

Sorry for nagging, but I really need more details. Android versions would be welcome as well.

Best would be a crashlog by running adb logcat with your device connected.

chrisbenseler commented 9 years ago

Those which crashes (and I have tested): Whatsapp, Twitter, Inbox, Gmail, Facebook and Colornote.

The only one that doesn't crash is "Copy to Clipboard".

adb logcat CordovaLog:E *:S doesn't return anuthing.

adb logcat CordovaLog:D *:S return just I/CordovaLog(16156): Changing log level to DEBUG(3)

If I run adb logcat there are too much info on the screen, can't find anything. Android 4.4.4, Moto G.

Gonna try with iOS.

EddyVerbruggen commented 9 years ago

Thanks for your efforts, I'll try with my 4.4.4 Samsung!

Perhaps you can catch something when attached to usb, press share, and immediately after the crash stop the output. That may show a stacktrace.

chrisbenseler commented 9 years ago

When I tried to share using Inbox:

W/ContextImpl( 1230): Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:1252 android.content.ContextWrapper.sendBroadcast:365 com.motorola.motocare.util.TriggerHelper$TriggerBuilder.send:76 com.motorola.motocare.internal.frameworkevents.PauseResumeTrigger.handleFrameworkEvent:53 com.motorola.motocare.internal.frameworkevents.FwEventMonitor$FrameworkListener.processFrameworkEvent:114 E/cutils ( 262): Failed to mkdirat(/storage/sdcard1/Android): Read-only file system W/Vold ( 262): Returning OperationFailed - no handler for errno 30 W/ContextImpl(26439): Failed to ensure directory: /storage/sdcard1/Android/data/com.google.android.apps.inbox/cache W/dalvikvm(26439): VFY: unable to resolve virtual method 1774: Landroid/app/Activity;.finishAfterTransition ()V W/dalvikvm(26439): Unable to resolve superclass of Lchm; (797) W/dalvikvm(26439): Link of class 'Lchm;' failed E/dalvikvm(26439): Could not find class 'chm', referenced from method com.google.android.apps.bigtop.widgets.BigTopToolbar. W/dalvikvm(26439): VFY: unable to resolve new-instance 2162 (Lchm;) in Lcom/google/android/apps/bigtop/widgets/BigTopToolbar;

then I tried with Twitter:

E/cutils ( 262): Failed to mkdirat(/storage/sdcard1/Android): Read-only file system W/Vold ( 262): Returning OperationFailed - no handler for errno 30 W/ContextImpl(28822): Failed to ensure directory: /storage/sdcard1/Android/data/com.twitter.android/cache

In both cases appear "Failed to ensure directory". In my device, I have (and never had) any SD Card. Only the internal storage, 8GB total, 1GB free now.

EddyVerbruggen commented 9 years ago

I can't crash mine that way, but can you try adding this to your AndroidManifest.xml?

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

If there already is an entry like this please remove it:

<uses-permission android:maxSdkVersion="18" android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
chrisbenseler commented 9 years ago

It's already with this settings.

Gonna make other tests, maybe with other devices. But I think this has no relation. I opened my Twitter app and tried to share via Inbox a tweet, the adb console outputs the same, but the app didn't crash. Going to take a look at the logs, a little bit more.

EddyVerbruggen commented 9 years ago

@philecom @sabithasharma the problem you were facing probably had to do with a bug in the callback handler of the plugin.

@chrisbenseler I fixed a bug 19 days ago - you should have that fix in your codebase, but please doublecheck that for me: check that you have the bits in green, not the bits in red here, it's in SocialSharing.java.

chrisbenseler commented 9 years ago

Yes, it already has this fix.

philecom commented 9 years ago

Thank you @EddyVerbruggen. It is working now for me. Thank you again.

Vatsov commented 8 years ago

Hi guys, I’m facing the same issue with Samsung Note 2 and Android version 4.4.2

I use ionic with cordova:

"ionic",  "version": "1.2.4"
"cordova-plugin-x-socialsharing",  "version": "5.0.10"
"ngCordova",  "version": "v0.1.12-alpha"

Installed platforms: android 4.0.2

In my AndroidManifest.xml:

<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="22" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

The code is: $cordovaSocialSharing.shareViaFacebookWithPasteMessageHint("Gigi Reveals Her Winning Recipe", "http://i.imgur.com/Jg7RXoT.jpg", null);

The strange is that there are no errors in the console. The post is successful but it does not go in success callback. Just restart the application.

lucianoengel commented 8 years ago

+1 android 4.1

Vatsov commented 8 years ago

I've updated android platform to 5.1.1 and cordova to 6.0.0, but it's the same.

sabithasharma commented 8 years ago

Hi All,

 This can be fixed by starting the intent in a new task i.e new window

draft.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //this was added to start the intent in a new window draft.setType("application/octet-stream"); cordova.startActivityForResult(plugin, Intent.createChooser(draft, "Choose Email App"), ACTIVITY_CODE_SENDVIAEMAIL);

With Regards, Sabitha Sharma L

On Thu, Mar 3, 2016 at 11:16 PM, Deyan Vatsov notifications@github.com wrote:

I've updated android platform to 5.1.1 and cordova to 6.0.0, but it's the same.

— Reply to this email directly or view it on GitHub https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin/issues/300#issuecomment-191881898 .

With Regards Sabitha Sharma L

EddyVerbruggen commented 8 years ago

@Vatsov can I have your project? Just tried again with my Android 4.4.2 device and all fine. I'm NOT using Ionic, just a vanilla Cordova CLI app with the plugin added and your shareViaFacebookWithPasteMessageHint code. Perhaps you can try that as well? It's just a matter of:

cordova create test
cd test
cordova platform add android
cordova plugin add cordova-plugin-x-socialsharing
cordova prepare android

And adding a button to /platforms/android/assets/www/index.html which triggers a function:

  function shareViaFb() {
    window.plugins.socialsharing.shareViaFacebookWithPasteMessageHint(
      "Gigi Reveals Her Winning Recipe",
      "http://i.imgur.com/Jg7RXoT.jpg",
      null
    );
  }
EddyVerbruggen commented 8 years ago

Tried in an Ionic app as well - no issues. Perhaps it's the launchMode in AndroidManifest.xml that's different? Anyway, I'll test that Intent.FLAG_ACTIVITY_NEW_TASK a bit and if it doesn't break anything I'll add it.

Vatsov commented 8 years ago

Thanks, I'm gonna try with clean ionic installation only with cordova-plugin-x-socialsharing

EddyVerbruggen commented 8 years ago

Please do, and also without the ngCordova wrapper, so plain old windows.plugins.socialsharing..

Vatsov commented 8 years ago

OK, So I created a github repo https://github.com/Vatsov/cleanShare with fresh new ionic and branch without the ngCordova wrapper https://github.com/Vatsov/cleanShare/tree/without_ngCordova_wrapper

And in both cases the problem continues to appear

EddyVerbruggen commented 8 years ago

@Vatsov As I can't reproduce I had to guess a few things - can you please test from the master branch of this repo? Should give you version 5.0.12-dev.

Vatsov commented 8 years ago

Hi Eddy,

I've updated social plugin but without effect.

I think the problem was one option that was checked on my phone.

Do not keep activities. Destroy every activity as soon as the user leaves it.

After I've unchecked it social plugin started working very smoothly.

I'm not sure if the reason was this option or a combination with your change, but thanks a lot for your help!

EddyVerbruggen commented 8 years ago

Oh man, that option is part of the Developer Options, right? It's better left untouched, thanks for reporting that back I would have never guessed it.