PAM Native Share Extension
Start here
Section titled “Start here”Every PAM Native product runs on the PAM runtime. Install and verify PAM first, create a Native application, and add this package through PAM Composer:
curl -fsSL https://github.com/push-in/pam/releases/latest/download/install.sh | shpam doctorpam init my-app --template nativecd my-apppam composer require pushinbr/pam-native-share-extensionpam doctorpam native devpushinbr/pam-native-share-extension 0.3.1 adds ACTION_SEND /
SEND_MULTIPLE intent filters on Android and a generated iOS Share Extension
(PamShareExtension, bundle suffix .share) that copies shared files into the
App Group group.<application-id>.pam-native. Requires PAM Native
>=1.16.0 <2.0.0.
Choose the accepted types
Section titled “Choose the accepted types”By default the app is offered for every share (*/*), several items at once.
Narrow it in pam-native.json; native prepare and every build read it:
{ "plugins": { "shareExtension": { "accept": ["text/plain", "image/*", "video/*"], "multiple": ["image/*", "video/*"] } }}accept(default["*/*"]): 1 to 16 lowercase MIME types,type/subtypeortype/*.multiple(defaulttrue):truelets every accepted type arrive several at once,falseallows single items only, or list the accepted types that may.
Android gets one SEND intent filter per type, plus SEND_MULTIPLE for the
multiple types. iOS gets a generated NSExtensionActivationRule:
text/plain enables text and web URLs, image/* images (up to 32, or 1),
video/* movies (up to 8, or 1), */* keeps the previous rule (text, 8 URLs,
32 files, 32 images, 8 movies), and specific types such as application/pdf
become a UTI-CONFORMS-TO predicate. With the example above, sharing a PDF
no longer lists the app. Keep validating what arrives: the share sheet is
untrusted input.
use Pam\Native\ShareExtension\{SharedItem, SharedItemKind, ShareInbox};
(new ShareInbox())->drain(function (array $items): void { foreach ($items as $item) { // SharedItem: identifier, kind, value, mimeType, createdAtMillis match ($item->kind) { SharedItemKind::Text, SharedItemKind::Url => $this->prefill($item->value), SharedItemKind::File => $this->attach($item), }; }});Drain after launch and on every resume; drained entries are consumed. Validate MIME type and content before using a file.
Core IncomingShares or this package?
Section titled “Core IncomingShares or this package?”On iOS, this package’s Share Extension is what fills the App Group inbox. You
can consume that inbox with ShareInbox (one SharedItem per text, link or
file, files as raw App Group tokens) or with the core
Pam\Native\System\IncomingShares API (initial() and listen()), which
groups each share and imports its files into the app sandbox as
FileReferences. Both drain the same entries, so pick one. Types in the core
android.shareTargets are merged into the same Android filters. Zé Chat
accepts RN’s types through plugins.shareExtension and consumes them with
IncomingShares.
On iOS, register the App Group for the app and the extension bundle ids and include it in both provisioning profiles.