Skip to content

Polish #182

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 1 commit into from
Jul 13, 2025
Merged
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
95 changes: 0 additions & 95 deletions resources/views/docs/mobile/1/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,98 +2,3 @@
title: Mobile
order: 1
---

# NativePHP for Mobile

**Build native iOS and Android apps with PHP and Laravel**

NativePHP for Mobile revolutionizes mobile development by allowing PHP developers to create native mobile applications using the languages and frameworks they already know and love. No need to learn Swift, Kotlin, or React Native - just pure PHP and Laravel.

## What Makes NativePHP Mobile Special?

📱**Native Performance** - Your app runs natively on device with embedded PHP runtime
🔥**True Mobile APIs** - Access camera, biometrics, push notifications, and more
⚡ **Laravel Powered** - Use your existing Laravel skills and ecosystem
🚫**No Web Server** - Your app runs entirely on-device
🔄**Cross Platform** - Single codebase for iOS and Android

## Quick Start

Get your first mobile app running in minutes:

```bash
# Install NativePHP Mobile
composer require nativephp/mobile

# Configure your app
php artisan native:install

# Run your app
php artisan native:run
```

## Current Features (v1.1)

**Available now:**
- 📷 Camera & Gallery access
- 🔐 Biometric authentication (Face ID, Touch ID, Fingerprint)
- 🔔 Push notifications via Firebase
- 💬 Native dialogs & toasts
- 🔗 Deep links & universal links
- 📱 NFC support
- 📳 Haptic feedback & vibration
- 🔦 Flashlight control
- 📤 Native sharing
- 🔒 Secure storage (Keychain/Keystore)
- 📍 Location services

[See the complete roadmap 🗺️](/docs/mobile/1/getting-started/roadmap)

## Documentation Sections

### [Getting Started](/docs/mobile/1/getting-started)
Everything you need to start building mobile apps with PHP:
- [Introduction](/docs/mobile/1/getting-started/introduction) - Learn how NativePHP Mobile works
- [Installation](/docs/mobile/1/getting-started/installation) - Set up your development environment
- [Environment Setup](/docs/mobile/1/getting-started/environment-setup) - Configure iOS and Android tools
- [Configuration](/docs/mobile/1/getting-started/configuration) - App settings and permissions
- [Development](/docs/mobile/1/getting-started/development) - Development workflow
- [Roadmap](/docs/mobile/1/getting-started/roadmap) - Current and planned features

### [The Basics](/docs/mobile/1/the-basics)
Core concepts and fundamental knowledge:
- [Native Functions](/docs/mobile/1/the-basics/native-functions) - Understanding sync vs async APIs
- [Asynchronous Methods](/docs/mobile/1/the-basics/asynchronous-methods) - Event-driven mobile development
- [ICU Support](/docs/mobile/1/the-basics/icu-support) - International components for Unicode

### [Concepts](/docs/mobile/1/concepts)
Important concepts for mobile app development:
- [CI/CD](/docs/mobile/1/concepts/ci-cd) - Continuous integration and deployment
- [Deep Links](/docs/mobile/1/concepts/deep-links) - Universal links, app links, and NFC
- [Push Notifications](/docs/mobile/1/concepts/push-notifications) - Firebase Cloud Messaging setup
- [Splash Screen/Icons](/docs/mobile/1/concepts/splash-screen-icons) - App branding and assets
- [Versioning](/docs/mobile/1/concepts/versioning) - App version management

### [APIs](/docs/mobile/1/apis)
Complete API reference for all native features:
- [Biometrics](/docs/mobile/1/apis/biometrics) - Face ID, Touch ID, fingerprint authentication
- [Camera](/docs/mobile/1/apis/camera) - Photo capture and gallery access
- [Dialog](/docs/mobile/1/apis/dialog) - Alerts, toasts, and sharing
- [Geolocation](/docs/mobile/1/apis/geolocation) - GPS and location services
- [Haptics](/docs/mobile/1/apis/haptics) - Vibration and tactile feedback
- [PushNotifications](/docs/mobile/1/apis/push-notifications) - FCM token management
- [SecureStorage](/docs/mobile/1/apis/secure-storage) - Keychain and keystore operations
- [System](/docs/mobile/1/apis/system) - Flashlight and legacy methods

### [Digging Deeper](/docs/mobile/1/digging-deeper)
Advanced topics for production apps:
- [Databases](/docs/mobile/1/digging-deeper/databases) - SQLite and data management
- [Security](/docs/mobile/1/digging-deeper/security) - Best practices and secure storage

## Need Help?

