Skip to content
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
102 changes: 102 additions & 0 deletions resources/views/docs/mobile/2/apis/biometrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,65 @@ order: 100
The Biometrics API allows you to authenticate users using their device's biometric sensors like Face ID, Touch ID, or
fingerprint scanners.

<x-snippet title="Import">

<x-snippet.tab name="PHP">

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

</x-snippet.tab>
<x-snippet.tab name="JS">

```js
import { biometric, on, off, Events } from '#nativephp';
```

</x-snippet.tab>
</x-snippet>

## Methods

### `prompt()`

Prompts the user for biometric authentication.

<x-snippet title="Biometric Prompt">

<x-snippet.tab name="PHP">

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

Biometrics::prompt();
```

</x-snippet.tab>
<x-snippet.tab name="JS">

```js
// Basic usage
await biometric.prompt();

// With an identifier for tracking
await biometric.prompt()
.id('secure-action-auth');
```

</x-snippet.tab>
</x-snippet>

## Events

### `Completed`

Fired when biometric authentication completes (success or failure).

<x-snippet title="Completed Event">

<x-snippet.tab name="PHP">

```php
use Native\Mobile\Attributes\OnNative;
use Native\Mobile\Events\Biometric\Completed;
Expand All @@ -47,6 +84,71 @@ public function handle(bool $success)
}
```

</x-snippet.tab>
<x-snippet.tab name="Vue">

```js
import { biometric, on, off, Events } from '#nativephp';
import { ref, onMounted, onUnmounted } from 'vue';

const isAuthenticated = ref(false);

const handleBiometricComplete = (payload) => {
if (payload.success) {
isAuthenticated.value = true;
unlockSecureFeature();
} else {
showErrorMessage();
}
};

const authenticate = async () => {
await biometric.prompt();
};

onMounted(() => {
on(Events.Biometric.Completed, handleBiometricComplete);
});

onUnmounted(() => {
off(Events.Biometric.Completed, handleBiometricComplete);
});
```

</x-snippet.tab>
<x-snippet.tab name="React">

```jsx
import { biometric, on, off, Events } from '#nativephp';
import { useState, useEffect } from 'react';

const [isAuthenticated, setIsAuthenticated] = useState(false);

const handleBiometricComplete = (payload) => {
if (payload.success) {
setIsAuthenticated(true);
unlockSecureFeature();
} else {
showErrorMessage();
}
};

const authenticate = async () => {
await biometric.prompt();
};

useEffect(() => {
on(Events.Biometric.Completed, handleBiometricComplete);

return () => {
off(Events.Biometric.Completed, handleBiometricComplete);
};
}, []);
```

</x-snippet.tab>
</x-snippet>

## Platform Support

- **iOS:** Face ID, Touch ID
Expand Down
56 changes: 56 additions & 0 deletions resources/views/docs/mobile/2/apis/browser.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,92 @@ order: 200
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.

<x-snippet title="Import">

<x-snippet.tab name="PHP">

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

</x-snippet.tab>
<x-snippet.tab name="JS">

```js
import { browser } from '#nativephp';
```

</x-snippet.tab>
</x-snippet>

## Methods

### `inApp()`

Opens a URL in an embedded browser within your app using Custom Tabs (Android) or SFSafariViewController (iOS).

<x-snippet title="In-App Browser">

<x-snippet.tab name="PHP">

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

</x-snippet.tab>
<x-snippet.tab name="JS">

```js
await browser.inApp('https://nativephp.com/mobile');
```

</x-snippet.tab>
</x-snippet>

### `open()`

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

<x-snippet title="System Browser">

<x-snippet.tab name="PHP">

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

</x-snippet.tab>
<x-snippet.tab name="JS">

```js
await browser.open('https://nativephp.com/mobile');
```

</x-snippet.tab>
</x-snippet>

### `auth()`

Opens a URL in a specialized authentication browser designed for OAuth flows with automatic `nativephp://` redirect handling.

<x-snippet title="Authentication Browser">

<x-snippet.tab name="PHP">

```php
Browser::auth('https://provider.com/oauth/authorize?client_id=123&redirect_uri=nativephp://127.0.0.1/auth/callback');
```

</x-snippet.tab>
<x-snippet.tab name="JS">

```js
await browser.auth('https://provider.com/oauth/authorize?client_id=123&redirect_uri=nativephp://127.0.0.1/auth/callback');
```

</x-snippet.tab>
</x-snippet>

## Use Cases

### When to Use Each Method
Expand Down
Loading