Sharing (iOS)
Bridge for opening iOS's native share sheet (UIActivityViewController) from website JavaScript with support for text, URL, and file payloads.
Bridge object: AppleShare (injected shim)
Method | Return | Description |
|---|---|---|
|
| Returns whether share is available (always |
|
| Opens native share sheet; resolves on successful share, rejects on error or cancellation |
Auto Shim for navigator.share
On iOS, MobiWeb auto-injects a shim that defines:
navigator.share(...)(if missing)navigator.canShare(...)(if missing)
This lets websites that already use the Web Share API trigger the native iOS share sheet without website changes.
Payload Shape
Notes:
All fields are optional, but at least one must be provided.
textandurlare both included in the activity view controller if provided.files[].datamust be base64-encoded (data URL prefix is not supported).Files are written to the temporary directory and automatically cleaned up after sharing completes.
Maximum recommended file count: 10 files per share operation.
Examples
Using navigator.share (recommended):
Using direct bridge call:
Platform Limitations
WKWebView on iOS does not support:
Direct file system access from JavaScript
Automatic file MIME type resolution from names alone
Solution: MobiWeb handles these transparently:
Files must be provided as Blob objects with proper
typesetTemporary files are created server-side with MIME type validation
Cleanup happens automatically after the share completes
Result Events
The share() method returns a Promise:
Resolves when user completes the share action (success)
Rejects with an error if:
User cancels the share sheet
No share targets are available
File encoding fails