Skip to content

Commit 9192d51

Browse files
committed
Add mobile 2.x documentation and version switcher
Introduces comprehensive documentation for the mobile 2.x platform, including API references (biometrics, browser, camera, device, dialog, geolocation, haptics, push notifications, QR code, secure storage, system), concepts (CI/CD, databases, deep links, push notifications, security), and EDGE components (bottom nav, FAB, side nav, top bar). Also updates the docs index view to support a version switcher for the mobile platform.
1 parent e903e51 commit 9192d51

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+3045
-0
lines changed

resources/views/docs/index.blade.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
1 => '1.x',
1111
2 => '2.x'
1212
]" />
13+
@elseif($platform === 'mobile')
14+
<livewire:version-switcher :versions="[
15+
1 => '1.x',
16+
2 => '2.x'
17+
]" />
1318
@endif
1419

1520
<x-docs.toc-and-sponsors :tableOfContents="$tableOfContents" />
@@ -30,6 +35,11 @@
3035
1 => '1.x',
3136
2 => '2.x'
3237
]" />
38+
@elseif($platform === 'mobile')
39+
<livewire:version-switcher :versions="[
40+
1 => '1.x',
41+
2 => '2.x'
42+
]" />
3343
@endif
3444

3545
{{-- Copy as Markdown Button --}}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
title: Mobile
3+
order: 1
4+
---
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
title: APIs
3+
order: 4
4+
---
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
title: Biometrics
3+
order: 100
4+
---
5+
6+
## Overview
7+
8+
The Biometrics API allows you to authenticate users using their device's biometric sensors like Face ID, Touch ID, or
9+
fingerprint scanners.
10+
11+
```php
12+
use Native\Mobile\Facades\Biometrics;
13+
```
14+
15+
## Methods
16+
17+
### `prompt()`
18+
19+
Prompts the user for biometric authentication.
20+
21+
```php
22+
use Native\Mobile\Facades\Biometrics;
23+
24+
Biometrics::prompt();
25+
```
26+
27+
## Events
28+
29+
### `Completed`
30+
31+
Fired when biometric authentication completes (success or failure).
32+
33+
```php
34+
use Livewire\Attributes\On;
35+
use Native\Mobile\Events\Biometric\Completed;
36+
37+
#[On('native:'.Completed::class)]
38+
public function handle(Completed $event)
39+
{
40+
if ($event->success) {
41+
// User authenticated successfully
42+
$this->unlockSecureFeature();
43+
} else {
44+
// Authentication failed
45+
$this->showErrorMessage();
46+
}
47+
}
48+
```
49+
50+
## Platform Support
51+
52+
- **iOS:** Face ID, Touch ID
53+
- **Android:** Fingerprint, Face unlock, other biometric methods
54+
- **Fallback:** System authentication (PIN, password, pattern)
55+
56+
## Security Notes
57+
58+
- Biometric authentication provides **convenience**, not absolute security
59+
- Always combine with other authentication factors for sensitive operations
60+
- Consider implementing session timeouts for unlocked states
61+
- Users can potentially bypass biometrics if their device is compromised
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
title: Browser
3+
order: 150
4+
---
5+
6+
## Overview
7+
8+
The Browser API provides three methods for opening URLs, each designed for specific use cases:
9+
in-app browsing, system browser navigation, and web authentication flows.
10+
11+
```php
12+
use Native\Mobile\Facades\Browser;
13+
```
14+
15+
## Methods
16+
17+
### `inApp()`
18+
19+
Opens a URL in an embedded browser within your app using Custom Tabs (Android) or SFSafariViewController (iOS).
20+
21+
```php
22+
Browser::inApp('https://nativephp.com/mobile');
23+
```
24+
25+
### `open()`
26+
27+
Opens a URL in the device's default browser app, leaving your application entirely.
28+
29+
```php
30+
Browser::open('https://nativephp.com/mobile');
31+
```
32+
33+
### `auth()`
34+
35+
Opens a URL in a specialized authentication browser designed for OAuth flows with automatic `nativephp://` redirect handling.
36+
37+
```php
38+
Browser::auth('https://provider.com/oauth/authorize?client_id=123&redirect_uri=nativephp://127.0.0.1/auth/callback');
39+
```
40+
41+
## Use Cases
42+
43+
### When to Use Each Method
44+
45+
**`inApp()`** - Keep users within your app experience:
46+
- Documentation, help pages, terms of service
47+
- External content that relates to your app
48+
- When you want users to easily return to your app
49+
50+
**`open()`** - Full browser experience needed:
51+
- Complex web applications
52+
- Content requiring specific browser features
53+
- When users need bookmarking or sharing capabilities
54+
55+
**`auth()`** - OAuth authentication flows:
56+
- Login with WorkOS, Auth0, Google, Facebook, etc.
57+
- Secure authentication with automatic redirects
58+
- Isolated browser session for security
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
---
2+
title: Camera
3+
order: 200
4+
---
5+
6+
## Overview
7+
8+
The Camera API provides access to the device's camera for taking photos and selecting images from the gallery.
9+
10+
```php
11+
use Native\Mobile\Facades\Camera;
12+
```
13+
14+
## Methods
15+
16+
### `getPhoto()`
17+
18+
Opens the camera interface to take a photo.
19+
20+
```php
21+
Camera::getPhoto();
22+
```
23+
24+
### `pickImages()`
25+
26+
Opens the gallery/photo picker to select existing images.
27+
28+
**Parameters:**
29+
- `string $media_type` - Type of media to pick: `'all'`, `'images'`, `'videos'` (default: `'all'`)
30+
- `bool $multiple` - Allow multiple selection (default: `false`)
31+
32+
**Returns:** `bool` - `true` if picker opened successfully
33+
34+
```php
35+
// Pick a single image
36+
Camera::pickImages('images', false);
37+
38+
// Pick multiple images
39+
Camera::pickImages('images', true);
40+
41+
// Pick any media type
42+
Camera::pickImages('all', true);
43+
```
44+
45+
## Events
46+
47+
### `PhotoTaken`
48+
49+
Fired when a photo is taken with the camera.
50+
51+
**Payload:** `string $path` - File path to the captured photo
52+
53+
```php
54+
use Livewire\Attributes\On;
55+
use Native\Mobile\Events\Camera\PhotoTaken;
56+
57+
#[On('native:'.PhotoTaken::class)]
58+
public function handlePhotoTaken(string $path)
59+
{
60+
// Process the captured photo
61+
$this->processPhoto($path);
62+
}
63+
```
64+
65+
### `MediaSelected`
66+
67+
Fired when media is selected from the gallery.
68+
69+
**Payload:** `array $media` - Array of selected media items
70+
71+
```php
72+
use Livewire\Attributes\On;
73+
use Native\Mobile\Events\Gallery\MediaSelected;
74+
75+
#[On('native:'.MediaSelected::class)]
76+
public function handleMediaSelected($success, $files, $count)
77+
{
78+
foreach ($files as $file) {
79+
// Process each selected media item
80+
$this->processMedia($file);
81+
}
82+
}
83+
```
84+
85+
## Notes
86+
87+
- The first time your app requests camera access, users will be prompted for permission
88+
- If permission is denied, camera functions will fail silently
89+
- Captured photos are stored in the app's temporary directory
90+
- File formats are platform-dependent (typically JPEG)
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
title: Device
3+
order: 200
4+
---
5+
6+
## Overview
7+
8+
The Device API exposes internal information about the device, such as the model and operating system version, along with user information such as unique ids.
9+
```php
10+
use Native\Mobile\Facades\Device;
11+
```
12+
13+
## Methods
14+
15+
### `getId()`
16+
17+
Return a unique identifier for the device.
18+
19+
Returns: `string`
20+
21+
### `getInfo()`
22+
23+
Return information about the underlying device/os/platform.
24+
25+
Returns JSON encoded: `string`
26+
27+
28+
### `getBatteryInfo()`
29+
30+
Return information about the battery.
31+
32+
Returns JSON encoded: `string`
33+
34+
## Device Info
35+
36+
| Prop | Type | Description
37+
|---|---|---|---|
38+
| name | string | The name of the device. For example, "John's iPhone". On iOS 16+ this will return a generic device name without the appropriate entitlements.
39+
| model | string | The device model. For example, "iPhone13,4".
40+
| platform | 'ios' \| 'android' | The device platform (lowercase).
41+
| operatingSystem | string | The operating system of the device.
42+
| osVersion | string | The version of the device OS.
43+
| iOSVersion | number | The iOS version number. Only available on iOS. Multi-part version numbers are crushed down into an integer padded to two-digits, e.g., "16.3.1" → `160301`. | 5.0.0 |
44+
| androidSDKVersion | number | The Android SDK version number. Only available on Android. | 5.0.0 |
45+
| manufacturer | string | The manufacturer of the device.
46+
| isVirtual | boolean | Whether the app is running in a simulator/emulator.
47+
| memUsed | number | Approximate memory used by the current app, in bytes. Divide by 1,048,576 to get MBs used.
48+
| webViewVersion | string | The web view browser version.
49+
50+
## Battery Info
51+
52+
| Prop | Type | Description
53+
|---|---|---|---|
54+
| batteryLevel | number | A percentage (0 to 1) indicating how much the battery is charged.
55+
| isCharging | boolean | Whether the device is charging.

0 commit comments

Comments
 (0)