react-native-share / react-native-share

Social share, sending simple data to other apps.

Home Page:https://react-native-share.github.io/react-native-share

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sending a URL along with a message does not work on IOS, only on Android.

ArthurSimoess opened this issue · comments

Hello, I want to share a url along with a message on WhatsApp, but only the message is sent. It works on Android and on IOS it doesn't. Does anyone know how I can get around this?

My code:

  import { useRef } from 'react';
  
  import { StyleSheet, Text, TouchableOpacity, View } from 'react-native';
  
  import { captureRef } from 'react-native-view-shot';
  
  import Share from 'react-native-share';
  
  export default function TestShare() {
    const imageRef = useRef(null);
  
    const onSaveImageAsync = async () => {
      try {
        const localUri = await captureRef(imageRef, {
          height: 440,
          quality: 1,
        });
  
        await Share.open({
          url: localUri,
          message: 'Test message',
        });
      } catch (e) {
        console.log(e);
      }
    };
  
    return (
      <>
        <View ref={imageRef} style={{ alignItems: 'center', marginTop: 40 }} collapsable={false}>
          <View style={styles.circle}>
            <Text>TESTE IMAGEM</Text>
          </View>
        </View>
        <TouchableOpacity style={styles.button} onPress={onSaveImageAsync}>
          <Text style={{ color: '#FFFFFF' }}>Share image</Text>
        </TouchableOpacity>
      </>
    );
  }
  
  const styles = StyleSheet.create({
    circle: {
      width: 150,
      height: 150,
      borderRadius: 100,
      padding: 10,
      backgroundColor: 'red',
      marginTop: 30,
      alignItems: 'center',
      justifyContent: 'center',
    },
    button: {
      backgroundColor: 'blue',
      borderColor: '#000000',
      borderRadius: 5,
      width: 100,
      height: 50,
      justifyContent: 'center',
      alignItems: 'center',
      marginTop: 10,
    },
  });

facing the same issue. It share only one at a time, if we use both message and url, only message is shared.

I'm also seeing this when clicking "Copy" from the menu. The url is there on the iOS simulator, but doesn't work on a physical device.

Encountering a similar problem on iOS after testing on real devices, while it functions seamlessly on Android. Seeking assistance—does anyone have a solution or insights to share?

Facing the same issue. Im passing this config:

const shareOptions = { 
  message: message, (String)
  url: base64, (String base64 format)
  failOnCancel: false,
};

same issue