leap-capacitor 1.2.0 → 1.3.0
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 +10 -0
- package/android/build.gradle +1 -1
- package/android/src/main/java/is/leap/capacitor/LeapPlugin.java +8 -7
- package/dist/docs.json +10 -0
- package/dist/esm/definitions.d.ts +1 -0
- package/dist/esm/definitions.js.map +1 -1
- package/ios/Plugin/LeapPlugin.m +1 -0
- package/ios/Plugin/LeapPlugin.swift +16 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,6 +23,7 @@ npx cap sync
|
|
|
23
23
|
* [`embedProject(...)`](#embedproject)
|
|
24
24
|
* [`offlineSync(...)`](#offlinesync)
|
|
25
25
|
* [`disable()`](#disable)
|
|
26
|
+
* [`logout()`](#logout)
|
|
26
27
|
* [`setAppLocale(...)`](#setapplocale)
|
|
27
28
|
* [`addListener('leapCallbacks', ...)`](#addlistenerleapcallbacks)
|
|
28
29
|
* [`addListener('leapElementActionCallbacks', ...)`](#addlistenerleapelementactioncallbacks)
|
|
@@ -159,6 +160,15 @@ disable() => Promise<void>
|
|
|
159
160
|
--------------------
|
|
160
161
|
|
|
161
162
|
|
|
163
|
+
### logout()
|
|
164
|
+
|
|
165
|
+
```typescript
|
|
166
|
+
logout() => Promise<void>
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
--------------------
|
|
170
|
+
|
|
171
|
+
|
|
162
172
|
### setAppLocale(...)
|
|
163
173
|
|
|
164
174
|
```typescript
|
package/android/build.gradle
CHANGED
|
@@ -51,7 +51,7 @@ repositories {
|
|
|
51
51
|
dependencies {
|
|
52
52
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
53
53
|
implementation project(':capacitor-android')
|
|
54
|
-
implementation 'is.leap.android:sdk:1.
|
|
54
|
+
implementation 'is.leap.android:sdk:1.8.2'
|
|
55
55
|
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
56
56
|
testImplementation "junit:junit:$junitVersion"
|
|
57
57
|
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
@@ -59,7 +59,6 @@ public class LeapPlugin extends Plugin {
|
|
|
59
59
|
private static final String FORMAT_SDF = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
|
|
60
60
|
private static final String TIMEZONE_GMT = "GMT";
|
|
61
61
|
public static final String LOCALE_CODE = "localeCode";
|
|
62
|
-
public static final String WFX_CLIENT_UNIQUE_ID = "wfx_user_id";
|
|
63
62
|
|
|
64
63
|
public LeapPlugin() {
|
|
65
64
|
setLeapEventEmitter();
|
|
@@ -120,11 +119,6 @@ public class LeapPlugin extends Plugin {
|
|
|
120
119
|
|
|
121
120
|
while (iterator.hasNext()) {
|
|
122
121
|
String key = iterator.next();
|
|
123
|
-
if(WFX_CLIENT_UNIQUE_ID.equals(key)) {
|
|
124
|
-
String uniqueId = propsObj.getString(key);
|
|
125
|
-
leapBuilder.addUniqueId(uniqueId);
|
|
126
|
-
continue;
|
|
127
|
-
}
|
|
128
122
|
Object propValue = null;
|
|
129
123
|
try {
|
|
130
124
|
propValue = propsObj.get(key);
|
|
@@ -187,6 +181,12 @@ public class LeapPlugin extends Plugin {
|
|
|
187
181
|
call.resolve();
|
|
188
182
|
}
|
|
189
183
|
|
|
184
|
+
@PluginMethod
|
|
185
|
+
public static void logout(PluginCall call) {
|
|
186
|
+
Leap.logout();
|
|
187
|
+
call.resolve();
|
|
188
|
+
}
|
|
189
|
+
|
|
190
190
|
@PluginMethod
|
|
191
191
|
public static void startProject(PluginCall call) {
|
|
192
192
|
String projectID = call.getString(PROJECT_ID);
|
|
@@ -229,8 +229,9 @@ public class LeapPlugin extends Plugin {
|
|
|
229
229
|
}
|
|
230
230
|
|
|
231
231
|
@PluginMethod
|
|
232
|
-
public void disable() {
|
|
232
|
+
public void disable(PluginCall call) {
|
|
233
233
|
Leap.disable();
|
|
234
|
+
call.resolve();
|
|
234
235
|
}
|
|
235
236
|
|
|
236
237
|
@PluginMethod
|
package/dist/docs.json
CHANGED
|
@@ -167,6 +167,16 @@
|
|
|
167
167
|
"complexTypes": [],
|
|
168
168
|
"slug": "disable"
|
|
169
169
|
},
|
|
170
|
+
{
|
|
171
|
+
"name": "logout",
|
|
172
|
+
"signature": "() => Promise<void>",
|
|
173
|
+
"parameters": [],
|
|
174
|
+
"returns": "Promise<void>",
|
|
175
|
+
"tags": [],
|
|
176
|
+
"docs": "",
|
|
177
|
+
"complexTypes": [],
|
|
178
|
+
"slug": "logout"
|
|
179
|
+
},
|
|
170
180
|
{
|
|
171
181
|
"name": "setAppLocale",
|
|
172
182
|
"signature": "(options: { localeCode: string; }) => Promise<void>",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["\nimport type { PluginListenerHandle } from '@capacitor/core';\n\nexport interface UserProperty {\n [key: string]: string | number\n}\n\nexport interface LeapCallbacks {\n [key: string]: string\n}\n\nexport interface LeapElementActionCallbacks {\n [key: string]: any\n}\n\nexport interface LeapPluginInterface {\n start(options: { apiKey: string }): Promise<void>;\n startWithProperties(options: { apiKey: string, properties: UserProperty }): Promise<void>;\n startWithSelfHostedURL(options:{baseURL: string}):Promise<void>;\n startWithSelfHostedURLAndProperties(options:{baseURL:string, properties: UserProperty}):Promise<void>;\n flushProperties(options: { properties: UserProperty }): Promise<void>;\n setUniqueUserId(options: { uniqueUserId: string }): Promise<void>;\n startProject(options: { projectId: string, resetProject?: boolean }): Promise<void>;\n embedProject(options: { projectId: string }): Promise<void>;\n offlineSync(options: { projectIds: Array<string> }): Promise<void>;\n disable(): Promise<void>;\n setAppLocale(options: {localeCode: string}): Promise<void>;\n\n addListener(\n eventName: 'leapCallbacks',\n listenerFunc: (event: LeapCallbacks) => void,\n ): Promise<PluginListenerHandle> & PluginListenerHandle\n\n addListener(\n eventName: 'leapElementActionCallbacks',\n listenerFunc: (event: LeapElementActionCallbacks) => void,\n ): Promise<PluginListenerHandle> & PluginListenerHandle\n\n\n}\n"]}
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["\nimport type { PluginListenerHandle } from '@capacitor/core';\n\nexport interface UserProperty {\n [key: string]: string | number\n}\n\nexport interface LeapCallbacks {\n [key: string]: string\n}\n\nexport interface LeapElementActionCallbacks {\n [key: string]: any\n}\n\nexport interface LeapPluginInterface {\n start(options: { apiKey: string }): Promise<void>;\n startWithProperties(options: { apiKey: string, properties: UserProperty }): Promise<void>;\n startWithSelfHostedURL(options:{baseURL: string}):Promise<void>;\n startWithSelfHostedURLAndProperties(options:{baseURL:string, properties: UserProperty}):Promise<void>;\n flushProperties(options: { properties: UserProperty }): Promise<void>;\n setUniqueUserId(options: { uniqueUserId: string }): Promise<void>;\n startProject(options: { projectId: string, resetProject?: boolean }): Promise<void>;\n embedProject(options: { projectId: string }): Promise<void>;\n offlineSync(options: { projectIds: Array<string> }): Promise<void>;\n disable(): Promise<void>;\n logout(): Promise<void>;\n setAppLocale(options: {localeCode: string}): Promise<void>;\n\n addListener(\n eventName: 'leapCallbacks',\n listenerFunc: (event: LeapCallbacks) => void,\n ): Promise<PluginListenerHandle> & PluginListenerHandle\n\n addListener(\n eventName: 'leapElementActionCallbacks',\n listenerFunc: (event: LeapElementActionCallbacks) => void,\n ): Promise<PluginListenerHandle> & PluginListenerHandle\n\n\n}\n"]}
|
package/ios/Plugin/LeapPlugin.m
CHANGED
|
@@ -15,4 +15,5 @@ CAP_PLUGIN(LeapPlugin, "LeapPlugin",
|
|
|
15
15
|
CAP_PLUGIN_METHOD(setAppLocale, CAPPluginReturnPromise);
|
|
16
16
|
CAP_PLUGIN_METHOD(offlineSync, CAPPluginReturnPromise);
|
|
17
17
|
CAP_PLUGIN_METHOD(disable, CAPPluginReturnPromise);
|
|
18
|
+
CAP_PLUGIN_METHOD(logout, CAPPluginReturnPromise);
|
|
18
19
|
)
|
|
@@ -14,7 +14,6 @@ let PROJECT_IDS = "projectIds"
|
|
|
14
14
|
let DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
|
|
15
15
|
let DATE_LOCALE = "en_US_POSIX"
|
|
16
16
|
let LEAP_CALLBACKS = "leapCallbacks"
|
|
17
|
-
let WFX_UNIQUE_ID = "wfx_user_id"
|
|
18
17
|
|
|
19
18
|
/**
|
|
20
19
|
* Please read the Capacitor iOS Plugin Development Guide
|
|
@@ -38,7 +37,6 @@ public class LeapPlugin: CAPPlugin {
|
|
|
38
37
|
let properties:[String:AnyHashable] = call.getObject(PROPERTIES) as? [String:AnyHashable] ?? [:]
|
|
39
38
|
DispatchQueue.main.async {[weak self] in
|
|
40
39
|
let leapShared = Leap.shared.withBuilder(apiKey)
|
|
41
|
-
if let wfxId = properties[WFX_UNIQUE_ID] as? String { Leap.shared.addUniqueUserId(wfxId) }
|
|
42
40
|
self?.addProperties(properties: properties)
|
|
43
41
|
leapShared?.start()
|
|
44
42
|
}
|
|
@@ -59,7 +57,6 @@ public class LeapPlugin: CAPPlugin {
|
|
|
59
57
|
let properties = call.getObject(PROPERTIES) as? [String:AnyHashable] ?? [:]
|
|
60
58
|
DispatchQueue.main.async {[weak self] in
|
|
61
59
|
Leap.shared.withSelfHostedBuilder()?.setBaseUrl(baseUrl)
|
|
62
|
-
if let wfxId = properties[WFX_UNIQUE_ID] as? String { Leap.shared.addUniqueUserId(wfxId) }
|
|
63
60
|
self?.addProperties(properties: properties)
|
|
64
61
|
Leap.shared.start()
|
|
65
62
|
}
|
|
@@ -125,21 +122,26 @@ public class LeapPlugin: CAPPlugin {
|
|
|
125
122
|
call.resolve()
|
|
126
123
|
}
|
|
127
124
|
|
|
125
|
+
@objc public func logout(_ call: CAPPluginCall) {
|
|
126
|
+
DispatchQueue.main.async {
|
|
127
|
+
Leap.shared.logout()
|
|
128
|
+
}
|
|
129
|
+
call.resolve()
|
|
130
|
+
}
|
|
131
|
+
|
|
128
132
|
func addProperties(properties:[String:AnyHashable]) {
|
|
129
133
|
properties.forEach { key, value in
|
|
130
|
-
if
|
|
131
|
-
if
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
Leap.shared.addProperty(key, dateValue: date)
|
|
136
|
-
}
|
|
137
|
-
} else {
|
|
138
|
-
Leap.shared.addProperty(key, stringValue: stringValue)
|
|
134
|
+
if let stringValue = value as? String {
|
|
135
|
+
if stringValue.hasPrefix(DATE_PREFIX) {
|
|
136
|
+
let dateValue = stringValue.components(separatedBy: DATE_PREFIX).last ?? ""
|
|
137
|
+
if let date = self.getDateFromISOString(dateString: dateValue) {
|
|
138
|
+
Leap.shared.addProperty(key, dateValue: date)
|
|
139
139
|
}
|
|
140
|
-
} else
|
|
141
|
-
Leap.shared.addProperty(key,
|
|
140
|
+
} else {
|
|
141
|
+
Leap.shared.addProperty(key, stringValue: stringValue)
|
|
142
142
|
}
|
|
143
|
+
} else if let intValue = value as? Int {
|
|
144
|
+
Leap.shared.addProperty(key, intValue: intValue)
|
|
143
145
|
}
|
|
144
146
|
}
|
|
145
147
|
}
|