Skip to content

Commit 2cc0fe5

Browse files
committed
polish
1 parent 0c7714c commit 2cc0fe5

33 files changed

+873
-2095
lines changed

resources/views/docs/mobile/1/_index.md

Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -2,98 +2,3 @@
22
title: Mobile
33
order: 1
44
---
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)

resources/views/docs/mobile/1/apis/biometrics.md

Lines changed: 9 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ order: 100
55

66
## Overview
77

8-
The Biometrics API allows you to authenticate users using their device's biometric sensors like Face ID, Touch ID, or fingerprint scanners.
8+
The Biometrics API allows you to authenticate users using their device's biometric sensors like Face ID, Touch ID, or
9+
fingerprint scanners.
910

1011
```php
1112
use Native\Mobile\Facades\Biometrics;
@@ -17,6 +18,12 @@ use Native\Mobile\Facades\Biometrics;
1718

1819
Prompts the user for biometric authentication.
1920

21+
```php
22+
use Native\Mobile\Facades\Biometrics;
23+
24+
Biometrics::promptForBiometricID();
25+
```
26+
2027
## Events
2128

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

30-
#[On('native:' . Completed::class)]
37+
#[On('native:'.Completed::class)]
3138
public function handleBiometricAuth(bool $success)
3239
{
3340
if ($success) {
@@ -40,45 +47,6 @@ public function handleBiometricAuth(bool $success)
4047
}
4148
```
4249

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-
8250
## Platform Support
8351

8452
- **iOS:** Face ID, Touch ID

resources/views/docs/mobile/1/apis/browser.md

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
---
22
title: Browser
3-
order: 250
3+
order: 150
44
---
55

66
## Overview
77

8-
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.
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.
910

1011
```php
1112
use Native\Mobile\Facades\Browser;
@@ -55,11 +56,3 @@ Browser::auth('https://provider.com/oauth/authorize?client_id=123&redirect_uri=n
5556
- Login with WorkOS, Auth0, Google, Facebook, etc.
5657
- Secure authentication with automatic redirects
5758
- Isolated browser session for security
58-
59-
## Platform Behavior
60-
61-
- **iOS**: Uses SFSafariViewController (inApp), Safari (system), ASWebAuthenticationSession (auth)
62-
- **Android**: Uses Custom Tabs (inApp), default browser (system), Custom Tabs with auth handling (auth)
63-
64-
The Browser API provides the right tool for each browsing scenario in your mobile application.
65-

resources/views/docs/mobile/1/apis/camera.md

Lines changed: 2 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Fired when a photo is taken with the camera.
5454
use Livewire\Attributes\On;
5555
use Native\Mobile\Events\Camera\PhotoTaken;
5656

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

75-
#[On('native:' . MediaSelected::class)]
75+
#[On('native:'.MediaSelected::class)]
7676
public function handleMediaSelected($success, $files, $count)
7777
{
7878
foreach ($files as $file) {
@@ -82,80 +82,9 @@ public function handleMediaSelected($success, $files, $count)
8282
}
8383
```
8484

