Skip to content

Commit bdcac7b

Browse files
committed
📚 Update mobile v1.1 documentation structure and content
- Reorganize v1.1 documentation with new APIs and concepts sections - Add comprehensive database security guidance covering API-first architecture, Laravel Sanctum integration, and SecureStorage best practices - Simplify Haptics API documentation to essential examples and usage patterns - Add Windows performance tip for faster composer installs during compilation - Improve geolocation API documentation with detailed event handling - Update installation guide with platform-specific optimizations - Restructure v1.1 content hierarchy for better developer experience
1 parent a699a30 commit bdcac7b

34 files changed

+4262
-362
lines changed

app/Http/Controllers/ShowDocumentationController.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ public function __invoke(Request $request, string $platform, string $version, ?s
4646
} catch (InvalidArgumentException $e) {
4747
return $this->redirectToFirstNavigationPage($navigation, $page);
4848
}
49-
5049
SEOTools::setTitle($pageProperties['title'].' - NativePHP '.$platform.' v'.$version);
5150
SEOTools::setDescription(Arr::exists($pageProperties, 'description') ? $pageProperties['description'] : '');
5251

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

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

7070
$pageProperties['platform'] = $platform;
7171
$pageProperties['version'] = $version;
@@ -143,6 +143,7 @@ protected function getPageProperties($platform, $version, $page = null): array
143143
}
144144
}
145145

