8000 📚 Mobile v1.1 Documentation Updates by shanerbaner82 · Pull Request #178 · NativePHP/nativephp.com · GitHub
[go: up one dir, main page]

Skip to content

📚 Mobile v1.1 Documentation Updates #178

New issue < 8000 /summary>

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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
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
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
99 changes: 99 additions & 0 deletions resources/views/docs/mobile/1/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
---
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)
4 changes: 4 additions & 0 deletions resources/views/docs/mobile/1/apis/_index.md
8000
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: APIs
order: 4
---
93 changes: 93 additions & 0 deletions resources/views/docs/mobile/1/apis/biometrics.md
C8E9
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
---
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.

## 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();
}
}
```

## 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
- **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
116 changes: 116 additions & 0 deletions resources/views/docs/mobile/1/apis/browser.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
---
title: Browser
order: 250
---

## Overview

The Browser API allows you to open URLs in an in-app browser that is "owned" by your application. This is essential when working with OAuth redirects since you need to provide a redirect URL that would naturally open in the user's default browser.

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

## Methods

### `inApp()`

Opens a URL in an in-app browser window.

**Parameters:**
- `string $url` - The URL to open in the in-app browser

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

## Use Cases

### OAuth Authentication

The in-app browser is particularly useful for OAuth flows where you need to:
- Redirect users to a third-party authentication provider
- Capture the redirect URL after authentication
- Return control to your app seamlessly

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

class AuthController extends Component
{
public function authenticateWithProvider()
{
// Open OAuth provider in in-app browser
Browser::inApp('https://provider.com/oauth/authorize?client_id=your_client_id&redirect_uri=your_app_scheme://oauth/callback');
}
}
```

### External Content

Display external content while keeping users within your app:

```php
// Open documentation
Browser::inApp('https://docs.example.com/help');

// Open terms of service
Browser::inApp('https://example.com/terms');

// Open privacy policy
Browser::inApp('https://example.com/privacy');
```

## Integration with Deep Links

Use the in-app browser in conjunction with App/Universal/Deep links for complete OAuth flows:

1. **Open OAuth provider** - Use `Browser::inApp()` to start authentication
2. **User authenticates** - User completes authentication in the in-app browser
3. **Redirect to app** - OAuth provider redirects to your app's deep link
4. **Handle in app** - Your app receives the deep link and processes the authentication

```php
use Native\Mobile\Facades\Browser;
use Livewire\Attributes\On;
use Native\Mobile\Events\DeepLink\Received;

class OAuthHandler extends Component
{
public function startOAuth()
{
Browser::inApp('https://github.com/login/oauth/authorize?client_id=your_client_id&redirect_uri=myapp://oauth/callback');
}
}
```

## Platform Behavior

### iOS
- Uses `SFSafariViewController` for the in-app browser
- Provides native Safari experience within your app
- Includes address bar, navigation controls, and share functionality
- Users can easily return to your app

### Android
- Uses `Chrome Custom Tabs` when available
- Falls back to `WebView` if Custom Tabs unavailable
- Provides native browser experience
- Maintains your app's context

## Best Practices

1. **Use for OAuth flows** - Perfect for authentication redirects
2. **Keep users in your app** - Better than opening external browser
3. **Combine with deep links** - Essential for complete OAuth implementation
4. **Handle errors gracefully** - Network issues or invalid URLs should be handled
5. **Provide user feedback** - Show loading states when opening URLs

## Security Considerations

- **Validate URLs** - Ensure URLs are from trusted sources
- **Handle redirects** - Be prepared for OAuth redirects back to your app
- **Secure communication** - Always use HTTPS for sensitive operations
- **User consent** - Make it clear when opening external content

The in-app browser provides a seamless way to handle external content and OAuth flows while maintaining your app's user experience.
Loading
0