react-native-social-share icon indicating copy to clipboard operation
react-native-social-share copied to clipboard

Unable to share on Facebook and Twitter with react-native-social-share in iOS

Open TarunKasera2401 opened this issue 6 years ago • 8 comments

Hey @doefler ,

All things are working fine in Android and in iOS not working. very strange.

I am unable to get success on facebook and twitter sharing. I have follow all instructions which you mentioned at : https://github.com/doefler/react-native-social-share. when I click on twitter and facebook function like
shareOnTwitter({ 'text':'Global democratized marketplace for art', 'link':'https://artboost.com/', 'imagelink':'https://artboost.com/apple-touch-icon-144x144.png', //or use image 'image': 'artboost-icon', }, (results) => { console.log(results); } ); }, then getting below error- 2018-05-24 12:27:35.804288+0530 AppOfChanges[332:27691] -canOpenURL: failed for URL: "twitter://" - error: "The operation couldn’t be completed. (OSStatus error -10814.)" 2018-05-24 12:27:35.806 [info][tid:com.facebook.react.JavaScript] not_available 2018-05-24 12:27:35.805769+0530 AppOfChanges[332:30147] not_available

and same thing getting in facebook function. Configration details: "react-native": "0.55.4", Working on - iOS 10.3.3

I have tried a lot but nothing getting any success , could you please help me on this.

TarunKasera2401 avatar May 24 '18 07:05 TarunKasera2401

simulator screen shot - iphone 6 - 2018-05-30 at 16 39 00

softdev8 avatar May 30 '18 08:05 softdev8

i used same code as you described.

softdev8 avatar May 30 '18 08:05 softdev8

Have you tried manually install on iOS?

ryanix avatar Jun 01 '18 13:06 ryanix

@MobileDev418 are you still seeing this issue? tweet is the method that's exported from KDSocialShare.m and called from node_modules/react-native-social-share/react-native-social-share.js. This means native module KDSocialShare isn't properly linked up. As @ryanix suggested, make sure you follow manual install steps:

  • KDSocialShare.h& KDSocialShare.m both have to be added to the Library folder in the project.
  • KDSocialShare.m's Target Membership is checked off for the appropriate target.
  • Header search paths should encompass the folder containing the file, either by explicit namespace or via recursion.
  • KDSocialShare.m file has to be added to "Build Phases" > "Compile Sources"
  • Clean the build cache then rebuild.

Let me know if you're still having trouble.

kevinkong91 avatar Aug 16 '18 22:08 kevinkong91

@TarunKasera2401 you're most likely seeing this issue because your project's main Info.plist does not have twitter value set in the LSApplicationQueriesSchemes array. The twitter:// query space is not accessible from the app so it's returning to the not_available callback path. Does adding the value solve your issue?

screen shot 2018-08-16 at 3 32 14 pm

kevinkong91 avatar Aug 16 '18 22:08 kevinkong91

I'm also getting this - though things are failing silently with no output (error or result), and I'm fairly sure I've linked things correctly. When I try without the apps installed I get "not_available" but with them installed, just silent.

dancherb avatar Dec 02 '18 10:12 dancherb

I was seeing silent failure on Twitter+iOS with Twitter app installed as well.

In my case, it was because I had a modal on-screen when I called shareOnTwitter. While nothing showed up when I was logging on react native debugger / chrome console, when I disabled remote logging and looked at xcode logs directly, I could see this Warning: Attempt to present <SLComposeViewController: 0x[...]> on <UIViewController: 0x[...]> which is already presenting <RCTModalHostViewController: 0x[...]>.

iOS doesn't seem to like presenting two viewcontrollers at once or something along those lines, but the reader's (your) specific case could be some other controller (like RN iOS ActionSheet, maybe).

See: https://stackoverflow.com/questions/26541085/slcomposeviewcontroller-attempt-to-present-errors-in-ios-8

I changed my app to dismiss the first visible controller (in my case, the user pressed a "Tweet" button to share something on Twitter from within a modal) then used setTimeout to give a little buffer time after dismissing the modal, then called shareOnTwitter after a small delay. Works fine now.

choiRyan avatar Dec 12 '18 09:12 choiRyan

I was seeing silent failure on Twitter+iOS with Twitter app installed as well.

In my case, it was because I had a modal on-screen when I called shareOnTwitter. While nothing showed up when I was logging on react native debugger / chrome console, when I disabled remote logging and looked at xcode logs directly, I could see this Warning: Attempt to present <SLComposeViewController: 0x[...]> on <UIViewController: 0x[...]> which is already presenting <RCTModalHostViewController: 0x[...]>.

iOS doesn't seem to like presenting two viewcontrollers at once or something along those lines, but the reader's (your) specific case could be some other controller (like RN iOS ActionSheet, maybe).

See: https://stackoverflow.com/questions/26541085/slcomposeviewcontroller-attempt-to-present-errors-in-ios-8

I changed my app to dismiss the first visible controller (in my case, the user pressed a "Tweet" button to share something on Twitter from within a modal) then used setTimeout to give a little buffer time after dismissing the modal, then called shareOnTwitter after a small delay. Works fine now.

I'm using react-native-navigation (don't know if that's important) and this is what I did to show it on top of current modal.

KDSocialShare.m line 58 was UIViewController *ctrl = [[[[UIApplication sharedApplication] delegate] window] rootViewController];

I changed it to UIViewController *ctrl = RCTPresentedViewController(); and it worked. I saw other packages using this, so I just tried it. No Idea how it works.

pravinjohn avatar Apr 06 '20 21:04 pravinjohn