146+
146147
return $pageProperties;
147148
}
148149

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
---
2+
title: Mobile
3+
order: 1
4+
---
5+
6+
# NativePHP for Mobile
7+
8+
**Build native iOS and Android apps with PHP and Laravel**
9+
10+
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.
11+
12+
## What Makes NativePHP Mobile Special?
13+
14+
=€ **Native Performance** - Your app runs natively on device with embedded PHP runtime
15+
**True Mobile APIs** - Access camera, biometrics, push notifications, and more
16+
¡ **Laravel Powered** - Use your existing Laravel skills and ecosystem
17+
=' **No Web Server** - Your app runs entirely on-device
18+
**Cross Platform** - Single codebase for iOS and Android
19+
20+
## Quick Start
21+
22+
Get your first mobile app running in minutes:
23+
24+
```bash
25+
# Install NativePHP Mobile
26+
composer require nativephp/mobile
27+
28+
# Configure your app
29+
php artisan native:install
30+
31+
# Run your app
32+
php artisan native:run
33+
```
34+
35+
## Current Features (v1.1)
36+
37+
**Available now:**
38+
- =ø Camera & Gallery access
39+
- = Biometric authentication (Face ID, Touch ID, Fingerprint)
40+
- = Push notifications via Firebase
41+
- =¬ Native dialogs & toasts
42+
- = Deep links & universal links
43+
- =á NFC support
44+
- =ó Haptic feedback & vibration
45+
- =& Flashlight control
46+
- =ä Native sharing
47+
- = Secure storage (Keychain/Keystore)
48+
- =Í Location services
49+
50+
[See the complete roadmap ’](/docs/mobile/1/getting-started/roadmap)
51+
52+
## Documentation Sections
53+
54+
### [Getting Started](/docs/mobile/1/getting-started)
55+
Everything you need to start building mobile apps with PHP:
56+
- [Introduction](/docs/mobile/1/getting-started/introduction) - Learn how NativePHP Mobile works
57+
- [Installation](/docs/mobile/1/getting-started/installation) - Set up your development environment
58+
- [Environment Setup](/docs/mobile/1/getting-started/environment-setup) - Configure iOS and Android tools
59+
- [Configuration](/docs/mobile/1/getting-started/configuration) - App settings and permissions
60+
- [Development](/docs/mobile/1/getting-started/development) - Development workflow
61+
- [Roadmap](/docs/mobile/1/getting-started/roadmap) - Current and planned features
62+
63+
### [The Basics](/docs/mobile/1/the-basics)
64+
Core concepts and fundamental knowledge:
65+
- [Native Functions](/docs/mobile/1/the-basics/native-functions) - Understanding sync vs async APIs
66+
- [Asynchronous Methods](/docs/mobile/1/the-basics/asynchronous-methods) - Event-driven mobile development
67+
- [ICU Support](/docs/mobile/1/the-basics/icu-support) - International components for Unicode
68+
69+
### [Concepts](/docs/mobile/1/concepts)
70+
Important concepts for mobile app development:
71+
- [CI/CD](/docs/mobile/1/concepts/ci-cd) - Continuous integration and deployment
72+
- [Deep Links](/docs/mobile/1/concepts/deep-links) - Universal links, app links, and NFC
73+
- [Push Notifications](/docs/mobile/1/concepts/push-notifications) - Firebase Cloud Messaging setup
74+
- [Splash Screen/Icons](/docs/mobile/1/concepts/splash-screen-icons) - App branding and assets
75+
- [Versioning](/docs/mobile/1/concepts/versioning) - App version management
76+
77+
### [APIs](/docs/mobile/1/apis)
78+
Complete API reference for all native features:
79+
- [Biometrics](/docs/mobile/1/apis/biometrics) - Face ID, Touch ID, fingerprint authentication
80+
- [Camera](/docs/mobile/1/apis/camera) - Photo capture and gallery access
81+
- [Dialog](/docs/mobile/1/apis/dialog) - Alerts, toasts, and sharing
82+
- [Geolocation](/docs/mobile/1/apis/geolocation) - GPS and location services
83+
- [Haptics](/docs/mobile/1/apis/haptics) - Vibration and tactile feedback
84+
- [PushNotifications](/docs/mobile/1/apis/push-notifications) - FCM token management
85+
- [SecureStorage](/docs/mobile/1/apis/secure-storage) - Keychain and keystore operations
86+
- [System](/docs/mobile/1/apis/system) - Flashlight and legacy methods
87+
88+
### [Digging Deeper](/docs/mobile/1/digging-deeper)
89+
Advanced topics for production apps:
90+
- [Databases](/docs/mobile/1/digging-deeper/databases) - SQLite and data management
91+
- [Security](/docs/mobile/1/digging-deeper/security) - Best practices and secure storage
92+
93+
## Need Help?
94+
95+
- **License Required** - [Purchase your license](https://nativephp.com/mobile) to get started
96+
- **Community** - Join our Discord for support and discussions
97+
- **Examples** - Check out the Kitchen Sink demo app (coming soon to app stores)
98+
99+
Ready to build your first mobile app with PHP? [Let's get started! ’](/docs/mobile/1/getting-started/introduction)
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
---
2+
title: APIs
3+
order: 4
4+
---
5+
6+
# API Reference
7+
8+
Complete documentation for all NativePHP Mobile APIs. Each API provides access to native device capabilities through familiar PHP facades.
9+
10+
## Available APIs
11+
12+
### [Biometrics](/docs/mobile/1/apis/biometrics)
13+
**Face ID, Touch ID, Fingerprint Authentication**
14+
```php
15+
Biometrics::promptForBiometricID();
16+
```
17+
Secure user authentication using device biometric sensors. Supports Face ID on iOS, Touch ID, and fingerprint readers on Android.
18+
19+
### [Camera](/docs/mobile/1/apis/camera)
20+
**Photo Capture & Gallery Access**
21+
```php
22+
Camera::getPhoto();
23+
Camera::pickImages('images', true, 5);
24+
```
25+
Take photos with the device camera or select images from the photo gallery. Supports both single and multiple image selection.
26+
27+
### [Dialog](/docs/mobile/1/apis/dialog)
28+
**Native UI Elements**
29+
```php
30+
Dialog::alert('Title', 'Message', $buttons, $callback);
31+
Dialog::toast('Success message');
32+
Dialog::share('Title', 'Text', 'https://example.com');
33+
```
34+
Display native alerts, toast notifications, and sharing interfaces that match platform design guidelines.
35+
36+
### [Geolocation](/docs/mobile/1/apis/geolocation) ⭐ New in v1.1
37+
**GPS & Location Services**
38+
```php
39+
Geolocation::getCurrentPosition(true); // High accuracy
40+
Geolocation::checkPermissions();
41+
Geolocation::requestPermissions();
42+
```
43+
Access device location services with configurable accuracy levels and proper permission handling.
44+
45+
### [Haptics](/docs/mobile/1/apis/haptics)
46+
**Vibration & Tactile Feedback**
47+
```php
48+
Haptics::vibrate();
49+
```
50+
Provide tactile feedback for user interactions, form validation, and important events.
51+
52+
### [PushNotifications](/docs/mobile/1/apis/push-notifications)
53+
**Firebase Cloud Messaging**
54+
```php
55+
PushNotifications::enrollForPushNotifications();
56+
PushNotifications::getPushNotificationsToken();
57+
```
58+
Register devices for push notifications and manage FCM tokens for server-side notification delivery.
59+
60+
### [SecureStorage](/docs/mobile/1/apis/secure-storage) ⭐ New in v1.1
61+
**Keychain & Keystore Operations**
62+
```php
63+
SecureStorage::set('api_token', $token);
64+
$token = SecureStorage::get('api_token');
65+
SecureStorage::delete('api_token');
66+
```
67+
Store sensitive data securely using iOS Keychain and Android Keystore with automatic encryption.
68+
69+
### [System](/docs/mobile/1/apis/system)
70+
**System Functions & Legacy API**
71+
```php
72+
System::flashlight(); // Toggle flashlight
73+
```
74+
Control system functions like the flashlight. Also provides deprecated methods that have moved to dedicated facades.
75+
76+
## API Patterns
77+
78+
### Synchronous APIs
79+
Execute immediately and return results:
80+
- `Haptics::vibrate()`
81+
- `System::flashlight()`
82+
- `Dialog::toast()`
83+
- `SecureStorage::set()` / `get()`
84+
85+
### Asynchronous APIs
86+
Trigger operations and fire events when complete:
87+
- `Camera::getPhoto()``PhotoTaken` event
88+
- `Biometrics::promptForBiometricID()``Completed` event
89+
- `PushNotifications::enrollForPushNotifications()``TokenGenerated` event
90+
- `Geolocation::getCurrentPosition()``LocationReceived` event
91+
92+
### Event Handling
93+
All async APIs use Laravel events with Livewire integration:
94+
95+
```php
96+
use Livewire\Attributes\On;
97+
use Native\Mobile\Events\Camera\PhotoTaken;
98+
99+
#[On('native:' . PhotoTaken::class)]
100+
public function handlePhotoTaken(string $path)
101+
{
102+
// Process the captured photo
103+
}
104+
```
105+
106+
## Migration from System Facade
107+
108+
Many methods have moved from the `System` facade to dedicated facades in v1.1:
109+
110+
| Old (Deprecated) | New (Recommended) |
111+
|------------------|-------------------|
112+
| `System::camera()` | `Camera::getPhoto()` |
113+
| `System::vibrate()` | `Haptics::vibrate()` |
114+
| `System::promptForBiometricID()` | `Biometrics::promptForBiometricID()` |
115+
| `System::enrollForPushNotifications()` | `PushNotifications::enrollForPushNotifications()` |
116+
| `System::secureSet()` / `secureGet()` | `SecureStorage::set()` / `get()` |
117+
118+
The old methods still work but are deprecated. See the [System API documentation](/docs/mobile/1/apis/system) for complete migration guidance.
119+
120+
## Platform Support
121+
122+
All APIs work on both iOS and Android with platform-appropriate implementations:
123+
- **iOS**: Uses native iOS frameworks and APIs
124+
- **Android**: Uses Android SDK and native libraries
125+
- **Permissions**: Automatically handled with user prompts when required
126+
- **Fallbacks**: Graceful degradation when features aren't available
127+
128+
## Error Handling
129+
130+
APIs provide both success and error events for proper error handling:
131+
132+
```php
133+
#[On('native:' . PhotoTaken::class)]
134+
public function handleSuccess($data) { /* ... */ }
135+
136+
#[On('native:' . PermissionDenied::class)]
137+
public function handleError($error) { /* ... */ }
138+
```
139+
140+
Each API documentation includes complete error handling examples and best practices.
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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 fingerprint scanners.
9+
10+
```php
11+
use Native\Mobile\Facades\Biometrics;
12+
```
13+
14+
## Methods
15+
16+
### `promptForBiometricID()`
17+
18+
Prompts the user for biometric authentication.
19+
20+
## Events
21+
22+
### `Native\Mobile\Events\Biometric\Completed`
23+
24+
Fired when biometric authentication completes (success or failure).
25+
26+
```php
27+
use Livewire\Attributes\On;
28+
use Native\Mobile\Events\Biometric\Completed;
29+
30+
#[On('native:' . Completed::class)]
31+
public function handleBiometricAuth(bool $success)
32+
{
33+
if ($success) {
34+
// User authenticated successfully
35+
$this->unlockSecureFeature();
36+
} else {
37+
// Authentication failed
38+
$this->showErrorMessage();
39+
}
40+
}
41+
```
42+
43+
## Example Usage
44+
45+
```php
46+
use Livewire\Component;
47+
use Livewire\Attributes\On;
48+
use Native\Mobile\Facades\Biometrics;
49+
use Native\Mobile\Events\Biometric\Completed;
50+
51+
class SecureArea extends Component
52+
{
53+
public bool $isUnlocked = false;
54+
public bool $isAuthenticating = false;
55+
56+
public function authenticate()
57+
{
58+
$this->isAuthenticating = true;
59+
Biometrics::promptForBiometricID();
60+
}
61+
62+
#[On('native:' . Completed::class)]
63+
public function handleBiometricAuth(bool $success)
64+
{
65+
$this->isAuthenticating = false;
66+
67+
if ($success) {
68+
$this->isUnlocked = true;
69+
session(['biometric_authenticated' => true]);
70+
} else {
71+
$this->addError('auth', 'Biometric authentication failed');
72+
}
73+
}
74+
75+
public function render()
76+
{
77+
return view('livewire.secure-area');
78+
}
79+
}
80+
```
81+
82+
## Platform Support
83+
84+
- **iOS:** Face ID, Touch ID
85+
- **Android:** Fingerprint, Face unlock, other biometric methods
86+
- **Fallback:** System authentication (PIN, password, pattern)
87+
88+
## Security Notes
89+
90+
- Biometric authentication provides **convenience**, not absolute security
91+
- Always combine with other authentication factors for sensitive operations
92+
- Consider implementing session timeouts for unlocked states
93+
- Users can potentially bypass biometrics if their device is compromised

0 commit comments

Comments
 (0)