-
-
Notifications
You must be signed in to change notification settings - Fork 94
Mobile v2 Docs #228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Mobile v2 Docs #228
Changes from 4 commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
9192d51
Add mobile 2.x documentation and version switcher
shanerbaner82 6da5c5d
Add horizontal scrolling to wide tables in documentation
shanerbaner82 673125e
Update mobile 2.x documentation with API details and improvements
shanerbaner82 bbffdc9
Merge branch 'main' into mobile-v2-docs
shanerbaner82 8b598be
Merge branch 'main' into mobile-v2-docs
simonhamp c38e116
wip
simonhamp 8f1f400
wip
simonhamp 3589fd5
Bump deps
simonhamp 0cf2b44
Extract class list to element style
simonhamp 247845a
Development and Deployment
simonhamp 632a796
OnNative
simonhamp 493ff3b
Reorg
simonhamp 4e6295f
Simplify
simonhamp 968e85c
Improve
simonhamp 4efa6ea
Add version warning
simonhamp 6c8ed22
Add EDGE intro
simonhamp d8ef32a
Add image
simonhamp fe35ec8
Events
simonhamp 28718eb
Updates changelog
shanerbaner82 a8b9dd2
Remove CI/CD page (now in Deployment)
simonhamp fbf5c38
Improve EDGE intros
simonhamp 7f3960c
Reorg
simonhamp 1021473
Add JS installation docs
simonhamp 6cc85d1
Reorg
simonhamp b7bf82e
Improve
simonhamp 34ee895
EDGE
simonhamp c6cc45f
Icons
simonhamp 389c33c
OnNative
simonhamp 088513c
Fix handler example
simonhamp a887903
Security and Authentication
simonhamp 27f9b4b
Deprecation
simonhamp b815117
Cleanup
simonhamp 19b7753
Clean the changelog
simonhamp 9e1be6d
Fix Boost paragraph
simonhamp 13c5dff
Merge branch 'main' into mobile-v2-docs
simonhamp d653ca5
Remove v1 doc change
simonhamp c654181
Final tweaks (#234)
shanerbaner82 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| --- | ||
| title: Mobile | ||
| order: 1 | ||
| --- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| --- | ||
| title: APIs | ||
| order: 4 | ||
| --- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,201 @@ | ||
| --- | ||
| title: Audio | ||
| order: 50 | ||
| --- | ||
|
|
||
| ## Overview | ||
|
|
||
| The Audio API provides access to the device's microphone for recording audio. It offers a fluent interface for starting and managing recordings, tracking them with unique identifiers, and responding to completion events. | ||
|
|
||
| ```php | ||
| use Native\Mobile\Facades\Audio; | ||
| ``` | ||
|
|
||
| ## Methods | ||
|
|
||
| ### `record()` | ||
|
|
||
| Start an audio recording. Returns a `PendingAudioRecorder` instance that controls the recording lifecycle. | ||
|
|
||
| ```php | ||
| Audio::record()->start(); | ||
| ``` | ||
|
|
||
| ### `stop()` | ||
|
|
||
| Stop the current audio recording. This dispatches the `AudioRecorded` event with the recording file path. | ||
|
|
||
| ```php | ||
| Audio::stop(); | ||
| ``` | ||
|
|
||
| ### `pause()` | ||
|
|
||
| Pause the current audio recording without ending it. | ||
|
|
||
| ```php | ||
| Audio::pause(); | ||
| ``` | ||
|
|
||
| ### `resume()` | ||
|
|
||
| Resume a paused audio recording. | ||
|
|
||
| ```php | ||
| Audio::resume(); | ||
| ``` | ||
|
|
||
| ### `getStatus()` | ||
|
|
||
| Get the current recording status. | ||
|
|
||
| **Returns:** `string` - One of: `"idle"`, `"recording"`, or `"paused"` | ||
|
|
||
| ```php | ||
| $status = Audio::getStatus(); | ||
|
|
||
| if ($status === 'recording') { | ||
| // A recording is in progress | ||
| } | ||
| ``` | ||
|
|
||
| ### `getRecording()` | ||
|
|
||
| Get the file path to the last recorded audio file. | ||
|
|
||
| **Returns:** `string|null` - Path to the last recording, or `null` if none exists | ||
|
|
||
| ```php | ||
| $path = Audio::getRecording(); | ||
|
|
||
| if ($path) { | ||
| // Process the recording file | ||
| } | ||
| ``` | ||
|
|
||
| ## PendingAudioRecorder | ||
|
|
||
| The `PendingAudioRecorder` provides a fluent interface for configuring and starting audio recordings. Most methods return `$this` for method chaining. | ||
|
|
||
| ### `id(string $id)` | ||
|
|
||
| Set a unique identifier for this recording. This ID will be included in the `AudioRecorded` event, allowing you to correlate recordings with completion events. | ||
|
|
||
| ```php | ||
| $recorderId = 'message-recording-' . $this->id; | ||
|
|
||
| Audio::record() | ||
| ->id($recorderId) | ||
| ->start(); | ||
| ``` | ||
|
|
||
| ### `getId()` | ||
|
|
||
| Get the recorder's unique identifier. If no ID was set, one is automatically generated (UUID v4). | ||
|
|
||
| ```php | ||
| $recorder = Audio::record() | ||
| ->id('my-recording'); | ||
|
|
||
| $id = $recorder->getId(); // 'my-recording' | ||
| ``` | ||
|
|
||
| ### `event(string $eventClass)` | ||
|
|
||
| Set a custom event class to dispatch when recording completes. By default, `AudioRecorded` is used. | ||
|
|
||
| **Throws:** `InvalidArgumentException` if the event class does not exist | ||
|
|
||
| ```php | ||
| use App\Events\VoiceMessageRecorded; | ||
|
|
||
| Audio::record() | ||
| ->event(VoiceMessageRecorded::class) | ||
| ->start(); | ||
| ``` | ||
|
|
||
| ### `remember()` | ||
|
|
||
| Store the recorder's ID in the session for later retrieval. This is useful when the recording completes on the next request. | ||
|
|
||
| ```php | ||
| Audio::record() | ||
| ->id('voice-note') | ||
| ->remember() | ||
| ->start(); | ||
| ``` | ||
|
|
||
| ### `lastId()` | ||
|
|
||
| Retrieve the last remembered audio recorder ID from the session. Use this in event listeners to correlate recordings. | ||
|
|
||
| ```php | ||
| use Livewire\Attributes\On; | ||
| use Native\Mobile\Events\Audio\AudioRecorded; | ||
|
|
||
| #[On('native:'.AudioRecorded::class)] | ||
| public function handleAudioRecorded(string $path, string $mimeType, ?string $id) | ||
| { | ||
| // For comparing with remembered IDs | ||
| if ($id === Audio::record()->lastId()) { | ||
| $this->saveRecording($path); | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### `start()` | ||
|
|
||
| Explicitly start the audio recording. This is optional - recordings auto-start if you don't call this method. | ||
|
|
||
| **Returns:** `bool` - `true` if recording started successfully, `false` if it failed or was already started | ||
|
|
||
| ```php | ||
| $recorder = Audio::record()->id('my-recording'); | ||
|
|
||
| if ($recorder->start()) { | ||
| // Recording started | ||
| } else { | ||
| // Recording failed - likely due to permission denial | ||
| } | ||
| ``` | ||
|
|
||
| ## Events | ||
|
|
||
| ### `AudioRecorded` | ||
|
|
||
| Dispatched when an audio recording completes. The event includes the file path and recording ID. | ||
|
|
||
| **Payload:** | ||
| - `string $path` - File path to the recorded audio | ||
| - `string $mimeType` - MIME type of the audio (default: `'audio/m4a'`) | ||
| - `?string $id` - The recorder's ID, if one was set | ||
|
|
||
| ```php | ||
| use Livewire\Attributes\On; | ||
| use Native\Mobile\Events\Audio\AudioRecorded; | ||
|
|
||
| #[On('native:'.AudioRecorded::class)] | ||
| public function handleAudioRecorded(string $path, string $mimeType, ?string $id) | ||
| { | ||
| // Store or process the recording | ||
| $this->recordings[] = [ | ||
| 'path' => $path, | ||
| 'mimeType' => $mimeType, | ||
| 'id' => $id, | ||
| ]; | ||
| } | ||
| ``` | ||
|
|
||
| ## Notes | ||
|
|
||
| - **Microphone Permission:** The first time your app requests microphone access, users will be prompted for permission. If denied, recording functions will fail silently. | ||
|
|
||
| - **File Format:** Recordings are stored as M4A/AAC audio files (`.m4a`). This format is optimized for small file sizes while maintaining quality. | ||
|
|
||
| - **Storage Location:** | ||
| - **Android:** Recordings are stored in the app's cache directory (`context.cacheDir/audio_{timestamp}.m4a`). These are temporary files and may be deleted by the system. | ||
| - **iOS:** Recordings are stored persistently in `~/Library/Application Support/Audio/NativePHP_{timestamp}.m4a` and are excluded from iCloud backup. | ||
|
|
||
| - **Recording State:** Only one recording can be active at a time. Calling `start()` while a recording is in progress will return `false`. | ||
|
|
||
| - **Auto-Start Behavior:** If you don't explicitly call `start()`, the recording will automatically start when the `PendingAudioRecorder` is destroyed. This maintains backward compatibility with earlier versions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| --- | ||
| title: Biometrics | ||
| order: 100 | ||
| --- | ||
|
|
||
| ## Overview | ||
|
|
||
| The Biometrics API allows you to authenticate users using their device's biometric sensors like Face ID, Touch ID, or | ||
| fingerprint scanners. | ||
|
|
||
| ```php | ||
| use Native\Mobile\Facades\Biometrics; | ||
| ``` | ||
|
|
||
| ## Methods | ||
|
|
||
| ### `prompt()` | ||
|
|
||
| Prompts the user for biometric authentication. | ||
|
|
||
| ```php | ||
| use Native\Mobile\Facades\Biometrics; | ||
|
|
||
| Biometrics::prompt(); | ||
| ``` | ||
|
|
||
| ## Events | ||
|
|
||
| ### `Completed` | ||
|
|
||
| Fired when biometric authentication completes (success or failure). | ||
|
|
||
| ```php | ||
| use Livewire\Attributes\On; | ||
| use Native\Mobile\Events\Biometric\Completed; | ||
|
|
||
| #[On('native:'.Completed::class)] | ||
| public function handle(Completed $event) | ||
| { | ||
| if ($event->success) { | ||
| // User authenticated successfully | ||
| $this->unlockSecureFeature(); | ||
| } else { | ||
| // Authentication failed | ||
| $this->showErrorMessage(); | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Platform Support | ||
|
|
||
| - **iOS:** Face ID, Touch ID | ||
| - **Android:** Fingerprint, Face unlock, other biometric methods | ||
| - **Fallback:** System authentication (PIN, password, pattern) | ||
|
|
||
| ## Security Notes | ||
|
|
||
| - Biometric authentication provides **convenience**, not absolute security | ||
| - Always combine with other authentication factors for sensitive operations | ||
| - Consider implementing session timeouts for unlocked states | ||
| - Users can potentially bypass biometrics if their device is compromised |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need context aware filtering in the algolia results. Once this is merged results from 4 versions will show up (desktop & mobile v1 + v2)