Skip to content

πŸ“š Mobile v1.1 Documentation Updates #178

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 18 commits into from
Jul 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
593fde1
Updates some of the docs for mobile
shanerbaner82 Jun 1, 2025
9fefd45
Updates ordering for docs
shanerbaner82 Jun 1, 2025
e6d3fa0
Merge branch 'main' into docs-updates
shanerbaner82 Jun 15, 2025
a699a30
updates doc
shanerbaner82 Jun 15, 2025
bdcac7b
πŸ“š Update mobile v1.1 documentation structure and content
shanerbaner82 Jul 7, 2025
6783490
Resolve merge conflicts with main branch
shanerbaner82 Jul 7, 2025
c364c16
Merge remote-tracking branch 'origin/main' into v1.1-docs-updates
shanerbaner82 Jul 7, 2025
cd6f1d0
Update resources/views/docs/mobile/1/apis/camera.md
shanerbaner82 Jul 7, 2025
1c0ad47
More docs updates
shanerbaner82 Jul 8, 2025
033fd97
Update mobile documentation with enhanced deep links, push notificati…
shanerbaner82 Jul 9, 2025
69832bf
Update Dialog API documentation for new alert implementation
shanerbaner82 Jul 10, 2025
4ba3bdc
Add Browser API documentation for in-app browser functionality
shanerbaner82 Jul 10, 2025
36c6d88
Update resources/views/docs/mobile/1/the-basics/icu-support.md
shanerbaner82 Jul 10, 2025
df3c84a
Update resources/views/docs/mobile/1/apis/browser.md
shanerbaner82 Jul 10, 2025
90ae4c3
Update mobile documentation with API improvements and platform notes
shanerbaner82 Jul 10, 2025
14bbdf7
Simplify versioning documentation with Laravel-inspired approach
shanerbaner82 Jul 10, 2025
0c7714c
Update Browser API documentation with new methods and improved structure
shanerbaner82 Jul 10, 2025
639ec1d
polish (#182)
simonhamp Jul 13, 2025
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
4 changes: 2 additions & 2 deletions app/Http/Controllers/ShowDocumentationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public function __invoke(Request $request, string $platform, string $version, ?s
} catch (InvalidArgumentException $e) {
return $this->redirectToFirstNavigationPage($navigation, $page);
}

SEOTools::setTitle($pageProperties['title'].' - NativePHP '.$platform.' v'.$version);
SEOTools::setDescription(Arr::exists($pageProperties, 'description') ? $pageProperties['description'] : '');

Expand All @@ -65,7 +64,8 @@ protected function getPageProperties($platform, $version, $page = null): array
$pageProperties = $document->matter();

$versionProperties = YamlFrontMatter::parseFile(resource_path("views/docs/{$platform}/{$version}/_index.md"));
$pageProperties = array_merge($pageProperties, $versionProperties->matter());

$pageProperties = array_merge($versionProperties->matter(), $pageProperties);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessarily an issue but can you help me understand why the order of arguments were switched here? Was something being overwritten we wasn't expecting? πŸ‘€

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually yeah, and maybe you can verify, locally for me every page showed "Mobile" as the title of the document, reversing this fixed it for me. On the website currently it works fine now, not sure what's going on tbh and I didn't switch it back.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On my end I see the title NativePHP on every page. Looks like the title tag is present in the head twice.

By editing $pageProperties the second title tag does change, but my browser only picks up the first one so I can't see it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might depend on your cache driver, I haven't played with it but saw some code about cacheing if local...


$pageProperties['platform'] = $platform;
$pageProperties['version'] = $version;
Expand Down
4 changes: 4 additions & 0 deletions resources/views/docs/mobile/1/_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/1/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/1/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

### `promptForBiometricID()`

Prompts the user for biometric authentication.

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

Biometrics::promptForBiometricID();
```

## 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 handleBiometricAuth(bool $success)
{
if ($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/1/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');
```

### `system()`

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

```php
Browser::system('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

**`system()`** - 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/1/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)
103 changes: 103 additions & 0 deletions resources/views/docs/mobile/1/apis/dialog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
---
title: Dialog
order: 300
---

## Overview

The Dialog API provides access to native UI elements like alerts, toasts, and sharing interfaces.

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

## Methods

### `alert()`

Displays a native alert dialog with customizable buttons.

**Parameters:**
- `string $title` - The alert title
- `string $message` - The alert message
- `array $buttons` - Array of button labels (max 3 buttons)

**Button Positioning:**
- **1 button** - Positive (OK/Confirm)
- **2 buttons** - Negative (Cancel) + Positive (OK/Confirm)
- **3 buttons** - Negative (Cancel) + Neutral (Maybe) + Positive (OK/Confirm)

```php
Dialog::alert(
'Confirm Action',
'Are you sure you want to delete this item?',
['Cancel', 'Delete']
);
```

### `toast()`

Displays a brief toast notification message.


**Parameters:**
- `string $message` - The message to display

```php
Dialog::toast('Item saved successfully!');
```

#### Good toast messages

- Short and clear
- Great for confirmations and status updates
- Don't rely on them for critical information
- Avoid showing multiple toasts in quick succession

### `share()`

Opens the native sharing interface.

**Parameters:**
- `string $title` - The share dialog title
- `string $text` - Text content to share
- `string $url` - URL to share

```php
Dialog::share(
'Check this out!',
'I found this amazing Laravel package for mobile development',
'https://nativephp.com'
);
```

## Events

### `ButtonPressed`

Fired when a button is pressed in an alert dialog.

**Payload:**
- `int $index` - Index of the pressed button (0-based)
- `string $label` - Label/text of the pressed button

```php
use Livewire\Attributes\On;
use Native\Mobile\Events\Alert\ButtonPressed;

#[On('native:'.ButtonPressed::class)]
public function handleAlertButton($index, $label)
{
switch ($index) {
case 0:
// First button (usually Cancel)
Dialog::toast("You pressed '{$label}'");
break;
case 1:
// Second button (usually OK/Confirm)
$this->performAction();
Dialog::toast("You pressed '{$label}'");
break;
}
}
```
Loading