Message Sharing
share You can display the native share sheet so users can easily share content with a function. For example, users can select a desired app (e.g., a messenger app or notes app) from the list of installed apps to share invitation messages or text information. It uses the default sharing interface provided by each platform (Android, iOS).
options.message If you pass the message to share into the property, a list of apps the user can choose from is displayed. For example, it's useful when the user wants to share a text message or save it to a notes app.
Signature
function share(message: { message: string }): Promise<void>;Parameters
options · Required ·
objectAn object containing the message to share.
options.message · Required ·
stringA text string to share. For example, "Hello! I'm sharing this content."
Example: Implementing the share function
Below is a simple example of sharing a message when a button is clicked.
import { share } from '@apps-in-toss/web-framework';
async function handleShare() {
try {
await share({ message: 'Message to share' });
console.log('Share complete');
} catch (error) {
console.error('Share failed:', error);
}
}import { share } from '@apps-in-toss/web-framework';
const ShareButton = () => {
const handleShare = async () => {
try {
await share({ message: 'Message to share' });
console.log('Share complete');
} catch (error) {
console.error('Share failed:', error);
}
};
return <button onClick={handleShare}>Share</button>;
};Sharing a message by accepting user input
You can also implement it so users share a message they entered themselves. The following is an example of a feature for composing an invitation message.
Try the sample app
apps-in-toss-examples from the repository with-share-text Download the code, or scan the QR code below to try it yourself.
QR code link: intoss://with-share-text
Last updated
Was this helpful?