react-native-share instagram direct message not working - Stack Overflow

admin2025-04-15  0

  const shareInstagramDM = async () => {
    const shareOptions = {
      title: 'Share dm',
      social: Share.Social.INSTAGRAM_DIRECT, 
    };

    try {
      const ShareResponse = await Share.shareSingle(shareOptions);
    } catch (error) {
      console.log('Error =>', error);
    }
  };

Share.Social.INSTAGRAM_DIRECT is not working but Share.Social.WHATSAPP is working. But I need Instagram dm

  const shareInstagramDM = async () => {
    const shareOptions = {
      title: 'Share dm',
      social: Share.Social.INSTAGRAM_DIRECT, 
    };

    try {
      const ShareResponse = await Share.shareSingle(shareOptions);
    } catch (error) {
      console.log('Error =>', error);
    }
  };

Share.Social.INSTAGRAM_DIRECT is not working but Share.Social.WHATSAPP is working. But I need Instagram dm

Share Improve this question asked Feb 4 at 12:31 Sefa KAÇMAZSefa KAÇMAZ 11 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 1

Direct sharing to Instagram DMs is not officially supported by Instagram's API or the react-native-share library. Your best bet is to use Instagram Stories or guide users to share content manually within the Instagram app.

import Share from 'react-native-share';

const shareToInstagramStory = async () => {
  const shareOptions = {
    backgroundImage: 'https://example.com/image.jpg', // URL or local file path
    stickerImage: 'https://example.com/sticker.png',  // Optional sticker
    backgroundTopColor: '#ffffff',                   // Optional
    backgroundBottomColor: '#000000',                // Optional
    social: Share.Social.INSTAGRAM_STORIES,
  };

  try {
    await Share.shareSingle(shareOptions);
  } catch (error) {
    console.error('Error sharing to Instagram Story:', error);
  }
};

shareToInstagramStory();
转载请注明原文地址:http://www.anycun.com/QandA/1744719638a86676.html