Skip to main content

shareHelpers

Content

Set of share functions, made possible by react-native-share. Check the docs to learn more.

showShareDialog

Shows share dialog with provided options and optional callbacks.

Params

NameTypeRequiredDefault valueDescription
optionsShareOptionsTrue-Share options
completedCallback(result: ShareOpenResult) => voidFalseUndefinedCallback when user completed share action with result parameters
errorCallback(error: Error or unknown) => voidFalseUndefinedError callback when something went wrong or user didn't share anything

Usage example

  const onShowShareDialogPress = useCallback(async () => {
await showShareDialog(
{
showAppsToView: true,
message: "Test message to share",
},
(result) => {
console.warn("Share result: ", result);
},
(error) => {
console.error("Share error: ", error);
},
);
}, []);

showShareSocialDialog

Shows share to social network dialog with provided options and optional callbacks. If the app is not installed then tries to open the web page of social network.

Params

NameTypeRequiredDefault valueDescription
optionsShareSingleOptionsTrue-Share options
completedCallback(result: ShareSingleResult) => voidFalseUndefinedCallback when user completed share action with result parameters
errorCallback(error: Error or unknown) => voidFalseUndefinedError callback when something went wrong or user didn't share anything

Usage example

  const onShowShareSocialDialogPress = useCallback(async () => {
await showShareSocialDialog(
{
social: Share.Social.TWITTER,
title: "Share via",
message: "Twitter test message from template",
url: "",
},
(result) => {
console.warn("Share result: ", result);
},
(error) => {
console.error("Share error: ", error);
},
);
}, []);

isPackageInstalled

Checks whether the package installed, on Android uses the share check, on iOS checks using Linking.canOpenURL.

Params

NameTypeRequiredDefault valueDescription
androidPackageNamestringFalseUndefinedAndroid package name
iosUrlstringFalseUndefinediOS package URI

Usage example

await isPackageInstalled("com.instagram.android", "instagram://");