Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
TarunKasera2401 opened this issue May 24, 2018 · 8 comments

Comments

@TarunKasera2401
Copy link

TarunKasera2401 commented May 24, 2018

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 TarunKasera2401 changed the title Unable to share on Facebook and Twitter with react-native-social-share Unable to share on Facebook and Twitter with react-native-social-share in iOS May 24, 2018
@softdev8
Copy link

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

@softdev8
Copy link

i used same code as you described.

@ryanix
Copy link

ryanix commented Jun 1, 2018

Have you tried manually install on iOS?

@kevinkong91
Copy link

kevinkong91 commented Aug 16, 2018

@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
Copy link

@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

@dancherb
Copy link

dancherb commented Dec 2, 2018

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.

@choiRyan
Copy link

choiRyan commented Dec 12, 2018

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.

@pravinjohn
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants