capacitor-record360sdk 8.26.0 → 8.30.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/CapacitorRecord360sdk.podspec +1 -1
- package/README.md +41 -5
- package/android/build.gradle +3 -3
- package/android/src/main/java/com/record360/plugins/CapacitorRecord360SDKPlugin.kt +54 -26
- package/android/src/main/java/com/record360/plugins/SampleRecord360Activity.kt +9 -0
- package/dist/docs.json +2 -2
- package/dist/esm/definitions.d.ts +4 -4
- package/dist/esm/definitions.js.map +1 -1
- package/ios/Sources/CapacitorRecord360SDKPlugin/CapacitorRecord360SDKPlugin.swift +55 -30
- package/package.json +1 -1
|
@@ -13,6 +13,6 @@ Pod::Spec.new do |s|
|
|
|
13
13
|
s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
14
|
s.ios.deployment_target = '15.0'
|
|
15
15
|
s.dependency 'Capacitor'
|
|
16
|
-
s.dependency 'Record360SDK', '4.
|
|
16
|
+
s.dependency 'Record360SDK', '4.24.7'
|
|
17
17
|
s.swift_version = '5.1'
|
|
18
18
|
end
|
package/README.md
CHANGED
|
@@ -53,13 +53,13 @@ launchReferenceCapture(options: { referenceNumber: string; department?: string;
|
|
|
53
53
|
### addListener('Record360Event', ...)
|
|
54
54
|
|
|
55
55
|
```typescript
|
|
56
|
-
addListener(eventName: 'Record360Event', listenerFunc: (data: { type: 'onFailedToAuthenticate' | 'onInspectionCancelled' | 'onInspectionComplete' | 'onInspectionUploadFailed' | 'onInspectionUploadProgress' | 'onInspectionUploaded' | 'onInspectionStarted' | 'onUserAuthenticated'; referenceNumber?: string;
|
|
56
|
+
addListener(eventName: 'Record360Event', listenerFunc: (data: { type: 'onFailedToAuthenticate' | 'onInspectionCancelled' | 'onInspectionComplete' | 'onInspectionUploadFailed' | 'onInspectionUploadProgress' | 'onInspectionUploaded' | 'onInspectionUploadDeleted' | 'onInspectionStarted' | 'onUserAuthenticated' | 'onSDKShouldRelaunch' | 'onSDKShouldExit'; referenceNumber?: string; inspectionNonce?: string; percentComplete?: number; error?: string; userId?: string; inspectionJSON?: string; }) => void) => Promise<PluginListenerHandle>
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
-
| Param | Type
|
|
60
|
-
| ------------------ |
|
|
61
|
-
| **`eventName`** | <code>'Record360Event'</code>
|
|
62
|
-
| **`listenerFunc`** | <code>(data: { type: 'onFailedToAuthenticate' \| 'onInspectionCancelled' \| 'onInspectionComplete' \| 'onInspectionUploadFailed' \| 'onInspectionUploadProgress' \| 'onInspectionUploaded' \| 'onInspectionStarted' \| 'onUserAuthenticated'; referenceNumber?: string;
|
|
59
|
+
| Param | Type |
|
|
60
|
+
| ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
61
|
+
| **`eventName`** | <code>'Record360Event'</code> |
|
|
62
|
+
| **`listenerFunc`** | <code>(data: { type: 'onFailedToAuthenticate' \| 'onInspectionCancelled' \| 'onInspectionComplete' \| 'onInspectionUploadFailed' \| 'onInspectionUploadProgress' \| 'onInspectionUploaded' \| 'onInspectionUploadDeleted' \| 'onInspectionStarted' \| 'onUserAuthenticated' \| 'onSDKShouldRelaunch' \| 'onSDKShouldExit'; referenceNumber?: string; inspectionNonce?: string; percentComplete?: number; error?: string; userId?: string; inspectionJSON?: string; }) => void</code> |
|
|
63
63
|
|
|
64
64
|
**Returns:** <code>Promise<<a href="#pluginlistenerhandle">PluginListenerHandle</a>></code>
|
|
65
65
|
|
|
@@ -105,3 +105,39 @@ addListener(eventName: 'Record360Event', listenerFunc: (data: { type: 'onFailedT
|
|
|
105
105
|
<code>{ [key: string]: unknown }</code>
|
|
106
106
|
|
|
107
107
|
</docgen-api>
|
|
108
|
+
|
|
109
|
+
## Changelog
|
|
110
|
+
|
|
111
|
+
### 8.30.2
|
|
112
|
+
|
|
113
|
+
Pairs with Android SDK 4.30.2 and iOS SDK 4.24.7.
|
|
114
|
+
|
|
115
|
+
Android fixes:
|
|
116
|
+
- The plugin now finishes the host activity it launched on `onSDKShouldExit`, matching the iOS dismissal. Previously a blank screen stayed up after the SDK exited until the user pressed Back.
|
|
117
|
+
- `onSDKShouldExit` now follows `onFailedToAuthenticate` when the credentials passed to a launch call are rejected, once the error dialog is dismissed. Previously no exit event arrived and the blank screen stayed up.
|
|
118
|
+
|
|
119
|
+
### 8.30.1
|
|
120
|
+
|
|
121
|
+
Capacitor 8 release carrying the unified Record360 SDK callbacks. Pairs with Android SDK 4.30.1 and iOS SDK 4.24.7.
|
|
122
|
+
|
|
123
|
+
Requirements (updates needed in the consuming app):
|
|
124
|
+
- Android: `minSdkVersion` 26, Kotlin Gradle plugin 2.1 or newer (the SDK is compiled with Kotlin 2.2), compileSdk 36
|
|
125
|
+
- iOS: deployment target 15.0
|
|
126
|
+
|
|
127
|
+
Event payload changes on `Record360Event`:
|
|
128
|
+
- Every inspection event now carries `inspectionNonce`, an id unique per inspection and identical across all of that inspection's events. Reference numbers repeat across inspections of the same unit; correlate on the nonce.
|
|
129
|
+
- `onInspectionUploadProgress` sends `percentComplete` as a fraction from 0 to 1. `bytesComplete` and `bytesTotal` are removed.
|
|
130
|
+
- `onInspectionUploadFailed` carries an `error` message on both platforms.
|
|
131
|
+
- `onUserAuthenticated` no longer includes `username`.
|
|
132
|
+
- `onInspectionStarted` fires once the inspection has been created, on both platforms. It previously fired from the reference-number prefill request on Android only.
|
|
133
|
+
|
|
134
|
+
New event types:
|
|
135
|
+
- `onInspectionUploadDeleted`: the user removed a queued upload from the Uploads screen.
|
|
136
|
+
- `onSDKShouldExit`: the SDK handed control back to the app. Fires exactly once per launch, after any inspection event. On iOS the plugin dismisses the SDK view controller on this event.
|
|
137
|
+
- `onSDKShouldRelaunch`: iOS only; the SDK dismissed after a workflow update and the plugin relaunches it with the last launch call.
|
|
138
|
+
|
|
139
|
+
Behavior changes:
|
|
140
|
+
- `onInspectionCancelled` fires whenever an in-progress inspection is discarded: the delete dialog, logout, session expiry, or a new launch for a different reference number or user. On iOS it no longer fires for plain dismissal, a cancelled sign-in, or declined terms; those report `onSDKShouldExit` only.
|
|
141
|
+
- On iOS, `onInspectionComplete` and `onInspectionCancelled` no longer dismiss the SDK view controller themselves; dismissal happens on `onSDKShouldExit`.
|
|
142
|
+
- Android `onInspectionUploaded` now passes the reference number; it previously passed an internal upload id.
|
|
143
|
+
|
package/android/build.gradle
CHANGED
|
@@ -6,9 +6,9 @@ buildscript {
|
|
|
6
6
|
androidxEspressoCoreVersion = '3.6.1'
|
|
7
7
|
androidXCore = '1.15.0'
|
|
8
8
|
compileSdk = 36
|
|
9
|
-
minSdkVersion =
|
|
9
|
+
minSdkVersion = 26
|
|
10
10
|
targetSdkVersion = 36
|
|
11
|
-
kotlinVersion = '2.0
|
|
11
|
+
kotlinVersion = '2.2.0'
|
|
12
12
|
androidxCoreVersion = '1.15.0'
|
|
13
13
|
androidxActivityVersion = '1.9.2'
|
|
14
14
|
androidxFragmentVersion = '1.8.4'
|
|
@@ -101,6 +101,6 @@ dependencies {
|
|
|
101
101
|
testImplementation "junit:junit:$junitVersion"
|
|
102
102
|
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
103
103
|
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
104
|
-
implementation 'com.record360.sdk:android-sdk:4.
|
|
104
|
+
implementation 'com.record360.sdk:android-sdk:4.30.2'
|
|
105
105
|
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'
|
|
106
106
|
}
|
|
@@ -114,84 +114,112 @@ open class CapacitorRecord360SDKPlugin : Plugin(), IRecord360Interface {
|
|
|
114
114
|
return contractFieldData
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
override fun
|
|
118
|
-
Log.i(TAG, "
|
|
117
|
+
override fun onFailedAuthentication(error: Throwable) {
|
|
118
|
+
Log.i(TAG, "onFailedAuthentication")
|
|
119
119
|
val data = JSObject().apply {
|
|
120
120
|
put("type", "onFailedToAuthenticate")
|
|
121
|
+
put("error", error.localizedMessage)
|
|
121
122
|
}
|
|
122
123
|
notifyListeners(EVENT_NAME, data)
|
|
123
124
|
}
|
|
124
125
|
|
|
125
|
-
override fun onInspectionCancelled(
|
|
126
|
-
Log.i(TAG, "onInspectionCancelled")
|
|
126
|
+
override fun onInspectionCancelled(refNum: String, inspectionNonce: String) {
|
|
127
|
+
Log.i(TAG, "onInspectionCancelled refNum=$refNum nonce=$inspectionNonce")
|
|
127
128
|
val data = JSObject().apply {
|
|
128
129
|
put("type", "onInspectionCancelled")
|
|
129
|
-
put("referenceNumber",
|
|
130
|
+
put("referenceNumber", refNum)
|
|
131
|
+
put("inspectionNonce", inspectionNonce)
|
|
130
132
|
}
|
|
131
133
|
notifyListeners(EVENT_NAME, data)
|
|
132
134
|
}
|
|
133
135
|
|
|
134
|
-
override fun onInspectionComplete(
|
|
135
|
-
Log.i(TAG, "onInspectionComplete")
|
|
136
|
+
override fun onInspectionComplete(refNum: String, inspectionNonce: String) {
|
|
137
|
+
Log.i(TAG, "onInspectionComplete refNum=$refNum nonce=$inspectionNonce")
|
|
136
138
|
val data = JSObject().apply {
|
|
137
139
|
put("type", "onInspectionComplete")
|
|
138
|
-
put("referenceNumber",
|
|
140
|
+
put("referenceNumber", refNum)
|
|
141
|
+
put("inspectionNonce", inspectionNonce)
|
|
139
142
|
}
|
|
140
143
|
notifyListeners(EVENT_NAME, data)
|
|
141
144
|
}
|
|
142
145
|
|
|
143
|
-
override fun onInspectionUploadFailed(
|
|
144
|
-
Log.i(TAG, "onInspectionUploadFailed")
|
|
146
|
+
override fun onInspectionUploadFailed(refNum: String, inspectionNonce: String, error: String) {
|
|
147
|
+
Log.i(TAG, "onInspectionUploadFailed refNum=$refNum nonce=$inspectionNonce error=$error")
|
|
145
148
|
val data = JSObject().apply {
|
|
146
149
|
put("type", "onInspectionUploadFailed")
|
|
147
|
-
put("referenceNumber",
|
|
150
|
+
put("referenceNumber", refNum)
|
|
151
|
+
put("inspectionNonce", inspectionNonce)
|
|
148
152
|
put("error", error)
|
|
149
153
|
}
|
|
150
154
|
notifyListeners(EVENT_NAME, data)
|
|
151
155
|
}
|
|
152
156
|
|
|
153
|
-
override fun onInspectionUploadProgress(
|
|
154
|
-
Log.i(TAG, "onInspectionUploadProgress")
|
|
155
|
-
val percentComplete = if (total > 0) complete.toDouble() / total.toDouble() else 0.0
|
|
157
|
+
override fun onInspectionUploadProgress(refNum: String, inspectionNonce: String, percentComplete: Double) {
|
|
158
|
+
Log.i(TAG, "onInspectionUploadProgress refNum=$refNum nonce=$inspectionNonce percent=$percentComplete")
|
|
156
159
|
val data = JSObject().apply {
|
|
157
160
|
put("type", "onInspectionUploadProgress")
|
|
158
|
-
put("referenceNumber",
|
|
159
|
-
put("
|
|
160
|
-
put("bytesTotal", total)
|
|
161
|
+
put("referenceNumber", refNum)
|
|
162
|
+
put("inspectionNonce", inspectionNonce)
|
|
161
163
|
put("percentComplete", percentComplete)
|
|
162
164
|
}
|
|
163
165
|
notifyListeners(EVENT_NAME, data)
|
|
164
166
|
}
|
|
165
167
|
|
|
166
|
-
override fun onInspectionUploaded(
|
|
167
|
-
Log.i(TAG, "onInspectionUploaded")
|
|
168
|
+
override fun onInspectionUploaded(refNum: String, inspectionNonce: String, inspectionJSON: String) {
|
|
169
|
+
Log.i(TAG, "onInspectionUploaded refNum=$refNum nonce=$inspectionNonce")
|
|
168
170
|
val data = JSObject().apply {
|
|
169
171
|
put("type", "onInspectionUploaded")
|
|
170
|
-
put("referenceNumber",
|
|
171
|
-
put("
|
|
172
|
+
put("referenceNumber", refNum)
|
|
173
|
+
put("inspectionNonce", inspectionNonce)
|
|
174
|
+
put("inspectionJSON", inspectionJSON)
|
|
172
175
|
}
|
|
173
176
|
notifyListeners(EVENT_NAME, data)
|
|
174
177
|
}
|
|
175
178
|
|
|
179
|
+
override fun onInspectionUploadDeleted(refNum: String, inspectionNonce: String) {
|
|
180
|
+
Log.i(TAG, "onInspectionUploadDeleted refNum=$refNum nonce=$inspectionNonce")
|
|
181
|
+
val data = JSObject().apply {
|
|
182
|
+
put("type", "onInspectionUploadDeleted")
|
|
183
|
+
put("referenceNumber", refNum)
|
|
184
|
+
put("inspectionNonce", inspectionNonce)
|
|
185
|
+
}
|
|
186
|
+
notifyListeners(EVENT_NAME, data)
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
override fun onSDKShouldRelaunch() {
|
|
190
|
+
Log.i(TAG, "onSDKShouldRelaunch")
|
|
191
|
+
notifyListeners(EVENT_NAME, JSObject().apply { put("type", "onSDKShouldRelaunch") })
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
override fun onSDKShouldExit() {
|
|
195
|
+
Log.i(TAG, "onSDKShouldExit")
|
|
196
|
+
notifyListeners(EVENT_NAME, JSObject().apply { put("type", "onSDKShouldExit") })
|
|
197
|
+
SampleRecord360Activity.current?.get()?.finish()
|
|
198
|
+
}
|
|
199
|
+
|
|
176
200
|
override fun onReferenceNumberEnteredWithFieldData(
|
|
177
201
|
referenceNumber: String?,
|
|
178
202
|
fieldData: Map<String?, String?>?
|
|
179
203
|
): Map<String?, String?>? {
|
|
180
204
|
Log.i(TAG, "onRefNumEntered")
|
|
205
|
+
return fieldData
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
override fun onInspectionStarted(refNum: String, inspectionNonce: String) {
|
|
209
|
+
Log.i(TAG, "onInspectionStarted refNum=$refNum nonce=$inspectionNonce")
|
|
181
210
|
val data = JSObject().apply {
|
|
182
211
|
put("type", "onInspectionStarted")
|
|
183
|
-
put("referenceNumber",
|
|
212
|
+
put("referenceNumber", refNum)
|
|
213
|
+
put("inspectionNonce", inspectionNonce)
|
|
184
214
|
}
|
|
185
215
|
notifyListeners(EVENT_NAME, data)
|
|
186
|
-
return fieldData
|
|
187
216
|
}
|
|
188
217
|
|
|
189
|
-
override fun
|
|
190
|
-
Log.i(TAG, "
|
|
218
|
+
override fun onSuccessfulAuthentication(userToken: String, userId: String) {
|
|
219
|
+
Log.i(TAG, "onSuccessfulAuthentication")
|
|
191
220
|
val data = JSObject().apply {
|
|
192
221
|
put("type", "onUserAuthenticated")
|
|
193
222
|
put("userId", userId)
|
|
194
|
-
put("username", username)
|
|
195
223
|
}
|
|
196
224
|
notifyListeners(EVENT_NAME, data)
|
|
197
225
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
package com.record360.plugins
|
|
2
2
|
|
|
3
3
|
import android.os.Bundle
|
|
4
|
+
import java.lang.ref.WeakReference
|
|
4
5
|
import com.record360.sdk.R360Identity
|
|
5
6
|
import com.record360.sdk.Record360Activity
|
|
6
7
|
import com.record360.sdk.ui.insets.EdgeToEdgeInitializer
|
|
@@ -9,6 +10,7 @@ import org.json.JSONObject
|
|
|
9
10
|
class SampleRecord360Activity: Record360Activity() {
|
|
10
11
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
11
12
|
super.onCreate(savedInstanceState)
|
|
13
|
+
current = WeakReference(this)
|
|
12
14
|
EdgeToEdgeInitializer.register(application)
|
|
13
15
|
val userId = if (intent.hasExtra(USER_ID_INTENT)) intent.getStringExtra(USER_ID_INTENT) else null
|
|
14
16
|
val userToken = if (intent.hasExtra(USER_TOKEN_INTENT)) intent.getStringExtra(USER_TOKEN_INTENT) else null
|
|
@@ -36,6 +38,11 @@ class SampleRecord360Activity: Record360Activity() {
|
|
|
36
38
|
}
|
|
37
39
|
}
|
|
38
40
|
|
|
41
|
+
override fun onDestroy() {
|
|
42
|
+
if (current?.get() === this) current = null
|
|
43
|
+
super.onDestroy()
|
|
44
|
+
}
|
|
45
|
+
|
|
39
46
|
private fun parseFieldData(json: String?): Map<String, String>? {
|
|
40
47
|
if (json.isNullOrEmpty()) return null
|
|
41
48
|
return try {
|
|
@@ -47,6 +54,8 @@ class SampleRecord360Activity: Record360Activity() {
|
|
|
47
54
|
}
|
|
48
55
|
|
|
49
56
|
companion object {
|
|
57
|
+
/** The host screen the SDK runs on top of; the plugin finishes it when the SDK exits. */
|
|
58
|
+
@Volatile var current: WeakReference<SampleRecord360Activity>? = null
|
|
50
59
|
var REFERENCE_NUMBER_INTENT = "SampleRecord360Activity.REF_NUM_INTENT"
|
|
51
60
|
var DEPARTMENT_INTENT = "SampleRecord360Activity.DEPARTMENT_INTENT"
|
|
52
61
|
var SEQUENCE_INTENT = "SampleRecord360Activity.SEQUENCE_INTENT"
|
package/dist/docs.json
CHANGED
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
},
|
|
45
45
|
{
|
|
46
46
|
"name": "addListener",
|
|
47
|
-
"signature": "(eventName: 'Record360Event', listenerFunc: (data: { type: 'onFailedToAuthenticate' | 'onInspectionCancelled' | 'onInspectionComplete' | 'onInspectionUploadFailed' | 'onInspectionUploadProgress' | 'onInspectionUploaded' | 'onInspectionStarted' | 'onUserAuthenticated'; referenceNumber?: string;
|
|
47
|
+
"signature": "(eventName: 'Record360Event', listenerFunc: (data: { type: 'onFailedToAuthenticate' | 'onInspectionCancelled' | 'onInspectionComplete' | 'onInspectionUploadFailed' | 'onInspectionUploadProgress' | 'onInspectionUploaded' | 'onInspectionUploadDeleted' | 'onInspectionStarted' | 'onUserAuthenticated' | 'onSDKShouldRelaunch' | 'onSDKShouldExit'; referenceNumber?: string; inspectionNonce?: string; percentComplete?: number; error?: string; userId?: string; inspectionJSON?: string; }) => void) => Promise<PluginListenerHandle>",
|
|
48
48
|
"parameters": [
|
|
49
49
|
{
|
|
50
50
|
"name": "eventName",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
{
|
|
55
55
|
"name": "listenerFunc",
|
|
56
56
|
"docs": "",
|
|
57
|
-
"type": "(data: { type: 'onFailedToAuthenticate' | 'onInspectionCancelled' | 'onInspectionComplete' | 'onInspectionUploadFailed' | 'onInspectionUploadProgress' | 'onInspectionUploaded' | 'onInspectionStarted' | 'onUserAuthenticated'
|
|
57
|
+
"type": "(data: { type: 'onFailedToAuthenticate' | 'onInspectionCancelled' | 'onInspectionComplete' | 'onInspectionUploadFailed' | 'onInspectionUploadProgress' | 'onInspectionUploaded' | 'onInspectionUploadDeleted' | 'onInspectionStarted' | 'onUserAuthenticated' | 'onSDKShouldRelaunch' | 'onSDKShouldExit'; referenceNumber?: string | undefined; inspectionNonce?: string | undefined; percentComplete?: number | undefined; error?: string | undefined; userId?: string | undefined; inspectionJSON?: string | undefined; }) => void"
|
|
58
58
|
}
|
|
59
59
|
],
|
|
60
60
|
"returns": "Promise<PluginListenerHandle>",
|
|
@@ -21,14 +21,14 @@ export interface CapacitorRecord360SDKPlugin {
|
|
|
21
21
|
identity?: Record360Identity;
|
|
22
22
|
}): Promise<void>;
|
|
23
23
|
addListener(eventName: 'Record360Event', listenerFunc: (data: {
|
|
24
|
-
type: 'onFailedToAuthenticate' | 'onInspectionCancelled' | 'onInspectionComplete' | 'onInspectionUploadFailed' | 'onInspectionUploadProgress' | 'onInspectionUploaded' | 'onInspectionStarted' | 'onUserAuthenticated';
|
|
24
|
+
type: 'onFailedToAuthenticate' | 'onInspectionCancelled' | 'onInspectionComplete' | 'onInspectionUploadFailed' | 'onInspectionUploadProgress' | 'onInspectionUploaded' | 'onInspectionUploadDeleted' | 'onInspectionStarted' | 'onUserAuthenticated' | 'onSDKShouldRelaunch' | 'onSDKShouldExit';
|
|
25
25
|
referenceNumber?: string;
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
/** Unique per inspection; correlates every event for the same inspection. */
|
|
27
|
+
inspectionNonce?: string;
|
|
28
|
+
/** Fraction uploaded, 0 to 1. */
|
|
28
29
|
percentComplete?: number;
|
|
29
30
|
error?: string;
|
|
30
31
|
userId?: string;
|
|
31
|
-
username?: string;
|
|
32
32
|
inspectionJSON?: string;
|
|
33
33
|
}) => void): Promise<PluginListenerHandle>;
|
|
34
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import type { PluginListenerHandle } from \"@capacitor/core\"\nexport type Record360Identity = R360PasswordIdentity | R360UserTokenIdentity\n\nexport interface R360PasswordIdentity {\n username: string,\n password: string\n}\n\nexport interface R360UserTokenIdentity {\n userId: string,\n userToken: string\n}\n\nexport type Record360FieldData = { [key: string]: unknown }\n\nexport interface CapacitorRecord360SDKPlugin {\n launchRecord360(identity?: Record360Identity): Promise<void>\n\n launchReferenceCapture(options: {\n referenceNumber: string,\n department?: string,\n sequence?: string,\n fieldData?: Record360FieldData,\n identity?: Record360Identity\n }): Promise<void>\n\n addListener(\n eventName: 'Record360Event',\n listenerFunc: (\n data: {
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import type { PluginListenerHandle } from \"@capacitor/core\"\nexport type Record360Identity = R360PasswordIdentity | R360UserTokenIdentity\n\nexport interface R360PasswordIdentity {\n username: string,\n password: string\n}\n\nexport interface R360UserTokenIdentity {\n userId: string,\n userToken: string\n}\n\nexport type Record360FieldData = { [key: string]: unknown }\n\nexport interface CapacitorRecord360SDKPlugin {\n launchRecord360(identity?: Record360Identity): Promise<void>\n\n launchReferenceCapture(options: {\n referenceNumber: string,\n department?: string,\n sequence?: string,\n fieldData?: Record360FieldData,\n identity?: Record360Identity\n }): Promise<void>\n\n addListener(\n eventName: 'Record360Event',\n listenerFunc: (\n data: {\n type: 'onFailedToAuthenticate' | 'onInspectionCancelled' | 'onInspectionComplete' | 'onInspectionUploadFailed' | 'onInspectionUploadProgress' | 'onInspectionUploaded' | 'onInspectionUploadDeleted' | 'onInspectionStarted' | 'onUserAuthenticated' | 'onSDKShouldRelaunch' | 'onSDKShouldExit',\n referenceNumber?: string,\n /** Unique per inspection; correlates every event for the same inspection. */\n inspectionNonce?: string,\n /** Fraction uploaded, 0 to 1. */\n percentComplete?: number,\n error?: string,\n userId?: string,\n inspectionJSON?: string\n }\n ) => void,\n ): Promise<PluginListenerHandle>;\n}\n"]}
|
|
@@ -14,10 +14,11 @@ public class CapacitorRecord360SDKPlugin: CAPPlugin, CAPBridgedPlugin, Record360
|
|
|
14
14
|
public var record360: Record360?
|
|
15
15
|
public var record360ViewController: Record360ViewController?
|
|
16
16
|
public var hostingSDKViewController = false
|
|
17
|
+
private var lastLaunch: (() -> Void)?
|
|
17
18
|
|
|
18
19
|
public override init() {
|
|
19
20
|
super.init()
|
|
20
|
-
self.record360 = Record360(delegate: self, allowUserToExitRecord360: true);
|
|
21
|
+
self.record360 = Record360(delegate: self, allowUserToExitRecord360: true, error: nil);
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
private func applySettings() {
|
|
@@ -90,6 +91,7 @@ public class CapacitorRecord360SDKPlugin: CAPPlugin, CAPBridgedPlugin, Record360
|
|
|
90
91
|
}
|
|
91
92
|
|
|
92
93
|
private func loadR360SDKLogin(referenceNumber: String?, department: String?, sequence: String?, fieldData: JSObject?, presentingVC: UIViewController) {
|
|
94
|
+
lastLaunch = { self.loadR360SDKLogin(referenceNumber: referenceNumber, department: department, sequence: sequence, fieldData: fieldData, presentingVC: presentingVC) }
|
|
93
95
|
DispatchQueue.main.async {
|
|
94
96
|
self.hostSDKViewController {
|
|
95
97
|
let identity = Record360Identity(userName: "", password: nil)
|
|
@@ -104,6 +106,7 @@ public class CapacitorRecord360SDKPlugin: CAPPlugin, CAPBridgedPlugin, Record360
|
|
|
104
106
|
}
|
|
105
107
|
|
|
106
108
|
private func loadR360SDK(identity: Record360Identity, presentingVC: UIViewController) {
|
|
109
|
+
lastLaunch = { self.loadR360SDK(identity: identity, presentingVC: presentingVC) }
|
|
107
110
|
DispatchQueue.main.async {
|
|
108
111
|
self.hostSDKViewController {
|
|
109
112
|
self.record360?.launch(identity)
|
|
@@ -113,6 +116,7 @@ public class CapacitorRecord360SDKPlugin: CAPPlugin, CAPBridgedPlugin, Record360
|
|
|
113
116
|
}
|
|
114
117
|
|
|
115
118
|
private func loadR360SDKForInspection(identity: Record360Identity, referenceNumber: String, department: String?, sequence: String?, fieldData: JSObject?, presentingVC: UIViewController) {
|
|
119
|
+
lastLaunch = { self.loadR360SDKForInspection(identity: identity, referenceNumber: referenceNumber, department: department, sequence: sequence, fieldData: fieldData, presentingVC: presentingVC) }
|
|
116
120
|
DispatchQueue.main.async {
|
|
117
121
|
self.hostSDKViewController {
|
|
118
122
|
self.record360?.launchReferenceCapture(referenceNumber, departmentReference: department, sequenceReference: sequence, fieldData: fieldData, identity: identity)
|
|
@@ -126,60 +130,81 @@ public class CapacitorRecord360SDKPlugin: CAPPlugin, CAPBridgedPlugin, Record360
|
|
|
126
130
|
data["type"] = "onUserAuthenticated"
|
|
127
131
|
data["userId"] = userId
|
|
128
132
|
|
|
129
|
-
|
|
133
|
+
emit(data)
|
|
130
134
|
}
|
|
131
135
|
|
|
132
136
|
public func onFailedAuthentication(_ error: any Error) {
|
|
133
137
|
var data = JSObject()
|
|
134
138
|
data["type"] = "onFailedToAuthenticate"
|
|
135
|
-
|
|
139
|
+
emit(data)
|
|
136
140
|
}
|
|
137
141
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
142
|
+
private func emit(_ data: JSObject) {
|
|
143
|
+
let fields = data.keys.sorted().filter { $0 != "type" && $0 != "inspectionJSON" }
|
|
144
|
+
.map { "\($0)=\(data[$0] ?? "")" }.joined(separator: " ")
|
|
145
|
+
print("Record360Event \(data["type"] ?? "") \(fields)")
|
|
141
146
|
notifyListeners("Record360Event", data: data)
|
|
142
|
-
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
private func inspectionEvent(_ type: String, _ refNum: String, _ nonce: String) -> JSObject {
|
|
150
|
+
var data = JSObject()
|
|
151
|
+
data["type"] = type
|
|
152
|
+
data["referenceNumber"] = refNum
|
|
153
|
+
data["inspectionNonce"] = nonce
|
|
154
|
+
return data
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
public func onInspectionStarted(forReferenceNumber refNum: String, inspectionNonce nonce: String) {
|
|
158
|
+
emit(inspectionEvent("onInspectionStarted", refNum, nonce))
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
public func onInspectionComplete(forReferenceNumber refNum: String, inspectionNonce nonce: String) {
|
|
162
|
+
emit(inspectionEvent("onInspectionComplete", refNum, nonce))
|
|
143
163
|
}
|
|
144
164
|
|
|
145
|
-
public func
|
|
165
|
+
public func onInspectionCancelled(forReferenceNumber refNum: String, inspectionNonce nonce: String) {
|
|
166
|
+
emit(inspectionEvent("onInspectionCancelled", refNum, nonce))
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
public func onSDKShouldExit() {
|
|
146
170
|
var data = JSObject()
|
|
147
|
-
data["type"] = "
|
|
148
|
-
|
|
171
|
+
data["type"] = "onSDKShouldExit"
|
|
172
|
+
emit(data)
|
|
149
173
|
self.dismissSDKViewController(animated: true, completion: {})
|
|
150
174
|
}
|
|
151
|
-
|
|
152
|
-
public func
|
|
153
|
-
|
|
175
|
+
|
|
176
|
+
public func onSDKShouldRelaunch() {
|
|
177
|
+
var data = JSObject()
|
|
178
|
+
data["type"] = "onSDKShouldRelaunch"
|
|
179
|
+
emit(data)
|
|
180
|
+
let relaunch = self.lastLaunch
|
|
181
|
+
self.dismissSDKViewController(animated: true) {
|
|
182
|
+
relaunch?()
|
|
183
|
+
}
|
|
154
184
|
}
|
|
155
185
|
|
|
156
|
-
public func
|
|
157
|
-
|
|
186
|
+
public func onInspectionUploadDeleted(forReferenceNumber refNum: String, inspectionNonce nonce: String) {
|
|
187
|
+
emit(inspectionEvent("onInspectionUploadDeleted", refNum, nonce))
|
|
158
188
|
}
|
|
159
189
|
|
|
160
|
-
public func onInspectionUploaded(forReferenceNumber
|
|
161
|
-
var data =
|
|
190
|
+
public func onInspectionUploaded(forReferenceNumber refNum: String, inspectionNonce nonce: String, inspectionJSON: [AnyHashable : Any]) {
|
|
191
|
+
var data = inspectionEvent("onInspectionUploaded", refNum, nonce)
|
|
162
192
|
if let json = self.dictionaryToJSONString(inspectionJSON) {
|
|
163
193
|
data["inspectionJSON"] = json
|
|
164
194
|
}
|
|
165
|
-
data
|
|
166
|
-
data["referenceNumber"] = referenceNumber
|
|
167
|
-
notifyListeners("Record360Event", data: data)
|
|
195
|
+
emit(data)
|
|
168
196
|
}
|
|
169
197
|
|
|
170
|
-
public func onInspectionUploadFailed(forReferenceNumber
|
|
171
|
-
var data =
|
|
172
|
-
data["
|
|
173
|
-
data
|
|
174
|
-
notifyListeners("Record360Event", data: data)
|
|
198
|
+
public func onInspectionUploadFailed(forReferenceNumber refNum: String, inspectionNonce nonce: String, error: any Error) {
|
|
199
|
+
var data = inspectionEvent("onInspectionUploadFailed", refNum, nonce)
|
|
200
|
+
data["error"] = error.localizedDescription
|
|
201
|
+
emit(data)
|
|
175
202
|
}
|
|
176
203
|
|
|
177
|
-
public func onInspectionUploadProgress(
|
|
178
|
-
var data =
|
|
179
|
-
data["type"] = "onInspectionUploadProgress"
|
|
180
|
-
data["referenceNumber"] = refNum
|
|
204
|
+
public func onInspectionUploadProgress(forReferenceNumber refNum: String, inspectionNonce nonce: String, percentComplete: CGFloat) {
|
|
205
|
+
var data = inspectionEvent("onInspectionUploadProgress", refNum, nonce)
|
|
181
206
|
data["percentComplete"] = Double(percentComplete)
|
|
182
|
-
|
|
207
|
+
emit(data)
|
|
183
208
|
}
|
|
184
209
|
|
|
185
210
|
func dictionaryToJSONString(_ dict: [AnyHashable: Any]) -> String? {
|