Skip to content

Commit fcc66b2

Browse files
committed
Updates API docs for mobile (JS)
1 parent 5013fc3 commit fcc66b2

File tree

15 files changed

+1872
-4
lines changed

15 files changed

+1872
-4
lines changed

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

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,65 @@ order: 100
88
The Biometrics API allows you to authenticate users using their device's biometric sensors like Face ID, Touch ID, or
99
fingerprint scanners.
1010

11+
<x-snippet title="Import">
12+
13+
<x-snippet.tab name="PHP">
14+
1115
```php
1216
use Native\Mobile\Facades\Biometrics;
1317
```
1418

19+
</x-snippet.tab>
20+
<x-snippet.tab name="JS">
21+
22+
```js
23+
import { biometric, on, off, Events } from '#nativephp';
24+
```
25+
26+
</x-snippet.tab>
27+
</x-snippet>
28+
1529
## Methods
1630

1731
### `prompt()`
1832

1933
Prompts the user for biometric authentication.
2034

35+
<x-snippet title="Biometric Prompt">
36+
37+
<x-snippet.tab name="PHP">
38+
2139
```php
2240
use Native\Mobile\Facades\Biometrics;
2341

2442
Biometrics::prompt();
2543
```
2644

45+
</x-snippet.tab>
46+
<x-snippet.tab name="JS">
47+
48+
```js
49+
// Basic usage
50+
await biometric.prompt();
51+
52+
// With an identifier for tracking
53+
await biometric.prompt()
54+
.id('secure-action-auth');
55+
```
56+
57+
</x-snippet.tab>
58+
</x-snippet>
59+
2760
## Events
2861

2962
### `Completed`
3063

3164
Fired when biometric authentication completes (success or failure).
3265

66+
<x-snippet title="Completed Event">
67+
68+
<x-snippet.tab name="PHP">
69+
3370
```php
3471
use Native\Mobile\Attributes\OnNative;
3572
use Native\Mobile\Events\Biometric\Completed;
@@ -47,6 +84,71 @@ public function handle(bool $success)
4784
}
4885
```
4986

87+
</x-snippet.tab>
88+
<x-snippet.tab name="Vue">
89+
90+
```js
91+
import { biometric, on, off, Events } from '#nativephp';
92+
import { ref, onMounted, onUnmounted } from 'vue';
93+
94+
const isAuthenticated = ref(false);
95+
96+
const handleBiometricComplete = (payload) => {
97+
if (payload.success) {
98+
isAuthenticated.value = true;
99+
unlockSecureFeature();
100+
} else {
101+
showErrorMessage();
102+
}
103+
};
104+
105+
const authenticate = async () => {
106+
await biometric.prompt();
107+
};
108+
109+
onMounted(() => {
110+
on(Events.Biometric.Completed, handleBiometricComplete);
111+
});
112+
113+
onUnmounted(() => {
114+
off(Events.Biometric.Completed, handleBiometricComplete);
115+
});
116+
```
117+
118+
</x-snippet.tab>
119+
<x-snippet.tab name="React">
120+
121+
```jsx
122+
import { biometric, on, off, Events } from '#nativephp';
123+
import { useState, useEffect } from 'react';
124+
125+
const [isAuthenticated, setIsAuthenticated] = useState(false);
126+
127+
const handleBiometricComplete = (payload) => {
128+
if (payload.success) {
129+
setIsAuthenticated(true);
130+
unlockSecureFeature();
131+
} else {
132+
showErrorMessage();
133+
}
134+
};
135+
136+
const authenticate = async () => {
137+
await biometric.prompt();
138+
};
139+
140+
useEffect(() => {
141+
on(Events.Biometric.Completed, handleBiometricComplete);
142+
143+
return () => {
144+
off(Events.Biometric.Completed, handleBiometricComplete);
145+
};
146+
}, []);
147+
```
148+
149+
</x-snippet.tab>
150+
</x-snippet>
151+
50152
## Platform Support
51153

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

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

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,92 @@ order: 200
88
The Browser API provides three methods for opening URLs, each designed for specific use cases:
99
in-app browsing, system browser navigation, and web authentication flows.
1010

11+
<x-snippet title="Import">
12+
13+
<x-snippet.tab name="PHP">
14+
1115
```php
1216
use Native\Mobile\Facades\Browser;
1317
```
1418

19+
</x-snippet.tab>
20+
<x-snippet.tab name="JS">
21+
22+
```js
23+
import { browser } from '#nativephp';
24+
```
25+
26+
</x-snippet.tab>
27+
</x-snippet>
28+
1529
## Methods
1630

1731
### `inApp()`
1832

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

35+
<x-snippet title="In-App Browser">
36+
37+
<x-snippet.tab name="PHP">
38+
2139
```php
2240
Browser::inApp('https://nativephp.com/mobile');
2341
```
2442

43+
</x-snippet.tab>
44+
<x-snippet.tab name="JS">
45+
46+
```js
47+
await browser.inApp('https://nativephp.com/mobile');
48+
```
49+
50+
</x-snippet.tab>
51+
</x-snippet>
52+
2553
### `open()`
2654

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

57+
<x-snippet title="System Browser">
58+
59+
<x-snippet.tab name="PHP">
60+
2961
```php
3062
Browser::open('https://nativephp.com/mobile');
3163
```
3264

65+
</x-snippet.tab>
66+
<x-snippet.tab name="JS">
67+
68+
```js
69+
await browser.open('https://nativephp.com/mobile');
70+
```
71+
72+
</x-snippet.tab>
73+
</x-snippet>
74+
3375
### `auth()`
3476

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

79+
<x-snippet title="Authentication Browser">
80+
81+
<x-snippet.tab name="PHP">
82+
3783
```php
3884
Browser::auth('https://provider.com/oauth/authorize?client_id=123&redirect_uri=nativephp://127.0.0.1/auth/callback');
3985
```
4086

87+
</x-snippet.tab>
88+
<x-snippet.tab name="JS">
89+
90+
```js
91+
await browser.auth('https://provider.com/oauth/authorize?client_id=123&redirect_uri=nativephp://127.0.0.1/auth/callback');
92+
```
93+
94+
</x-snippet.tab>
95+
</x-snippet>
96+
4197
## Use Cases
4298

4399
### When to Use Each Method

0 commit comments

Comments
 (0)