nativine 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +410 -0
- package/dist/core/bridge.d.ts +52 -0
- package/dist/core/platform.d.ts +15 -0
- package/dist/index.d.ts +182 -0
- package/dist/modules/ads.d.ts +40 -0
- package/dist/modules/auth.d.ts +45 -0
- package/dist/modules/biometrics.d.ts +60 -0
- package/dist/modules/cache.d.ts +25 -0
- package/dist/modules/camera.d.ts +35 -0
- package/dist/modules/clipboard.d.ts +28 -0
- package/dist/modules/contacts.d.ts +28 -0
- package/dist/modules/device.d.ts +84 -0
- package/dist/modules/downloads.d.ts +31 -0
- package/dist/modules/events.d.ts +55 -0
- package/dist/modules/haptics.d.ts +44 -0
- package/dist/modules/location.d.ts +31 -0
- package/dist/modules/navigation.d.ts +60 -0
- package/dist/modules/network.d.ts +54 -0
- package/dist/modules/onesignal.d.ts +70 -0
- package/dist/modules/pedometer.d.ts +66 -0
- package/dist/modules/print.d.ts +14 -0
- package/dist/modules/reviews.d.ts +19 -0
- package/dist/modules/screenshot.d.ts +21 -0
- package/dist/modules/share.d.ts +46 -0
- package/dist/modules/storage.d.ts +56 -0
- package/dist/modules/toast.d.ts +19 -0
- package/dist/modules/ui.d.ts +109 -0
- package/dist/modules/updates.d.ts +15 -0
- package/dist/nativine.cjs.js +1984 -0
- package/dist/nativine.cjs.js.map +1 -0
- package/dist/nativine.esm.js +1954 -0
- package/dist/nativine.esm.js.map +1 -0
- package/dist/nativine.umd.js +2 -0
- package/dist/nativine.umd.js.map +1 -0
- package/package.json +58 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auth Module
|
|
3
|
+
*
|
|
4
|
+
* Native Google Sign-In integration. Triggers the native Google Sign-In flow
|
|
5
|
+
* and returns user credentials to your web app.
|
|
6
|
+
*/
|
|
7
|
+
export interface GoogleSignInResult {
|
|
8
|
+
/** User's email address */
|
|
9
|
+
email: string;
|
|
10
|
+
/** User's display name */
|
|
11
|
+
displayName: string;
|
|
12
|
+
/** Google ID token for backend verification */
|
|
13
|
+
idToken: string;
|
|
14
|
+
/** URL of user's profile photo */
|
|
15
|
+
photoUrl: string;
|
|
16
|
+
/** Google account ID */
|
|
17
|
+
id: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Trigger the native Google Sign-In flow.
|
|
21
|
+
* Returns user credentials when the user completes sign-in.
|
|
22
|
+
*
|
|
23
|
+
* @returns Promise resolving with Google user credentials
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```js
|
|
27
|
+
* try {
|
|
28
|
+
* const user = await nativine.auth.googleSignIn();
|
|
29
|
+
* console.log(user.email); // "john@gmail.com"
|
|
30
|
+
* console.log(user.idToken); // Send to your backend for verification
|
|
31
|
+
* } catch (err) {
|
|
32
|
+
* console.log('Sign-in cancelled or failed');
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare function googleSignIn(): Promise<GoogleSignInResult>;
|
|
37
|
+
/**
|
|
38
|
+
* Sign out of the current Google account.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```js
|
|
42
|
+
* await nativine.auth.googleSignOut();
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare function googleSignOut(): void;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Biometrics Module
|
|
3
|
+
*
|
|
4
|
+
* Trigger native biometric authentication (fingerprint, face recognition, iris scan).
|
|
5
|
+
*/
|
|
6
|
+
export type BiometryType = 'fingerprint' | 'face' | 'iris' | 'none';
|
|
7
|
+
export interface BiometricAvailability {
|
|
8
|
+
/** Whether biometric authentication is available on this device */
|
|
9
|
+
available: boolean;
|
|
10
|
+
/** The type of biometric sensor available */
|
|
11
|
+
biometryType: BiometryType;
|
|
12
|
+
}
|
|
13
|
+
export interface BiometricAuthOptions {
|
|
14
|
+
/** Reason displayed to the user for why authentication is needed */
|
|
15
|
+
reason?: string;
|
|
16
|
+
/** Title for the biometric dialog (Android only) */
|
|
17
|
+
title?: string;
|
|
18
|
+
/** Whether to allow device PIN/pattern as fallback */
|
|
19
|
+
allowFallback?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface BiometricAuthResult {
|
|
22
|
+
/** Whether authentication was successful */
|
|
23
|
+
success: boolean;
|
|
24
|
+
/** Error message if authentication failed */
|
|
25
|
+
error?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Check if biometric authentication is available on this device.
|
|
29
|
+
*
|
|
30
|
+
* @returns Promise resolving with availability info
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```js
|
|
34
|
+
* const { available, biometryType } = await nativine.biometrics.isAvailable();
|
|
35
|
+
* if (available) {
|
|
36
|
+
* console.log(`Biometric type: ${biometryType}`); // "fingerprint"
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function isAvailable(): Promise<BiometricAvailability>;
|
|
41
|
+
/**
|
|
42
|
+
* Trigger biometric authentication.
|
|
43
|
+
*
|
|
44
|
+
* @param options - Configuration for the authentication prompt
|
|
45
|
+
* @returns Promise resolving with the authentication result
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```js
|
|
49
|
+
* const result = await nativine.biometrics.authenticate({
|
|
50
|
+
* reason: 'Verify your identity to access settings',
|
|
51
|
+
* allowFallback: true
|
|
52
|
+
* });
|
|
53
|
+
*
|
|
54
|
+
* if (result.success) {
|
|
55
|
+
* // User authenticated
|
|
56
|
+
* showSensitiveContent();
|
|
57
|
+
* }
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare function authenticate(options?: BiometricAuthOptions): Promise<BiometricAuthResult>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cache Module
|
|
3
|
+
*
|
|
4
|
+
* Clear WebView cache and cookies.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Clear the WebView cache (CSS, JS, images, etc.).
|
|
8
|
+
* Shows a confirmation dialog to the user.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```js
|
|
12
|
+
* nativine.cache.clear();
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare function clear(): void;
|
|
16
|
+
/**
|
|
17
|
+
* Clear all WebView cookies.
|
|
18
|
+
* Useful for logout flows to ensure session data is wiped.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```js
|
|
22
|
+
* nativine.cache.clearCookies();
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function clearCookies(): void;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Camera / Scanner Module
|
|
3
|
+
*
|
|
4
|
+
* Access the device camera for barcode and QR code scanning.
|
|
5
|
+
*/
|
|
6
|
+
export interface ScanResult {
|
|
7
|
+
/** The decoded content of the barcode/QR code */
|
|
8
|
+
value: string;
|
|
9
|
+
/** The format of the code (e.g., 'QR_CODE', 'EAN_13', 'CODE_128') */
|
|
10
|
+
format: string;
|
|
11
|
+
}
|
|
12
|
+
export interface ScanOptions {
|
|
13
|
+
/** Restrict scanning to specific formats */
|
|
14
|
+
formats?: string[];
|
|
15
|
+
/** Prompt text shown on the scanner UI */
|
|
16
|
+
prompt?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Open the native barcode/QR code scanner.
|
|
20
|
+
*
|
|
21
|
+
* @param options - Scanner configuration
|
|
22
|
+
* @returns Promise resolving with the scanned code data
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```js
|
|
26
|
+
* try {
|
|
27
|
+
* const result = await nativine.scanner.scan();
|
|
28
|
+
* console.log(result.value); // "https://example.com"
|
|
29
|
+
* console.log(result.format); // "QR_CODE"
|
|
30
|
+
* } catch (err) {
|
|
31
|
+
* console.log('Scan cancelled');
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function scan(options?: ScanOptions): Promise<ScanResult>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clipboard Module
|
|
3
|
+
*
|
|
4
|
+
* Read from and write to the device clipboard.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Copy text to the device clipboard.
|
|
8
|
+
*
|
|
9
|
+
* @param text - The text to copy
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```js
|
|
13
|
+
* await nativine.clipboard.copy('https://example.com/share/abc123');
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function copy(text: string): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Read text from the device clipboard.
|
|
19
|
+
*
|
|
20
|
+
* @returns Promise resolving with the clipboard text content
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```js
|
|
24
|
+
* const text = await nativine.clipboard.read();
|
|
25
|
+
* console.log('Clipboard:', text);
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function read(): Promise<string>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contacts Module
|
|
3
|
+
*
|
|
4
|
+
* Access the device's native contact list (requires user permission).
|
|
5
|
+
*/
|
|
6
|
+
export interface Contact {
|
|
7
|
+
/** Contact display name */
|
|
8
|
+
name: string;
|
|
9
|
+
/** Phone number(s) */
|
|
10
|
+
phone: string;
|
|
11
|
+
/** Email address(es) */
|
|
12
|
+
email: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Retrieve the user's contacts from the native contact book.
|
|
16
|
+
* Prompts for permission if not already granted.
|
|
17
|
+
*
|
|
18
|
+
* @returns Promise resolving with an array of contacts
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```js
|
|
22
|
+
* const contacts = await nativine.contacts.getAll();
|
|
23
|
+
* contacts.forEach(c => {
|
|
24
|
+
* console.log(`${c.name}: ${c.phone}`);
|
|
25
|
+
* });
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function getAll(): Promise<Contact[]>;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Device Module
|
|
3
|
+
*
|
|
4
|
+
* Access device hardware/software information, safe area insets,
|
|
5
|
+
* app version, and anonymous device identifiers.
|
|
6
|
+
*/
|
|
7
|
+
export interface DeviceInfo {
|
|
8
|
+
/** Device model name (e.g., "Pixel 8", "iPhone 15") */
|
|
9
|
+
model: string;
|
|
10
|
+
/** Device manufacturer (e.g., "Google", "Apple") */
|
|
11
|
+
manufacturer: string;
|
|
12
|
+
/** Operating system version (e.g., "14", "17.2") */
|
|
13
|
+
osVersion: string;
|
|
14
|
+
/** Nativine app version name (e.g., "1.2.0") */
|
|
15
|
+
appVersion: string;
|
|
16
|
+
/** Nativine app version code (e.g., 12) */
|
|
17
|
+
appVersionCode: number;
|
|
18
|
+
/** App package name (e.g., "com.example.myapp") */
|
|
19
|
+
packageName: string;
|
|
20
|
+
/** Device locale (e.g., "en-US") */
|
|
21
|
+
locale: string;
|
|
22
|
+
/** Screen width in dp */
|
|
23
|
+
screenWidth: number;
|
|
24
|
+
/** Screen height in dp */
|
|
25
|
+
screenHeight: number;
|
|
26
|
+
/** Screen pixel density */
|
|
27
|
+
density: number;
|
|
28
|
+
/** Platform: 'android' or 'ios' */
|
|
29
|
+
platform: string;
|
|
30
|
+
}
|
|
31
|
+
export interface SafeAreaInsets {
|
|
32
|
+
/** Top safe area inset in px (e.g., status bar height) */
|
|
33
|
+
top: number;
|
|
34
|
+
/** Bottom safe area inset in px (e.g., navigation bar / home indicator) */
|
|
35
|
+
bottom: number;
|
|
36
|
+
/** Left safe area inset in px */
|
|
37
|
+
left: number;
|
|
38
|
+
/** Right safe area inset in px */
|
|
39
|
+
right: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Get comprehensive device information.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```js
|
|
46
|
+
* const info = await nativine.device.getInfo();
|
|
47
|
+
* console.log(info.model); // "Pixel 8"
|
|
48
|
+
* console.log(info.appVersion); // "1.2.0"
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export declare function getInfo(): Promise<DeviceInfo>;
|
|
52
|
+
/**
|
|
53
|
+
* Get the current safe area insets.
|
|
54
|
+
* Useful for positioning UI elements to avoid notches and system bars.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```js
|
|
58
|
+
* const insets = await nativine.device.getSafeAreaInsets();
|
|
59
|
+
* element.style.paddingTop = `${insets.top}px`;
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export declare function getSafeAreaInsets(): Promise<SafeAreaInsets>;
|
|
63
|
+
/**
|
|
64
|
+
* Get the app's version name string (e.g., "1.2.0").
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```js
|
|
68
|
+
* const version = await nativine.device.getAppVersion();
|
|
69
|
+
* // "1.2.0"
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export declare function getAppVersion(): Promise<string>;
|
|
73
|
+
/**
|
|
74
|
+
* Get an anonymous, persistent device identifier.
|
|
75
|
+
* This ID is unique per app installation (not a hardware ID).
|
|
76
|
+
* Resets when the app is reinstalled.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```js
|
|
80
|
+
* const id = await nativine.device.getDeviceId();
|
|
81
|
+
* // "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
export declare function getDeviceId(): Promise<string>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Downloads Module
|
|
3
|
+
*
|
|
4
|
+
* Trigger native file downloads using the device's download manager.
|
|
5
|
+
*/
|
|
6
|
+
export interface DownloadFileOptions {
|
|
7
|
+
/** The URL of the file to download */
|
|
8
|
+
url: string;
|
|
9
|
+
/** Custom filename (optional, auto-detected from URL if not provided) */
|
|
10
|
+
filename?: string;
|
|
11
|
+
/** MIME type of the file */
|
|
12
|
+
mimeType?: string;
|
|
13
|
+
/** Whether to open the file after download completes */
|
|
14
|
+
openAfterDownload?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Download a file using the native download manager.
|
|
18
|
+
* Shows a notification with download progress on Android.
|
|
19
|
+
*
|
|
20
|
+
* @param options - Download configuration
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```js
|
|
24
|
+
* nativine.downloads.downloadFile({
|
|
25
|
+
* url: 'https://example.com/report.pdf',
|
|
26
|
+
* filename: 'monthly-report.pdf',
|
|
27
|
+
* openAfterDownload: true
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function downloadFile(options: DownloadFileOptions): void;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Events Module
|
|
3
|
+
*
|
|
4
|
+
* Subscribe to native app lifecycle events.
|
|
5
|
+
* The native side dispatches events by calling global handler functions.
|
|
6
|
+
*/
|
|
7
|
+
export type NativineEvent = 'appResume' | 'appPause' | 'pageReady' | 'keyboardShow' | 'keyboardHide' | 'stepUpdate';
|
|
8
|
+
type EventCallback = (data?: any) => void;
|
|
9
|
+
/**
|
|
10
|
+
* Subscribe to a native app lifecycle event.
|
|
11
|
+
*
|
|
12
|
+
* Available events:
|
|
13
|
+
* - `'appResume'` — App returned to foreground
|
|
14
|
+
* - `'appPause'` — App went to background
|
|
15
|
+
* - `'pageReady'` — Bridge is fully initialized and ready
|
|
16
|
+
* - `'keyboardShow'` — Software keyboard appeared (with height data)
|
|
17
|
+
* - `'keyboardHide'` — Software keyboard dismissed
|
|
18
|
+
*
|
|
19
|
+
* @param event - The event name to listen for
|
|
20
|
+
* @param callback - Function called when the event fires
|
|
21
|
+
* @returns Unsubscribe function
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```js
|
|
25
|
+
* // Refresh data when user returns to app
|
|
26
|
+
* const unsubscribe = nativine.on('appResume', () => {
|
|
27
|
+
* fetchLatestData();
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* // Listen for keyboard visibility
|
|
31
|
+
* nativine.on('keyboardShow', ({ height }) => {
|
|
32
|
+
* adjustLayoutForKeyboard(height);
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* // Cleanup
|
|
36
|
+
* unsubscribe();
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare function on(event: NativineEvent, callback: EventCallback): () => void;
|
|
40
|
+
/**
|
|
41
|
+
* Unsubscribe all listeners for a specific event, or all events.
|
|
42
|
+
*
|
|
43
|
+
* @param event - The event to clear listeners for (or omit to clear all)
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```js
|
|
47
|
+
* // Remove all appResume listeners
|
|
48
|
+
* nativine.off('appResume');
|
|
49
|
+
*
|
|
50
|
+
* // Remove ALL event listeners
|
|
51
|
+
* nativine.off();
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare function off(event?: NativineEvent): void;
|
|
55
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Haptics Module
|
|
3
|
+
*
|
|
4
|
+
* Trigger device vibrations and haptic feedback patterns.
|
|
5
|
+
*/
|
|
6
|
+
export type HapticFeedbackType = 'light' | 'medium' | 'heavy' | 'success' | 'error' | 'warning' | 'selection';
|
|
7
|
+
/**
|
|
8
|
+
* Vibrate the device for a specified duration.
|
|
9
|
+
*
|
|
10
|
+
* @param durationMs - Duration in milliseconds (default: 100ms)
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```js
|
|
14
|
+
* nativine.haptics.vibrate(200);
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare function vibrate(durationMs?: number): void;
|
|
18
|
+
/**
|
|
19
|
+
* Trigger a predefined haptic feedback pattern.
|
|
20
|
+
*
|
|
21
|
+
* @param type - The type of haptic feedback
|
|
22
|
+
*
|
|
23
|
+
* Feedback types:
|
|
24
|
+
* - `'light'` — Subtle tap (e.g., toggle switch)
|
|
25
|
+
* - `'medium'` — Standard tap (e.g., button press)
|
|
26
|
+
* - `'heavy'` — Strong tap (e.g., action confirmation)
|
|
27
|
+
* - `'success'` — Success pattern (double tap)
|
|
28
|
+
* - `'error'` — Error pattern (triple tap)
|
|
29
|
+
* - `'warning'` — Warning pattern
|
|
30
|
+
* - `'selection'` — Selection change (lightest)
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```js
|
|
34
|
+
* // On button click
|
|
35
|
+
* nativine.haptics.feedback('medium');
|
|
36
|
+
*
|
|
37
|
+
* // On form validation error
|
|
38
|
+
* nativine.haptics.feedback('error');
|
|
39
|
+
*
|
|
40
|
+
* // On successful payment
|
|
41
|
+
* nativine.haptics.feedback('success');
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare function feedback(type?: HapticFeedbackType): void;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Location Module
|
|
3
|
+
*
|
|
4
|
+
* Access the device's GPS location.
|
|
5
|
+
*/
|
|
6
|
+
export interface LocationResult {
|
|
7
|
+
/** Latitude in degrees */
|
|
8
|
+
latitude: number;
|
|
9
|
+
/** Longitude in degrees */
|
|
10
|
+
longitude: number;
|
|
11
|
+
/** Accuracy in meters */
|
|
12
|
+
accuracy: number;
|
|
13
|
+
/** Altitude in meters (may be null on some devices) */
|
|
14
|
+
altitude?: number;
|
|
15
|
+
/** Speed in m/s (may be null) */
|
|
16
|
+
speed?: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Get the device's current GPS location.
|
|
20
|
+
* Prompts for location permission if not already granted.
|
|
21
|
+
*
|
|
22
|
+
* @returns Promise resolving with location coordinates
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```js
|
|
26
|
+
* const loc = await nativine.location.getCurrent();
|
|
27
|
+
* console.log(`Lat: ${loc.latitude}, Lng: ${loc.longitude}`);
|
|
28
|
+
* console.log(`Accuracy: ${loc.accuracy}m`);
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function getCurrent(): Promise<LocationResult>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Navigation Module
|
|
3
|
+
*
|
|
4
|
+
* Control in-app navigation: go back, go forward, navigate to URLs,
|
|
5
|
+
* open external browser, and close the app.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Navigate the WebView back one page in history.
|
|
9
|
+
* No-op if there's no back history.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```js
|
|
13
|
+
* nativine.navigation.goBack();
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function goBack(): void;
|
|
17
|
+
/**
|
|
18
|
+
* Navigate the WebView forward one page in history.
|
|
19
|
+
* No-op if there's no forward history.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```js
|
|
23
|
+
* nativine.navigation.goForward();
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function goForward(): void;
|
|
27
|
+
/**
|
|
28
|
+
* Navigate the WebView to a specific URL.
|
|
29
|
+
* Supports both absolute URLs and relative paths.
|
|
30
|
+
*
|
|
31
|
+
* @param url - The URL or path to navigate to
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```js
|
|
35
|
+
* nativine.navigation.navigate('/products');
|
|
36
|
+
* nativine.navigation.navigate('https://example.com/page');
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare function navigate(url: string): void;
|
|
40
|
+
/**
|
|
41
|
+
* Open a URL in the device's default external browser.
|
|
42
|
+
* The user leaves the app temporarily.
|
|
43
|
+
*
|
|
44
|
+
* @param url - The URL to open externally
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```js
|
|
48
|
+
* nativine.navigation.openInBrowser('https://docs.nativine.com');
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export declare function openInBrowser(url: string): void;
|
|
52
|
+
/**
|
|
53
|
+
* Close the app. On Android, this finishes the Activity.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```js
|
|
57
|
+
* nativine.navigation.closeApp();
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare function closeApp(): void;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Network Module
|
|
3
|
+
*
|
|
4
|
+
* Check connectivity status and listen for network changes.
|
|
5
|
+
*/
|
|
6
|
+
export interface ConnectivityStatus {
|
|
7
|
+
/** Whether the device is online */
|
|
8
|
+
online: boolean;
|
|
9
|
+
/** Connection type: 'wifi', 'cellular', 'ethernet', 'none', 'unknown' */
|
|
10
|
+
type: 'wifi' | 'cellular' | 'ethernet' | 'none' | 'unknown';
|
|
11
|
+
}
|
|
12
|
+
type ConnectivityCallback = (status: ConnectivityStatus) => void;
|
|
13
|
+
/**
|
|
14
|
+
* Check if the device currently has network connectivity.
|
|
15
|
+
*
|
|
16
|
+
* @returns Promise resolving with connectivity status
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```js
|
|
20
|
+
* const status = await nativine.network.isOnline();
|
|
21
|
+
* if (!status.online) {
|
|
22
|
+
* showOfflineBanner();
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function isOnline(): Promise<ConnectivityStatus>;
|
|
27
|
+
/**
|
|
28
|
+
* Listen for network connectivity changes.
|
|
29
|
+
*
|
|
30
|
+
* @param callback - Function called when connectivity changes
|
|
31
|
+
* @returns Unsubscribe function to stop listening
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```js
|
|
35
|
+
* const unsubscribe = nativine.network.onConnectivityChange((status) => {
|
|
36
|
+
* if (!status.online) {
|
|
37
|
+
* showOfflineBanner();
|
|
38
|
+
* } else {
|
|
39
|
+
* hideOfflineBanner();
|
|
40
|
+
* }
|
|
41
|
+
* });
|
|
42
|
+
*
|
|
43
|
+
* // Later: stop listening
|
|
44
|
+
* unsubscribe();
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare function onConnectivityChange(callback: ConnectivityCallback): () => void;
|
|
48
|
+
/**
|
|
49
|
+
* Internal: Called by the native side when connectivity changes.
|
|
50
|
+
* Dispatches to all registered listeners.
|
|
51
|
+
* @internal
|
|
52
|
+
*/
|
|
53
|
+
export declare function _onConnectivityChanged(status: ConnectivityStatus): void;
|
|
54
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OneSignal Module
|
|
3
|
+
*
|
|
4
|
+
* Interact with OneSignal push notification service from your web app.
|
|
5
|
+
* Requires the OneSignal addon to be enabled in your Nativine app.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Set the OneSignal external user ID.
|
|
9
|
+
* Links the device's push subscription to your backend user ID.
|
|
10
|
+
*
|
|
11
|
+
* @param userId - Your app's user identifier
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```js
|
|
15
|
+
* // After user logs in
|
|
16
|
+
* nativine.onesignal.setExternalUserId('user_12345');
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function setExternalUserId(userId: string): void;
|
|
20
|
+
/**
|
|
21
|
+
* Send a tag (key-value pair) to OneSignal for audience segmentation.
|
|
22
|
+
*
|
|
23
|
+
* @param key - Tag key
|
|
24
|
+
* @param value - Tag value
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```js
|
|
28
|
+
* nativine.onesignal.sendTag('plan', 'premium');
|
|
29
|
+
* nativine.onesignal.sendTag('language', 'en');
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function sendTag(key: string, value: string): void;
|
|
33
|
+
/**
|
|
34
|
+
* Send multiple tags at once to OneSignal.
|
|
35
|
+
*
|
|
36
|
+
* @param tags - Object with tag key-value pairs
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```js
|
|
40
|
+
* nativine.onesignal.sendTags({
|
|
41
|
+
* plan: 'premium',
|
|
42
|
+
* language: 'en',
|
|
43
|
+
* onboarded: 'true'
|
|
44
|
+
* });
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare function sendTags(tags: Record<string, string>): void;
|
|
48
|
+
/**
|
|
49
|
+
* Get the OneSignal Player ID (push subscription ID) for this device.
|
|
50
|
+
*
|
|
51
|
+
* @returns Promise resolving with the player ID string
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```js
|
|
55
|
+
* const playerId = await nativine.onesignal.getPlayerId();
|
|
56
|
+
* // Send to your backend for targeted push notifications
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare function getPlayerId(): Promise<string>;
|
|
60
|
+
/**
|
|
61
|
+
* Remove the external user ID association.
|
|
62
|
+
* Call this when the user logs out.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```js
|
|
66
|
+
* // On logout
|
|
67
|
+
* nativine.onesignal.removeExternalUserId();
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export declare function removeExternalUserId(): void;
|