Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions resources/views/docs/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
1 => '1.x',
2 => '2.x'
]" />
@elseif($platform === 'mobile')
<livewire:version-switcher :versions="[
1 => '1.x',
2 => '2.x'
]" />
@endif

<x-docs.toc-and-sponsors :tableOfContents="$tableOfContents" />
Expand All @@ -30,6 +35,11 @@
1 => '1.x',
2 => '2.x'
]" />
@elseif($platform === 'mobile')
<livewire:version-switcher :versions="[
1 => '1.x',
2 => '2.x'
]" />
@endif

{{-- Copy as Markdown Button --}}
Expand Down
4 changes: 4 additions & 0 deletions resources/views/docs/mobile/2/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: Mobile
order: 1
---
4 changes: 4 additions & 0 deletions resources/views/docs/mobile/2/apis/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: APIs
order: 4
---
61 changes: 61 additions & 0 deletions resources/views/docs/mobile/2/apis/biometrics.md
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
58 changes: 58 additions & 0 deletions resources/views/docs/mobile/2/apis/browser.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
title: Browser
order: 150
---

## Overview

The Browser API provides three methods for opening URLs, each designed for specific use cases:
in-app browsing, system browser navigation, and web authentication flows.

```php
use Native\Mobile\Facades\Browser;
```

## Methods

### `inApp()`

Opens a URL in an embedded browser within your app using Custom Tabs (Android) or SFSafariViewController (iOS).

```php
Browser::inApp('https://nativephp.com/mobile');
```

### `open()`

Opens a URL in the device's default browser app, leaving your application entirely.

```php
Browser::open('https://nativephp.com/mobile');
```

### `auth()`

Opens a URL in a specialized authentication browser designed for OAuth flows with automatic `nativephp://` redirect handling.

```php
Browser::auth('https://provider.com/oauth/authorize?client_id=123&redirect_uri=nativephp://127.0.0.1/auth/callback');
```

## Use Cases

### When to Use Each Method

**`inApp()`** - Keep users within your app experience:
- Documentation, help pages, terms of service
- External content that relates to your app
- When you want users to easily return to your app

**`open()`** - Full browser experience needed:
- Complex web applications
- Content requiring specific browser features
- When users need bookmarking or sharing capabilities

**`auth()`** - OAuth authentication flows:
- Login with WorkOS, Auth0, Google, Facebook, etc.
- Secure authentication with automatic redirects
- Isolated browser session for security
90 changes: 90 additions & 0 deletions resources/views/docs/mobile/2/apis/camera.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
---
title: Camera
order: 200
---

## Overview

The Camera API provides access to the device's camera for taking photos and selecting images from the gallery.

```php
use Native\Mobile\Facades\Camera;
```

## Methods

### `getPhoto()`

Opens the camera interface to take a photo.

```php
Camera::getPhoto();
```

### `pickImages()`

Opens the gallery/photo picker to select existing images.

**Parameters:**
- `string $media_type` - Type of media to pick: `'all'`, `'images'`, `'videos'` (default: `'all'`)
- `bool $multiple` - Allow multiple selection (default: `false`)

**Returns:** `bool` - `true` if picker opened successfully

```php
// Pick a single image
Camera::pickImages('images', false);

// Pick multiple images
Camera::pickImages('images', true);

// Pick any media type
Camera::pickImages('all', true);
```

## Events

### `PhotoTaken`

Fired when a photo is taken with the camera.

**Payload:** `string $path` - File path to the captured photo

```php
use Livewire\Attributes\On;
use Native\Mobile\Events\Camera\PhotoTaken;

#[On('native:'.PhotoTaken::class)]
public function handlePhotoTaken(string $path)
{
// Process the captured photo
$this->processPhoto($path);
}
```

### `MediaSelected`

Fired when media is selected from the gallery.

**Payload:** `array $media` - Array of selected media items

```php
use Livewire\Attributes\On;
use Native\Mobile\Events\Gallery\MediaSelected;

#[On('native:'.MediaSelected::class)]
public function handleMediaSelected($success, $files, $count)
{
foreach ($files as $file) {
// Process each selected media item
$this->processMedia($file);
}
}
```

## Notes

- The first time your app requests camera access, users will be prompted for permission
- If permission is denied, camera functions will fail silently
- Captured photos are stored in the app's temporary directory
- File formats are platform-dependent (typically JPEG)
55 changes: 55 additions & 0 deletions resources/views/docs/mobile/2/apis/device.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
title: Device
order: 200
---

## Overview

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.
```php
use Native\Mobile\Facades\Device;
```

## Methods

### `getId()`

Return a unique identifier for the device.

Returns: `string`

### `getInfo()`

Return information about the underlying device/os/platform.

Returns JSON encoded: `string`


### `getBatteryInfo()`

Return information about the battery.

Returns JSON encoded: `string`

## Device Info

| Prop | Type | Description
|---|---|---|---|
| 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.
| model | string | The device model. For example, "iPhone13,4".
| platform | 'ios' \| 'android' | The device platform (lowercase).
| operatingSystem | string | The operating system of the device.
| osVersion | string | The version of the device OS.
| 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 |
| androidSDKVersion | number | The Android SDK version number. Only available on Android. | 5.0.0 |
| manufacturer | string | The manufacturer of the device.
| isVirtual | boolean | Whether the app is running in a simulator/emulator.
| memUsed | number | Approximate memory used by the current app, in bytes. Divide by 1,048,576 to get MBs used.
| webViewVersion | string | The web view browser version.

## Battery Info

| Prop | Type | Description
|---|---|---|---|
| batteryLevel | number | A percentage (0 to 1) indicating how much the battery is charged.
| isCharging | boolean | Whether the device is charging.
Loading
Loading