How to share text & url to facebook on Android? React Native allows us to share url on iOS but not for Android. Please help!
I did it for both system and the doc says:
> Open a dialog to share text content.
> In iOS, Returns a Promise which will be invoked an object containing action, activityType. If the user dismissed the dialog, the Promise will still be resolved with action being Share.dismissedAction and all the other keys being undefined.
> In Android, Returns a Promise which always be resolved with action being Share.sharedAction.
How did you get it to work on Android? Only works on iOS for me as well.
I actually didn’t test on IOS by myself (I need a macbook ), but it seems to works on both system.
I did like this:
import React, { Component } from 'react';
import {
View,
Share,
TouchableOpacity,
Platform
} from 'react-native';
import { Icon } from 'react-native-elements';
class SharingItem extends Component {
onClick() {
Share.share({
...Platform.select({
ios: {
message: 'Have a look on : ',
url: this.props.url,
},
android: {
message: 'Have a look on : \n' + this.props.url
}
}),
title: 'Wow, did you see that?'
}, {
...Platform.select({
ios: {
// iOS only:
excludedActivityTypes: [
'com.apple.UIKit.activity.PostToTwitter'
]
},
android: {
// Android only:
dialogTitle: 'Share : ' + this.props.title
}
})
});
}
render() {
return (
<View>
<TouchableOpacity
onPress={() => { this.onClick(); }}
>
<Icon
key={this.props.keyId}
name='share-alt'
type='font-awesome'
color='#22313F'
size={22}
/>
</TouchableOpacity>
</View>
);
}
}
export default SharingItem;
Ahh, i see now the URL attribute only works on ios.
Thanks
Cool if it’s helped you
Cheers
I worked now, thanks a lot!
Cool, happy that’s helped you
Can you help me with, coding share message in such a way that the whatsapp will render the image and title and message.
For example.
Note: I don’t have dynamic detail page like github
This topic was automatically closed after 14 days. New replies are no longer allowed.