react-native-social-share
react-native-social-share copied to clipboard
Unable to share on Facebook and Twitter with react-native-social-share in iOS
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.
i used same code as you described.
Have you tried manually install on iOS?
@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.
@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?

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.
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 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 thisWarning: 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 calledshareOnTwitter
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.