85-
## Example Usage
86-
87-
```php
88-
use Livewire\Component;
89-
use Livewire\Attributes\On;
90-
use Native\Mobile\Facades\Camera;
91-
use Native\Mobile\Events\Camera\PhotoTaken;
92-
use Native\Mobile\Events\Gallery\MediaSelected;
93-
94-
class PhotoManager extends Component
95-
{
96-
public array $photos = [];
97-
public bool $isCapturing = false;
98-
99-
public function takePhoto()
100-
{
101-
$this->isCapturing = true;
102-
Camera::getPhoto();
103-
}
104-
105-
public function pickFromGallery()
106-
{
107-
Camera::pickImages('images', true, 5);
108-
}
109-
110-
#[On('native:' . PhotoTaken::class)]
111-
public function handlePhotoTaken(string $path)
112-
{
113-
$this->isCapturing = false;
114-
$this->addPhoto($path);
115-
}
116-
117-
#[On('native:' . MediaSelected::class)]
118-
public function handleMediaSelected($success, $files, $count)
119-
{
120-
foreach ($files as $file) {
121-
$this->addPhoto($file);
122-
}
123-
}
124-
125-
private function addPhoto(string $path)
126-
{
127-
$this->photos[] = [
128-
'path' => $path,
129-
'data_url' => $this->createDataUrl($path),
130-
'timestamp' => now()
131-
];
132-
}
133-
134-
private function createDataUrl(string $path): string
135-
{
136-
$data = base64_encode(file_get_contents($path));
137-
$mime = mime_content_type($path);
138-
return "data:$mime;base64,$data";
139-
}
140-
141-
public function render()
142-
{
143-
return view('livewire.photo-manager');
144-
}
145-
}
146-
```
147-
148-
## Platform Support
149-
150-
- **iOS:** Uses UIImagePickerController and Photos framework
151-
- **Android:** Uses `Intent.ACTION_IMAGE_CAPTURE` and gallery intents
152-
- **Permissions:** Camera permission required for photo capture
153-
- **File Location:** Photos saved to app's temporary directory
154-
15585
## Notes
15686

15787
- The first time your app requests camera access, users will be prompted for permission
15888
- If permission is denied, camera functions will fail silently
15989
- Captured photos are stored in the app's temporary directory
160-
- Consider implementing cleanup for old temporary photos
16190
- File formats are platform-dependent (typically JPEG)

resources/views/docs/mobile/1/apis/dialog.md

Lines changed: 9 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,21 @@ Dialog::alert(
3939

4040
Displays a brief toast notification message.
4141

42+
4243
**Parameters:**
4344
- `string $message` - The message to display
4445

4546
```php
4647
Dialog::toast('Item saved successfully!');
4748
```
4849

50+
#### Good toast messages
51+
52+
- Short and clear
53+
- Great for confirmations and status updates
54+
- Don't rely on them for critical information
55+
- Avoid showing multiple toasts in quick succession
56+
4957
### `share()`
5058

5159
Opens the native sharing interface.
@@ -77,7 +85,7 @@ Fired when a button is pressed in an alert dialog.
7785
use Livewire\Attributes\On;
7886
use Native\Mobile\Events\Alert\ButtonPressed;
7987

80-
#[On('native:' . ButtonPressed::class)]
88+
#[On('native:'.ButtonPressed::class)]
8189
public function handleAlertButton($index, $label)
8290
{
8391
switch ($index) {
@@ -93,40 +101,3 @@ public function handleAlertButton($index, $label)
93101
}
94102
}
95103
```
96-
97-
## Toast Guidelines
98-
99-
### Best Practices
100-
- Keep messages short and clear
101-
- Use for confirmations and status updates
102-
- Don't rely on toasts for critical information
103-
- Avoid showing multiple toasts in quick succession
104-
105-
```php
106-
// Good toast messages
107-
Dialog::toast('Saved!');
108-
Dialog::toast('Photo uploaded');
109-
Dialog::toast('Settings updated');
110-
111-
// Avoid long messages
112-
Dialog::toast('Your photo has been successfully uploaded to the server and will be processed shortly');
113-
```
114-
115-
## Platform Differences
116-
117-
### iOS
118-
- Alerts use UIAlertController
119-
- Toasts use custom overlay views
120-
- Sharing uses UIActivityViewController
121-
122-
### Android
123-
- Alerts use AlertDialog
124-
- Toasts use native Toast system
125-
- Sharing uses Intent.ACTION_SEND
126-
127-
## Accessibility
128-
129-
- All dialogs automatically support screen readers
130-
- Button text should be descriptive
131-
- Toast messages are announced by accessibility services
132-
- Consider users with motor disabilities when designing button layouts

0 commit comments

Comments
 (0)