React Native save image in iOS camera roll

How to save the image in the response label on the iOS camera? has a uri source. The CameraRoll class has a method called saveImageWithTag, but it's unclear how to use it. I think the documentation is not good enough.

+4
source share
1 answer

I have the same problem and I test my own CameraRoll API, it provides a static function

static saveImageWithTag(tag, successCallback, errorCallback) 

Help save the image to the camera roll / gallery.

1. , / node_modules/react-native/Libraries/CameraRoll/RCTCameraRoll.xcodeproj . , , . (https://facebook.imtqy.com/react-native/docs/linking-libraries-ios.html#content)

2., . .

3. , . DidMount. ( : https://thebhwgroup.com/blog/accessing-iphone-camera-roll-images-react-native)

'use strict';

var React = require('react-native');

var {
  CameraRoll,
  View,
} = React;

var CameraRollTest = React.createClass({
  
  componentDidMount() {
    CameraRoll.saveImageWithTag('YOUR_IMAGE_TAG/URI', function(data) {
      console.log(data);
    }, function(err) {
      console.log(err);
    });

  },
  render: function() {
    return (
      <View>
      </View>
    );
  }
});

module.exports = CameraRollTest;
Hide result
+3

Source: https://habr.com/ru/post/1612082/


All Articles