despia-native 1.0.7 → 1.0.9
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 +66 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -47,6 +47,72 @@ Our visual editor allows you to configure native widgets, shortcuts, and dynamic
|
|
|
47
47
|
npm install despia-native
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
+
## Getting Started
|
|
51
|
+
|
|
52
|
+
### Step 1: Import Despia SDK
|
|
53
|
+
|
|
54
|
+
```javascript
|
|
55
|
+
// ES6/ES2015 modules
|
|
56
|
+
import despia from 'despia-native';
|
|
57
|
+
|
|
58
|
+
// CommonJS
|
|
59
|
+
const despia = require('despia-native');
|
|
60
|
+
|
|
61
|
+
// Browser (if using UMD build)
|
|
62
|
+
// <script src="despia-native.js"></script>
|
|
63
|
+
// despia is available globally
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Step 2: Use Native Features
|
|
67
|
+
|
|
68
|
+
```javascript
|
|
69
|
+
// Simple commands (no response needed)
|
|
70
|
+
despia('lighthaptic://'); // Light haptic feedback
|
|
71
|
+
despia('takescreenshot://'); // Take screenshot
|
|
72
|
+
despia('spinneron://'); // Show loading spinner
|
|
73
|
+
|
|
74
|
+
// Commands that return data (use await)
|
|
75
|
+
const appInfo = await despia('getappversion://', ['versionNumber', 'bundleNumber']);
|
|
76
|
+
console.log(appInfo); // { versionNumber: '1.0.0', bundleNumber: '123' }
|
|
77
|
+
|
|
78
|
+
const contacts = await despia('readcontacts://', ['contacts']);
|
|
79
|
+
console.log(contacts); // { contacts: [...] }
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Step 3: Handle Responses
|
|
83
|
+
|
|
84
|
+
```javascript
|
|
85
|
+
// For commands that set variables, watch for them
|
|
86
|
+
const result = await despia('get-uuid://', ['uuid']);
|
|
87
|
+
console.log('Device UUID:', result.uuid);
|
|
88
|
+
|
|
89
|
+
// For commands with no response, just call them
|
|
90
|
+
despia('lighthaptic://');
|
|
91
|
+
despia('takescreenshot://');
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Quick Examples
|
|
95
|
+
|
|
96
|
+
```javascript
|
|
97
|
+
// Haptic feedback
|
|
98
|
+
despia('lighthaptic://'); // Light vibration
|
|
99
|
+
despia('heavyhaptic://'); // Heavy vibration
|
|
100
|
+
despia('successhaptic://'); // Success vibration
|
|
101
|
+
|
|
102
|
+
// App information
|
|
103
|
+
const appInfo = await despia('getappversion://', ['versionNumber', 'bundleNumber']);
|
|
104
|
+
const deviceId = await despia('get-uuid://', ['uuid']);
|
|
105
|
+
|
|
106
|
+
// UI controls
|
|
107
|
+
despia('spinneron://'); // Show loading
|
|
108
|
+
despia('spinneroff://'); // Hide loading
|
|
109
|
+
despia('hidebars://on'); // Hide status bar
|
|
110
|
+
|
|
111
|
+
// Screenshots and sharing
|
|
112
|
+
despia('takescreenshot://');
|
|
113
|
+
despia('shareapp://message?=Hello&url=https://myapp.com');
|
|
114
|
+
```
|
|
115
|
+
|
|
50
116
|
## Usage
|
|
51
117
|
|
|
52
118
|
### Basic Despia Command Execution
|
|
@@ -452,7 +518,6 @@ Despia operates through a streamlined protocol handler system, allowing you to i
|
|
|
452
518
|
- **Direct Access** - Proxy-based access to window variables
|
|
453
519
|
|
|
454
520
|
### How It Works
|
|
455
|
-
|
|
456
521
|
Despia's protocol handler system eliminates the need for complex libraries or dependencies, making it compatible across various frameworks and platforms. The SDK uses the setter pattern to execute commands:
|
|
457
522
|
|
|
458
523
|
```javascript
|