Platform Capabilities
PAM Native exposes platform features through typed PHP APIs. The core
(pushinbr/pam-native) keeps what nearly every app needs in the
Pam\Native\System, Storage, Database, and Http namespaces; features
that need extra permissions or SDKs — notifications, location, sensors,
contacts, recording, camera capture, gallery, shares — ship as official
plugins, so an app only carries the ones it installs. Every call is
asynchronous and answers through a callback, coded variants are integer-backed
enums, and every native operation is bounded in size and time.
This page maps both and covers the smaller APIs that do not need a guide of their own. See the plugin catalog for everything else.
Capability map
Section titled “Capability map”In the core
Section titled “In the core”| Capability | PHP entry point | Guide |
|---|---|---|
| Runtime permissions | System\Permissions |
Permissions |
| Key-value preferences, secrets | Storage\Storage, Storage\SecureStorage |
Storage |
| Private files, pickers, downloads | System\Files |
Storage, Files and media |
| Cache usage and cleanup | System\Caches |
Storage |
| SQLite | Database\SQLite |
SQLite database |
| HTTP, uploads, multipart | Http\Http |
HTTP networking |
| Battery, network, power-save state | System\DeviceStatus |
Location and sensors |
| Window metrics, appearance, device and app info | System\DeviceInfo |
Location and sensors |
| Incoming and outgoing links | System\Linking |
This page, Navigation |
| Finite background work | System\BackgroundTasks |
This page |
| Timers | System\Timers |
This page |
| Clipboard, haptics, alerts, share sheet | Clipboard, Haptics, Vibration, Alert, Share |
This page |
| Media playback | UI\MediaPlayer |
Video and audio |
| Gestures and motion | UI\GestureDetector, Animated, InteractionRegion |
Interaction and motion |
In official plugins
Section titled “In official plugins”| Capability | Package | PHP entry point | Guide |
|---|---|---|---|
| Local and push notifications | pushinbr/pam-native-notifications |
Notifications\Notifications, Notifications\PushNotifications |
Notifications |
| Location | pushinbr/pam-native-location |
Location\Location |
Location and sensors |
| Motion sensors | pushinbr/pam-native-sensors |
Sensors\Sensors |
Location and sensors |
| Contacts, SMS composer | pushinbr/pam-native-contacts |
Contacts\Contacts, Contacts\Sms |
This page |
| Voice recording, audio player | pushinbr/pam-native-audio |
Audio\AudioRecorder, Audio\AudioPlayer |
This page |
| Camera capture, gallery, image processing | pushinbr/pam-native-media |
Media\MediaCapture, Media\MediaLibrary |
Files and media |
| Image editing | pushinbr/pam-native-media-editor |
MediaEditor\ImageEditor |
Files and media |
| Content shared by other apps | pushinbr/pam-native-share-extension |
ShareExtension\IncomingShares |
This page |
| Toasts | pushinbr/pam-native-toast |
Toast\Toast |
This page |
| Web content | pushinbr/pam-native-webview |
UI\WebView |
WebView |
Install a plugin with pam composer require <package>, then pam doctor --fix.
The plugin brings its own Android permissions and default iOS purpose strings.
Contacts
Section titled “Contacts”Install pushinbr/pam-native-contacts (it adds READ_CONTACTS and a default
NSContactsUsageDescription) and request PermissionKind::Contacts before
reading the address book. Contacts contain stable platform identifiers, names,
phone numbers, and email addresses.
use Pam\Native\Contacts\Contacts;use Pam\Native\PermissionKind;use Pam\Native\System\Permissions;
Permissions::requestKind(PermissionKind::Contacts, function ($decision): void { if (!$decision->granted()) { return; }
Contacts::all(function (array $contacts): void { foreach ($contacts as $contact) { $this->indexContact($contact->id, $contact->displayName); } });});Contacts::all() reads bounded native pages internally so a large address book
does not exceed the bridge payload limit. Keep the stable ID and reload details
rather than persisting a second unbounded copy of the address book.
Contacts::openNewContactForm() opens the system “new contact” form.
Voice recording
Section titled “Voice recording”AudioRecorder, in pushinbr/pam-native-audio, records AAC/M4A and provides bounded amplitude updates for a
waveform. Start, stop, and other asynchronous operations accept failure
callbacks so the composer can recover when the native recorder is unavailable.
use Pam\Native\Audio\AudioRecorder;use Pam\Native\Audio\AudioRecording;
AudioRecorder::start( function (): void { $this->recording = true; $this->amplitudeSubscription = AudioRecorder::watch( fn ($progress) => $this->amplitude = $progress->amplitude, ); }, fn (string $message) => $this->restoreComposer($message),);
AudioRecorder::stop( function (AudioRecording $recording): void { $this->upload($recording->relativePath, $recording->durationMs); }, fn (string $message) => $this->restoreComposer($message),);Stop amplitude observation with AudioRecorder::unwatch() when its screen
unmounts, and call cancel() if the user leaves mid-recording. The plugin
adds RECORD_AUDIO and a default NSMicrophoneUsageDescription; request
PermissionKind::Microphone first — see Permissions.
Native failures are asynchronous, so product UI should supply failure
callbacks instead of wrapping the original call in try/catch.
use Pam\Native\System\Linking;
Linking::open( 'https://example.com', fn () => $this->recordLinkOpened(), fn (string $message) => $this->offerCopyFallback($message),);canOpen() and initial() expose the same optional final failure callback.
Cold and warm incoming links, intent filters, URI limits, and routing are
covered in Navigation.
Incoming shares
Section titled “Incoming shares”Receiving text, links, and files from other apps’ share sheets is provided by
pushinbr/pam-native-share-extension,
which generates the Android intent filters and the iOS Share Extension.
use Pam\Native\ShareExtension\IncomingShare;use Pam\Native\ShareExtension\IncomingShares;
$openComposer = function (IncomingShare $share): void { $this->draftText = $share->text; $this->draftFiles = $share->files; // FileReference values in the sandbox};
IncomingShares::initial(function (?IncomingShare $share) use ($openComposer): void { if ($share !== null) { $openComposer($share); }});
$subscription = IncomingShares::listen($openComposer);initial() accepts an optional IncomingShareLimits (total bytes, item
count, video items, retention hours) that bounds what is copied into the
sandbox. Call IncomingShares::release($share) once you have moved the files
you keep, and unsubscribe when a short-lived owner no longer needs warm-start
shares.
Background work
Section titled “Background work”BackgroundTasks::begin() requests a finite execution window: a partial wake
lock on Android or UIBackgroundTask on iOS. It is not an unlimited service.
use Pam\Native\System\BackgroundTasks;
BackgroundTasks::begin( name: 'finish-upload', timeoutSeconds: 120, callback: function (int $token): void { $finish = static fn () => BackgroundTasks::end($token);
$this->finishPendingUpload( completed: $finish, failed: $finish, ); },);Always call end(), including on errors. The timeout is clamped to 1–600
seconds, and Android needs android.permission.WAKE_LOCK in pam-native.json. Persist resumable work before the
window expires and move durable synchronization to the native sync APIs.
Timers
Section titled “Timers”Timers are scheduled natively, so PHP is not kept busy while it waits.
timeout() and every() return a TimerHandle you can cancel:
use Pam\Native\System\Timers;
$hint = Timers::timeout(1_500, fn () => $this->showHint = true);
$poll = Timers::every(30_000, fn () => $this->refresh());
// When the screen is hidden or unmounted:$poll->cancel(); // or Timers::cancel($poll)every() runs at most every 16 ms until cancelled; Timers::after() is the
older one-shot form (0 to 86,400,000 ms) without a handle. Start periodic
timers only while the screen is visible and cancel them in paused() and
unmount().
Device interaction utilities
Section titled “Device interaction utilities”Clipboard
Section titled “Clipboard”use Pam\Native\System\Clipboard;
Clipboard::setText('Invite code: PAM42', function (bool $copied): void { $this->copied = $copied;});
Clipboard::hasText(function (bool $available): void { if ($available) { Clipboard::getText(fn (?string $text) => $this->paste($text)); }});Clipboard text is limited to 1 MiB. For one-time codes and other secrets, use
Clipboard::setSensitiveText($text, clearAfterSeconds: 60), which marks the
clip as sensitive and clears it after 15–300 seconds. getText() returns null and hasText()
returns false when the native operation fails.
Haptics and vibration
Section titled “Haptics and vibration”use Pam\Native\HapticFeedback;use Pam\Native\System\Haptics;use Pam\Native\System\Vibration;
Haptics::trigger(HapticFeedback::Success);Vibration::vibrate(80);Semantic haptic cases are Selection, Light, Medium, Heavy, Success,
Warning, and Error. Raw vibration duration is clamped between 1 and 10,000
milliseconds. Prefer semantic haptics for product feedback and respect the
device user’s expectations; vibration is not a substitute for accessible
visual or spoken feedback.
Toasts and the share sheet
Section titled “Toasts and the share sheet”use Pam\Native\System\Share;use Pam\Native\Toast\Toast;
Toast::show('Link copied');Share::text('https://example.com/invite/42', title: 'Invite a friend');Share::text(), Share::files(), and Share::fileToPackage() open the system
share sheet. Toasts live in the optional
pushinbr/pam-native-toast plugin (Pam\Native\Toast\Toast, with
Toast::show() and the richer Toast::message()); the old
Pam\Native\System\Toast name remains as an alias.
Alerts and keyboard
Section titled “Alerts and keyboard”use Pam\Native\System\Alert;use Pam\Native\System\Keyboard;
Keyboard::dismiss();Alert::show( 'Draft saved', 'Your message is available offline.', fn () => $this->afterDismiss(),);Alert::show() invokes the optional closure after dismissal and promotes a
native failure to a runtime exception. Keyboard::dismiss() is fire-and-forget.
SMS drafts
Section titled “SMS drafts”The SMS composer ships with pushinbr/pam-native-contacts.
use Pam\Native\Contacts\Sms;
Sms::isAvailable( callback: function (bool $available): void { if ($available) { Sms::compose( recipients: ['+15555550100'], body: 'Join me on Acme!', failed: fn (string $message) => $this->showError($message), ); } }, failed: fn (string $message) => $this->showError($message),);Sms::compose() only opens the platform composer; it never sends a message.
It accepts 1 to 50 unique non-empty recipients, each at most 128 bytes, and a
body up to 10,000 bytes. Android restricts the intent to smsto: and iOS uses
MFMessageComposeViewController. Devices without a configured SMS service may
legitimately report unavailable.
Lifecycle and recovery
Section titled “Lifecycle and recovery”Android pauses WebView timers and active media from Activity.onPause() and
resumes only media that was playing. iOS applies the same behavior across
active and inactive notifications.
Components implementing Restorable persist on lifecycle transitions.
Navigators restore stacks, selected destinations, and parameters. Picker or
camera operations cancelled by process death must be restarted from restored
product state rather than replayed blindly.
Security and resource limits
Section titled “Security and resource limits”- WebView allowlists apply to exact main-frame hosts and reject executable or custom root schemes.
- WebView main-frame navigation times out after 30 seconds.
- File paths remain canonical inside
pam-files. - Imports stop at 64 MiB; bridge reads and writes stop at 1 MiB.
- SQLite queries stop at 1,000 rows or 256 columns.
- Push queues, IDs, text, deep links, and JSON payloads are bounded.
- Runtime event payloads remain bounded to 1 MiB.
- Continuous observers must be unsubscribed by their owning lifecycle.
Use DevTools to inspect module latency, failures, lifecycle events, and runtime errors while exercising these APIs.
Next steps
Section titled “Next steps”- Permissions — declare and request access correctly.
- Storage — where each kind of data belongs.
- Plugin catalog — capabilities beyond the core.