Social sharing?

#1

Upon searching I’m unable to find information on social sharing solutions usable in conjunction with Expo. I just started assessing Expo’s applicability to my project so excuse my ignorance, but what would be the best way of going about this? I need the ability to share on Twitter, Facebook and Google Plus.

#2

I have also been exploring on integrating social sharing into my app.
Showing UI in mobile is not tough, you can use vector icons provided by expo. And use Linking library to take action on that.
Next you will need to use deep linking, explained here
and here

Although you might need a web version of your app for better results IMO.

#3

hello! welcome. you can use this api built into react-native core to share: https://facebook.github.io/react-native/docs/share.html

2 Likes
#4

thanks for share Brent
you are amazing as always :slight_smile:

1 Like
#6

And all of the typical social provider SDK’s can be included without ejecting?

#7

@eemebarbe- which ones do you need? what features from them specifically? can you create a feature request on https://expo.canny.io/feature-requests please?

#8

Hi @notbrent!

We’ve been having some issues opening the Facebook app with our CRNA and Expo app. Specifically, we want to link to the Facebook app to post a status. It seems to work for Twitter, but not Facebook. I’ve been hunting around the interwebs, but beginning to suspect we will need to eject our CRNA? Could you explain why that is and what might be a workaround? Here’s the code for our Twitter & Facebook sharing. Thanks in advance for your help/advice!

shareTwitter = () => {
    const { short_referrer_key } = this.props;

    Linking.openURL(
      `https://twitter.com/home?status=Use%20my%20Thistle%20referral%20code%20${short_referrer_key}%20to%20get%20$20%20off%20healthy%20meals%20delivered%20https%3A//www.thistle.co/referral/${short_referrer_key}`,
    );
  };

  shareFacebook = () => {
    const { short_referrer_key } = this.props;

    Linking.openURL(
      `https://www.facebook.com/sharer/sharer.php?u=https%3A//www.thistle.co/referral/${short_referrer_key}`,
    );
  };
#9

Hello Is there anyone who have sort this problem in a proper way?
Thank you in adavance.

#10

what does this mean? see https://facebook.github.io/react-native/docs/share.html

if this doesn’t handle your use case then explain what your use case is :sweat_smile:

#11

Hey guys, jumping onto this as I need to share an Image.
This is possible with react-native core share function on iOS but not on Android.
Unfortunately I am targeting both platforms.

I also tried: https://github.com/react-native-community/react-native-share but there I get an unhandled promise rejection error.

Any ideas?

#12

not supported at the moment it seems but you could open a feature request on expo-pls.xyz or detach and add that library!

#13

Take a look at how Spotify or Google photos does it.

The native share sheet in most apps triggers a generic handler to supply content to the target service (or target app to be more specific). With Spotify and Google photos, those apps employ their own share-sheet. This has 2 benefits;

  • They can style it as they see fit, and choose which services to support
  • They can call appropriate API’s for each service. This means that they need to write more code, but they can finely control how things are shared.

I haven’t yet tried to integrate my own share sheet as I haven’t researched if the FBSDK can be integrated into an expo project without detaching (which is something I won’t consider right now), but I could take a look at the API’s of say, Twitter, Whatsapp, etc. and manually write my own wrapper that shares with those services using linking or fetch (and combining with a web browser view where appropriate).

I do wish FB wouldn’t have changed sharing in the way they have as it really does make native UX very inconsistent.

@notbrent - Is it possible to support restricting which services are available within the native share sheet? I figure if people can choose to remove say Facebook, from the native share sheet, that might alleviate some of the concerns people have (even if it doesn’t fix the problem, it helps make better UX for devs).

#14

@gawr I am having the same issues as you while trying to achieve the same thing. Did you get around the problem without detaching? I would like to stay attached if possible bc there isn’t another clean and simple solution to do push notifications with expo on iOS and android.