- **License Required** - [Purchase your license](https://nativephp.com/mobile) to get started
- **Community** - Join our Discord for support and discussions
- **Examples** - Check out the Kitchen Sink demo app (coming soon to app stores)

Ready to build your first mobile app with PHP? [Let's get started! 🚀](/docs/mobile/1/getting-started/introduction)
50 changes: 9 additions & 41 deletions resources/views/docs/mobile/1/apis/biometrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ 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.
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;
Expand All @@ -17,6 +18,12 @@ use Native\Mobile\Facades\Biometrics;

Prompts the user for biometric authentication.

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

Biometrics::promptForBiometricID();
```

## Events

### `Completed`
Expand All @@ -27,7 +34,7 @@ Fired when biometric authentication completes (success or failure).
use Livewire\Attributes\On;
use Native\Mobile\Events\Biometric\Completed;

#[On('native:' . Completed::class)]
#[On('native:'.Completed::class)]
public function handleBiometricAuth(bool $success)
{
if ($success) {
Expand All @@ -40,45 +47,6 @@ public function handleBiometricAuth(bool $success)
}
```

## Example Usage

```php
use Livewire\Component;
use Livewire\Attributes\On;
use Native\Mobile\Facades\Biometrics;
use Native\Mobile\Events\Biometric\Completed;

class SecureArea extends Component
{
public bool $isUnlocked = false;
public bool $isAuthenticating = false;

public function authenticate()
{
$this->isAuthenticating = true;
Biometrics::promptForBiometricID();
}

#[On('native:' . Completed::class)]
public function handleBiometricAuth(bool $success)
{
$this->isAuthenticating = false;

if ($success) {
$this->isUnlocked = true;
session(['biometric_authenticated' => true]);
} else {
$this->addError('auth', 'Biometric authentication failed');
}
}

public function render()
{
return view('livewire.secure-area');
}
}
```

## Platform Support

- **iOS:** Face ID, Touch ID
Expand Down
13 changes: 3 additions & 10 deletions resources/views/docs/mobile/1/apis/browser.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
---
title: Browser
order: 250
order: 150
---

## Overview

The Browser API provides three methods for opening URLs in mobile apps, each designed for specific use cases: in-app browsing, system browser navigation, and OAuth authentication flows.
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;
Expand Down Expand Up @@ -55,11 +56,3 @@ Browser::auth('https://provider.com/oauth/authorize?client_id=123&redirect_uri=n
- Login with WorkOS, Auth0, Google, Facebook, etc.
- Secure authentication with automatic redirects
- Isolated browser session for security

## Platform Behavior

- **iOS**: Uses SFSafariViewController (inApp), Safari (system), ASWebAuthenticationSession (auth)
- **Android**: Uses Custom Tabs (inApp), default browser (system), Custom Tabs with auth handling (auth)

The Browser API provides the right tool for each browsing scenario in your mobile application.

75 changes: 2 additions & 73 deletions resources/views/docs/mobile/1/apis/camera.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Fired when a photo is taken with the camera.
use Livewire\Attributes\On;
use Native\Mobile\Events\Camera\PhotoTaken;

#[On('native:' . PhotoTaken::class)]
#[On('native:'.PhotoTaken::class)]
public function handlePhotoTaken(string $path)
{
// Process the captured photo
Expand All @@ -72,7 +72,7 @@ Fired when media is selected from the gallery.
use Livewire\Attributes\On;
use Native\Mobile\Events\Gallery\MediaSelected;

#[On('native:' . MediaSelected::class)]
#[On('native:'.MediaSelected::class)]
public function handleMediaSelected($success, $files, $count)
{
foreach ($files as $file) {
Expand All @@ -82,80 +82,9 @@ public function handleMediaSelected($success, $files, $count)
}
```

## Example Usage

```php
use Livewire\Component;
use Livewire\Attributes\On;
use Native\Mobile\Facades\Camera;
use Native\Mobile\Events\Camera\PhotoTaken;
use Native\Mobile\Events\Gallery\MediaSelected;

class PhotoManager extends Component
{
public array $photos = [];
public bool $isCapturing = false;

public function takePhoto()
{
$this->isCapturing = true;
Camera::getPhoto();
}

public function pickFromGallery()
{
Camera::pickImages('images', true, 5);
}

#[On('native:' . PhotoTaken::class)]
public function handlePhotoTaken(string $path)
{
$this->isCapturing = false;
$this->addPhoto($path);
}

#[On('native:' . MediaSelected::class)]
public function handleMediaSelected($success, $files, $count)
{
foreach ($files as $file) {
$this->addPhoto($file);
}
}

private function addPhoto(string $path)
{
$this->photos[] = [
'path' => $path,
'data_url' => $this->createDataUrl($path),
'timestamp' => now()
];
}

private function createDataUrl(string $path): string
{
$data = base64_encode(file_get_contents($path));
$mime = mime_content_type($path);
return "data:$mime;base64,$data";
}

public function render()
{
return view('livewire.photo-manager');
}
}
```

## Platform Support

- **iOS:** Uses UIImagePickerController and Photos framework
- **Android:** Uses `Intent.ACTION_IMAGE_CAPTURE` and gallery intents
- **Permissions:** Camera permission required for photo capture
- **File Location:** Photos saved to app's temporary directory

## 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
- Consider implementing cleanup for old temporary photos
- File formats are platform-dependent (typically JPEG)
47 changes: 9 additions & 38 deletions resources/views/docs/mobile/1/apis/dialog.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,21 @@ Dialog::alert(

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.
Expand Down Expand Up @@ -77,7 +85,7 @@ Fired when a button is pressed in an alert dialog.
use Livewire\Attributes\On;
use Native\Mobile\Events\Alert\ButtonPressed;

#[On('native:' . ButtonPressed::class)]
#[On('native:'.ButtonPressed::class)]
public function handleAlertButton($index, $label)
{
switch ($index) {
Expand All @@ -93,40 +101,3 @@ public function handleAlertButton($index, $label)
}
}
```

## Toast Guidelines

### Best Practices
- Keep messages short and clear
- Use for confirmations and status updates
- Don't rely on toasts for critical information
- Avoid showing multiple toasts in quick succession

```php
// Good toast messages
Dialog::toast('Saved!');
Dialog::toast('Photo uploaded');
Dialog::toast('Settings updated');

// Avoid long messages
Dialog::toast('Your photo has been successfully uploaded to the server and will be processed shortly');
```

## Platform Differences

### iOS
- Alerts use UIAlertController
- Toasts use custom overlay views
- Sharing uses UIActivityViewController

### Android
- Alerts use AlertDialog
- Toasts use native Toast system
- Sharing uses Intent.ACTION_SEND

## Accessibility

- All dialogs automatically support screen readers
- Button text should be descriptive
- Toast messages are announced by accessibility services
- Consider users with motor disabilities when designing button layouts
Loading