Частичное отключениеshare-external
It's possible to copy a link after share picture to the Instagram story?
1

I'm developing a feature which generates a picture and then shares it with the Instagram Story; at the same time, copying a URL so that users can add this URL by adding a Link to Instagram Story. I'm using react-native-share to do the sharing. Under the hood, it uses the same code as mentioned in this doc.(https://developers.facebook.com/docs/instagram/sharing-to-stories/#register-instagram-s-custom-url-scheme), so the problem is to share the picture to Instagram Story, the picture URL and other sharing related information need to be set to the clipboard first. If I copy the URL first, it's gonna be overwritten by the sharing-related information. I find a workaround: copy the URL within 1 second after my app opens Instagram. But this brings another issue because, in this case, my app is in the background. If the user didn't grant paste from my app in Instagram before or Instagram doesn't run in the background, it shows a "allow paste with yes and no" prompt in the splash screen, which interrupts my workaround because the URL link is gonna overwrite the sharing-related information in the clipboard and then the user gonna see a black picture in the Instagram story. I've noticed similar case in stackoverflow(https://stackoverflow.com/questions/70748544/is-it-possible-to-share-story-to-instagram-and-copy-text-simultaneously-ios-sw), but didn't find solution. I've noticed a similar case in Stackoverflow (https://stackoverflow.com/questions/70748544/is-it-possible-to-share-story-to-instagram-and-copy-text-simultaneously-ios-sw) but didn't find a solution. I've seen other iOS apps like NGL, and after it opens the Instagram Story, it keeps a link in the clipboard. How can it be achieved?

Dongxu
Вопрос задан около 6 мес. назад
Выбранный ответ
1

I have a problem same as you. You can handle copy text by event app state change. Here: useEffect(() => { const handleAppStateChange = ( nextAppState: SetStateAction<"active" | "background" | "inactive" | "unknown" | "extension"> ) => { if (appState === "inactive" && nextAppState === "background") { if (!urlCopied) { Clipboard.setString(string); setUrlCopied(true); } } setAppState(nextAppState); };

const subscription = AppState.addEventListener("change", handleAppStateChange);

return () => {
  subscription.remove();
};

}, [appState, urlCopied]);

27 августа в 00:01
Minh