@ua/capacitor-airship 3.1.0 → 4.0.1
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/UaCapacitorAirship.podspec +3 -3
- package/android/build.gradle +6 -6
- package/android/src/main/java/com/airship/capacitor/AirshipCapacitorVersion.kt +1 -1
- package/android/src/main/java/com/airship/capacitor/AirshipPlugin.kt +277 -207
- package/dist/plugin.cjs.js +0 -2
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +0 -2
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/AirshipCapacitorAutopilot.swift +2 -4
- package/ios/Plugin/AirshipCapacitorVersion.swift +1 -1
- package/ios/Plugin/AirshipPlugin.swift +48 -33
- package/ios/Plugin/AirshipPluginLoader.swift +4 -1
- package/package.json +16 -16
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Foundation
|
|
2
|
+
@preconcurrency
|
|
2
3
|
import Capacitor
|
|
3
4
|
|
|
4
5
|
#if canImport(AirshipKit)
|
|
@@ -14,7 +15,7 @@ import AirshipFrameworkProxy
|
|
|
14
15
|
* here: https://capacitorjs.com/docs/plugins/ios
|
|
15
16
|
*/
|
|
16
17
|
@objc(AirshipPlugin)
|
|
17
|
-
public class AirshipPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
18
|
+
public class AirshipPlugin: CAPPlugin, CAPBridgedPlugin, @unchecked Sendable {
|
|
18
19
|
|
|
19
20
|
public let identifier = "AirshipPlugin"
|
|
20
21
|
public let jsName = "Airship"
|
|
@@ -36,15 +37,17 @@ public class AirshipPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
36
37
|
.liveActivitiesUpdated: "ios_live_activities_updated"
|
|
37
38
|
]
|
|
38
39
|
|
|
39
|
-
@MainActor
|
|
40
40
|
public override func load() {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
let config = self.getConfig()
|
|
42
|
+
MainActor.assumeIsolated {
|
|
43
|
+
AirshipCapacitorAutopilot.shared.onPluginInitialized(
|
|
44
|
+
pluginConfig: config
|
|
45
|
+
)
|
|
44
46
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
Task {
|
|
48
|
+
for await _ in AirshipProxyEventEmitter.shared.pendingEventAdded {
|
|
49
|
+
await self.notifyPendingEvents()
|
|
50
|
+
}
|
|
48
51
|
}
|
|
49
52
|
}
|
|
50
53
|
}
|
|
@@ -52,22 +55,26 @@ public class AirshipPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
52
55
|
@MainActor
|
|
53
56
|
private func notifyPendingEvents() async {
|
|
54
57
|
for eventType in AirshipProxyEventType.allCases {
|
|
55
|
-
|
|
58
|
+
AirshipProxyEventEmitter.shared.processPendingEvents(type: eventType) { event in
|
|
56
59
|
return sendEvent(event)
|
|
57
60
|
}
|
|
58
61
|
}
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
@MainActor
|
|
62
|
-
private func sendEvent(_ event: AirshipProxyEvent) -> Bool {
|
|
65
|
+
private func sendEvent(_ event: any AirshipProxyEvent) -> Bool {
|
|
63
66
|
guard let eventName = Self.eventNames[event.type] else {
|
|
64
67
|
return false
|
|
65
68
|
}
|
|
66
69
|
guard self.hasListeners(eventName) else {
|
|
67
70
|
return false
|
|
68
71
|
}
|
|
72
|
+
do {
|
|
73
|
+
self.notifyListeners(eventName, data: try event.body.unwrapped())
|
|
74
|
+
} catch {
|
|
75
|
+
AirshipLogger.error("Failed to send event: \(event) error: \(error)")
|
|
76
|
+
}
|
|
69
77
|
|
|
70
|
-
self.notifyListeners(eventName, data: event.body)
|
|
71
78
|
return true
|
|
72
79
|
}
|
|
73
80
|
|
|
@@ -80,7 +87,7 @@ public class AirshipPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
80
87
|
|
|
81
88
|
CAPLog.print("⚡️ To Airship -> ", pluginId, method, call.callbackId as Any)
|
|
82
89
|
|
|
83
|
-
Task {
|
|
90
|
+
Task { @MainActor in
|
|
84
91
|
do {
|
|
85
92
|
if let result = try await self.handle(method: method, call: call) {
|
|
86
93
|
call.resolve(["value": try AirshipJSON.wrap(result).unWrap() as Any])
|
|
@@ -102,7 +109,7 @@ public class AirshipPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
102
109
|
}
|
|
103
110
|
|
|
104
111
|
@MainActor
|
|
105
|
-
private func handle(method: String, call: CAPPluginCall) async throws ->
|
|
112
|
+
private func handle(method: String, call: CAPPluginCall) async throws -> (any Sendable)? {
|
|
106
113
|
|
|
107
114
|
switch method {
|
|
108
115
|
|
|
@@ -117,20 +124,20 @@ public class AirshipPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
117
124
|
|
|
118
125
|
// Channel
|
|
119
126
|
case "channel#getChannelId":
|
|
120
|
-
return try AirshipProxy.shared.channel.
|
|
127
|
+
return try AirshipProxy.shared.channel.channelID
|
|
121
128
|
|
|
122
129
|
case "channel#editTags":
|
|
123
130
|
try AirshipProxy.shared.channel.editTags(
|
|
124
|
-
|
|
131
|
+
operations: try call.requireCodableArg()
|
|
125
132
|
)
|
|
126
133
|
return nil
|
|
127
134
|
|
|
128
135
|
case "channel#getTags":
|
|
129
|
-
return try AirshipProxy.shared.channel.
|
|
136
|
+
return try AirshipProxy.shared.channel.tags
|
|
130
137
|
|
|
131
138
|
case "channel#editTagGroups":
|
|
132
139
|
try AirshipProxy.shared.channel.editTagGroups(
|
|
133
|
-
|
|
140
|
+
operations: try call.requireCodableArg()
|
|
134
141
|
)
|
|
135
142
|
return nil
|
|
136
143
|
|
|
@@ -142,12 +149,12 @@ public class AirshipPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
142
149
|
|
|
143
150
|
case "channel#editAttributes":
|
|
144
151
|
try AirshipProxy.shared.channel.editAttributes(
|
|
145
|
-
|
|
152
|
+
operations: try call.requireCodableArg()
|
|
146
153
|
)
|
|
147
154
|
return nil
|
|
148
155
|
|
|
149
156
|
case "channel#getSubscriptionLists":
|
|
150
|
-
return try await AirshipProxy.shared.channel.
|
|
157
|
+
return try await AirshipProxy.shared.channel.fetchSubscriptionLists()
|
|
151
158
|
|
|
152
159
|
case "channel#enableChannelCreation":
|
|
153
160
|
try AirshipProxy.shared.channel.enableChannelCreation()
|
|
@@ -156,19 +163,19 @@ public class AirshipPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
156
163
|
// Contact
|
|
157
164
|
case "contact#editTagGroups":
|
|
158
165
|
try AirshipProxy.shared.contact.editTagGroups(
|
|
159
|
-
|
|
166
|
+
operations: try call.requireCodableArg()
|
|
160
167
|
)
|
|
161
168
|
return nil
|
|
162
169
|
|
|
163
170
|
case "contact#editSubscriptionLists":
|
|
164
171
|
try AirshipProxy.shared.contact.editSubscriptionLists(
|
|
165
|
-
|
|
172
|
+
operations: try call.requireCodableArg()
|
|
166
173
|
)
|
|
167
174
|
return nil
|
|
168
175
|
|
|
169
176
|
case "contact#editAttributes":
|
|
170
177
|
try AirshipProxy.shared.contact.editAttributes(
|
|
171
|
-
|
|
178
|
+
operations: try call.requireCodableArg()
|
|
172
179
|
)
|
|
173
180
|
return nil
|
|
174
181
|
|
|
@@ -190,7 +197,7 @@ public class AirshipPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
190
197
|
return nil
|
|
191
198
|
|
|
192
199
|
case "contact#getNamedUserId":
|
|
193
|
-
return try await AirshipProxy.shared.contact.
|
|
200
|
+
return try await AirshipProxy.shared.contact.namedUserID
|
|
194
201
|
|
|
195
202
|
|
|
196
203
|
// Push
|
|
@@ -212,10 +219,10 @@ public class AirshipPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
212
219
|
return try AirshipProxy.shared.push.isUserNotificationsEnabled()
|
|
213
220
|
|
|
214
221
|
case "push#getNotificationStatus":
|
|
215
|
-
return try await AirshipProxy.shared.push.
|
|
222
|
+
return try await AirshipProxy.shared.push.notificationStatus
|
|
216
223
|
|
|
217
224
|
case "push#getActiveNotifications":
|
|
218
|
-
return await AirshipProxy.shared.push.getActiveNotifications()
|
|
225
|
+
return try await AirshipProxy.shared.push.getActiveNotifications()
|
|
219
226
|
|
|
220
227
|
case "push#clearNotification":
|
|
221
228
|
AirshipProxy.shared.push.clearNotification(
|
|
@@ -283,7 +290,7 @@ public class AirshipPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
283
290
|
return nil
|
|
284
291
|
|
|
285
292
|
case "push#ios#getQuietTime":
|
|
286
|
-
return try AirshipProxy.shared.push.getQuietTime()
|
|
293
|
+
return try AirshipJSON.wrap(try AirshipProxy.shared.push.getQuietTime())
|
|
287
294
|
|
|
288
295
|
// In-App
|
|
289
296
|
case "inApp#setPaused":
|
|
@@ -297,7 +304,7 @@ public class AirshipPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
297
304
|
|
|
298
305
|
case "inApp#setDisplayInterval":
|
|
299
306
|
try AirshipProxy.shared.inApp.setDisplayInterval(
|
|
300
|
-
try call.requireIntArg()
|
|
307
|
+
milliseconds: try call.requireIntArg()
|
|
301
308
|
)
|
|
302
309
|
return nil
|
|
303
310
|
|
|
@@ -330,7 +337,7 @@ public class AirshipPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
330
337
|
|
|
331
338
|
// Message Center
|
|
332
339
|
case "messageCenter#getMessages":
|
|
333
|
-
return try
|
|
340
|
+
return try await AirshipProxy.shared.messageCenter.messages
|
|
334
341
|
|
|
335
342
|
case "messageCenter#display":
|
|
336
343
|
try AirshipProxy.shared.messageCenter.display(
|
|
@@ -367,7 +374,7 @@ public class AirshipPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
367
374
|
return nil
|
|
368
375
|
|
|
369
376
|
case "messageCenter#getUnreadCount":
|
|
370
|
-
return try await AirshipProxy.shared.messageCenter.
|
|
377
|
+
return try await AirshipProxy.shared.messageCenter.unreadCount
|
|
371
378
|
|
|
372
379
|
case "messageCenter#refreshMessages":
|
|
373
380
|
try await AirshipProxy.shared.messageCenter.refresh()
|
|
@@ -446,7 +453,7 @@ public class AirshipPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
446
453
|
return nil
|
|
447
454
|
|
|
448
455
|
case "locale#getCurrentLocale":
|
|
449
|
-
return try AirshipProxy.shared.locale.
|
|
456
|
+
return try AirshipProxy.shared.locale.currentLocale
|
|
450
457
|
|
|
451
458
|
// Actions
|
|
452
459
|
case "actions#run":
|
|
@@ -459,11 +466,10 @@ public class AirshipPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
459
466
|
}
|
|
460
467
|
|
|
461
468
|
let arg = try? AirshipJSON.wrap(args[1])
|
|
462
|
-
|
|
469
|
+
return try await AirshipProxy.shared.action.runAction(
|
|
463
470
|
actionName,
|
|
464
471
|
value: args.count == 2 ? arg : nil
|
|
465
|
-
)
|
|
466
|
-
return result?.unWrap()
|
|
472
|
+
)
|
|
467
473
|
|
|
468
474
|
// Feature Flag
|
|
469
475
|
case "featureFlagManager#flag":
|
|
@@ -631,3 +637,12 @@ extension CAPPluginCall {
|
|
|
631
637
|
throw AirshipErrors.error("Argument must be a double")
|
|
632
638
|
}
|
|
633
639
|
}
|
|
640
|
+
|
|
641
|
+
fileprivate extension Encodable {
|
|
642
|
+
func unwrapped<T>() throws -> T {
|
|
643
|
+
guard let value = try AirshipJSON.wrap(self).unWrap() as? T else {
|
|
644
|
+
throw AirshipErrors.error("Failed to unwrap codable")
|
|
645
|
+
}
|
|
646
|
+
return value
|
|
647
|
+
}
|
|
648
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ua/capacitor-airship",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "Airship capacitor plugin",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -35,31 +35,31 @@
|
|
|
35
35
|
"lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
|
|
36
36
|
"fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
|
|
37
37
|
"eslint": "eslint . --ext ts",
|
|
38
|
-
"prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
|
|
38
|
+
"prettier": "prettier \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java",
|
|
39
39
|
"build:docs": "typedoc src/index.ts",
|
|
40
|
-
"build": "npm run clean && npm run build:docs && tsc && rollup -c rollup.config.
|
|
40
|
+
"build": "npm run clean && npm run build:docs && tsc && rollup -c rollup.config.mjs",
|
|
41
41
|
"clean": "rimraf ./dist",
|
|
42
42
|
"watch": "tsc --watch",
|
|
43
43
|
"prepublishOnly": "npm run build"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@capacitor/android": "^
|
|
47
|
-
"@capacitor/core": "^
|
|
48
|
-
"@capacitor/ios": "^
|
|
49
|
-
"@capacitor/cli": "^
|
|
50
|
-
"@ionic/eslint-config": "^0.
|
|
51
|
-
"@ionic/prettier-config": "^
|
|
52
|
-
"@ionic/swiftlint-config": "^
|
|
53
|
-
"eslint": "^
|
|
54
|
-
"prettier": "
|
|
55
|
-
"prettier-plugin-java": "
|
|
56
|
-
"rimraf": "^
|
|
57
|
-
"rollup": "^
|
|
46
|
+
"@capacitor/android": "^7.0.0",
|
|
47
|
+
"@capacitor/core": "^7.0.0",
|
|
48
|
+
"@capacitor/ios": "^7.0.0",
|
|
49
|
+
"@capacitor/cli": "^7.0.0",
|
|
50
|
+
"@ionic/eslint-config": "^0.4.0",
|
|
51
|
+
"@ionic/prettier-config": "^4.0.0",
|
|
52
|
+
"@ionic/swiftlint-config": "^2.0.0",
|
|
53
|
+
"eslint": "^8.57.0",
|
|
54
|
+
"prettier": "^3.4.2",
|
|
55
|
+
"prettier-plugin-java": "^2.6.6",
|
|
56
|
+
"rimraf": "^6.0.1",
|
|
57
|
+
"rollup": "^4.30.1",
|
|
58
58
|
"typescript": "~4.8.0",
|
|
59
59
|
"typedoc": "0.23.24"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
|
-
"@capacitor/core": "
|
|
62
|
+
"@capacitor/core": ">=7.0.0"
|
|
63
63
|
},
|
|
64
64
|
"prettier": "@ionic/prettier-config",
|
|
65
65
|
"eslintConfig": {
|