react-native-share instagram story doesn't work on Android [React Native]

1.2k views Asked by At

I'm using react-native-share to share content on instagram stories. On iOS, it works fine; however, on Android, it does not resolve the promise and does not display any error.

import { default as RNShare } from "react-native-share";

const shareOnInstagram = async (callback) => {
  const imageUrl =
    "https://images.unsplash.com/photo-1556035511-3168381ea4d4?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1674&q=80";

  /* Download image using expo-file-system */
  const base64 = await downloadImage({ url: imageUrl, isBase64: true });

  const shareOptions = {
    backgroundImage: imageUrl,
    stickerImage: "data:image/png;base64," + base64,
    backgroundBottomColor: "#fefefe",
    backgroundTopColor: "#906df4",
    social: RNShare.Social.INSTAGRAM_STORIES,
    appId: META_API_KEY,
  };

  RNShare.shareSingle(shareOptions).catch((err) => {
    console.log(err);
  });

  callback();
};

Here's the specs:

"react-native": "^0.70.6"
"react-native-share": "^8.0.1"
1

There are 1 answers

3
Kirill Novikov On

I think the problem in your Image format https://images.unsplash.com/photo-1556035511-3168381ea4d4?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1674&q=80 - if you check it is image/avif but from android documentation https://developers.facebook.com/docs/instagram/sharing-to-stories/ you can find that it should be MEDIA_TYPE_JPEG. Try to use JPEG as a workaround and if it works probably you need to convert avif to jpeg for Android version