Native share sheet for sharing URLs and files in NativePHP Mobile applications.
The Share API provides cross-platform native share sheet functionality for sharing URLs, text, and files.
composer require nativephp/mobile-shareuse Native\Mobile\Facades\Share;
// Share a URL with title and text
Share::url('Check this out!', 'Found this great article', 'https://example.com');import { share } from '#nativephp';
// Share a URL
await share.url('Check this out!', 'Found this great article', 'https://example.com');use Native\Mobile\Facades\Share;
// Share a file
Share::file('My Recording', 'Listen to this!', '/path/to/audio.m4a');
// Share just text (no file)
Share::file('Hello', 'This is my message', '');import { share } from '#nativephp';
// Share a file
await share.file('My Recording', 'Listen to this!', '/path/to/audio.m4a');
// Share just text
await share.file('Hello', 'This is my message');Opens the native share sheet with a URL.
| Parameter | Type | Description |
|---|---|---|
title |
string | Share dialog title / subject |
text |
string | Text message to include with the URL |
url |
string | The URL to share |
Opens the native share sheet with a file or text.
| Parameter | Type | Description |
|---|---|---|
title |
string | Share dialog title / subject |
text |
string | Text message to share |
filePath |
string | Absolute path to file (optional) |
The share sheet automatically detects MIME types for common file formats:
Audio: m4a, aac, mp3, wav, ogg, flac Video: mp4, m4v, mov, avi, mkv, webm Images: jpg, jpeg, png, gif, webp Documents: pdf, txt
- Uses
Intent.ACTION_SENDwithIntent.createChooser - Files are shared via
FileProviderfor security - Temporary copies are made for files in app storage
- Old share temp files are automatically cleaned up
- Uses
UIActivityViewController - Supports iPad popover presentation
- Files are shared directly via file URLs
MIT