Share photo to Instagram from React-Native app built with Expo SDK

前端 未结 4 1413
南笙
南笙 2020-12-29 17:17

I want my react-native app to share a photo with Instagram. I know it\'s possible when writing in native code to open up Instagram\'s filter screen with a specified photo.

4条回答
  •  孤独总比滥情好
    2020-12-29 17:50

    I put together an example that you can run on iOS here: https://snack.expo.io/rkbW-EG7-

    Full code below:

    import React, { Component } from 'react';
    import { Linking, Button, View, StyleSheet } from 'react-native';
    import { ImagePicker } from 'expo';
    
    export default class App extends Component {
      render() {
        return (
          
            

    This will let you open up your camera roll and pick an image, then open the Instagram app with that image selected. If the image isn't already on the camera roll, then you can use CameraRoll.saveToCameraRoll on the image (link to React Native documentation) to get it there.

    The approach used in this example will only work if you are OK with sharing from the camera roll, however, and I am unsure about how to do this on Android. I made an issue on Expo's feature request board to make sure that Instagram sharing works great out of the box.

提交回复
热议问题