Command palette

@yasinsensoy/native

React Native · APIs and utilities

Share

System share sheet.

4 exports

Import

import { Share } from "@yasinsensoy/native";

Share

module

System share sheet.

NameTypeDescription
share(content: ShareContent, options?: ShareOptions) => Promise<ShareResult>Opens the share sheet; resolves when the user picks a target or closes it. Errors: E_ARGS (no content), E_FILE (file missing), E_NO_ACTIVITY.

ShareContent

interface

Content to share. At least one must be given.

NameTypeDescription
message?stringText.
url?stringLink (appended to the text on Android).
files?readonly string[]Files: a file:// URL or an absolute path; on Android also content://. On Android they are copied to the cache and opened to the chosen app only.
subject?stringSubject (email). If title is given without subject, it is used.
title?stringTitle.
mimeType?stringAndroid: MIME type. Inferred from the files if omitted (text/plain).

ShareOptions

interface

Share.share options.

NameTypeDescription
dialogTitle?stringAndroid: title of the share sheet.
excludedActivityTypes?readonly string[]iOS: targets to hide (airDrop, message, mail, copy, print, assignToContact, saveToCameraRoll, addToReadingList, openInIBooks, markupAsPDF or a system id).
anchor?{ x: number; y: number; width?: number; height?: number; }iPad: area the popover anchors to (screen points). Opens centered if omitted.

ShareResult

interface

Share result.

NameTypeDescription
action"shared" | "dismissed"shared: a target was chosen; dismissed: the sheet was closed.
targetstring | nullThe chosen target (Android: package name, iOS: activity type). null if unknown or a system action ("Copy" on Android).