@ua/capacitor-airship 1.0.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 +12 -0
- package/UaCapacitorAirship.podspec +18 -0
- package/android/build.gradle +72 -0
- package/android/src/main/AndroidManifest.xml +33 -0
- package/android/src/main/java/com/airship/capacitor/AirshipCapacitorVersion.kt +7 -0
- package/android/src/main/java/com/airship/capacitor/AirshipPlugin.kt +331 -0
- package/android/src/main/java/com/airship/capacitor/CapacitorAutopilot.kt +39 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/esm/AirshipActions.d.ts +18 -0
- package/dist/esm/AirshipActions.js +20 -0
- package/dist/esm/AirshipActions.js.map +1 -0
- package/dist/esm/AirshipAnalytics.d.ts +30 -0
- package/dist/esm/AirshipAnalytics.js +39 -0
- package/dist/esm/AirshipAnalytics.js.map +1 -0
- package/dist/esm/AirshipChannel.d.ts +61 -0
- package/dist/esm/AirshipChannel.js +87 -0
- package/dist/esm/AirshipChannel.js.map +1 -0
- package/dist/esm/AirshipContact.d.ts +48 -0
- package/dist/esm/AirshipContact.js +68 -0
- package/dist/esm/AirshipContact.js.map +1 -0
- package/dist/esm/AirshipFeatureFlagManager.d.ts +24 -0
- package/dist/esm/AirshipFeatureFlagManager.js +28 -0
- package/dist/esm/AirshipFeatureFlagManager.js.map +1 -0
- package/dist/esm/AirshipInApp.d.ts +30 -0
- package/dist/esm/AirshipInApp.js +39 -0
- package/dist/esm/AirshipInApp.js.map +1 -0
- package/dist/esm/AirshipLocale.d.ts +24 -0
- package/dist/esm/AirshipLocale.js +31 -0
- package/dist/esm/AirshipLocale.js.map +1 -0
- package/dist/esm/AirshipMessageCenter.d.ts +77 -0
- package/dist/esm/AirshipMessageCenter.js +99 -0
- package/dist/esm/AirshipMessageCenter.js.map +1 -0
- package/dist/esm/AirshipPlugin.d.ts +31 -0
- package/dist/esm/AirshipPlugin.js +15 -0
- package/dist/esm/AirshipPlugin.js.map +1 -0
- package/dist/esm/AirshipPreferenceCenter.d.ts +38 -0
- package/dist/esm/AirshipPreferenceCenter.js +49 -0
- package/dist/esm/AirshipPreferenceCenter.js.map +1 -0
- package/dist/esm/AirshipPrivacyManager.d.ts +38 -0
- package/dist/esm/AirshipPrivacyManager.js +48 -0
- package/dist/esm/AirshipPrivacyManager.js.map +1 -0
- package/dist/esm/AirshipPush.d.ts +184 -0
- package/dist/esm/AirshipPush.js +232 -0
- package/dist/esm/AirshipPush.js.map +1 -0
- package/dist/esm/AirshipRoot.d.ts +49 -0
- package/dist/esm/AirshipRoot.js +55 -0
- package/dist/esm/AirshipRoot.js.map +1 -0
- package/dist/esm/AttributeEditor.d.ts +54 -0
- package/dist/esm/AttributeEditor.js +76 -0
- package/dist/esm/AttributeEditor.js.map +1 -0
- package/dist/esm/EventType.d.ts +25 -0
- package/dist/esm/EventType.js +14 -0
- package/dist/esm/EventType.js.map +1 -0
- package/dist/esm/ScopedSubscriptionListEditor.d.ts +59 -0
- package/dist/esm/ScopedSubscriptionListEditor.js +62 -0
- package/dist/esm/ScopedSubscriptionListEditor.js.map +1 -0
- package/dist/esm/SubscriptionListEditor.d.ts +50 -0
- package/dist/esm/SubscriptionListEditor.js +56 -0
- package/dist/esm/SubscriptionListEditor.js.map +1 -0
- package/dist/esm/TagEditor.d.ts +46 -0
- package/dist/esm/TagEditor.js +46 -0
- package/dist/esm/TagEditor.js.map +1 -0
- package/dist/esm/TagGroupEditor.d.ts +60 -0
- package/dist/esm/TagGroupEditor.js +60 -0
- package/dist/esm/TagGroupEditor.js.map +1 -0
- package/dist/esm/index.d.ts +20 -0
- package/dist/esm/index.js +25 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/types.d.ts +651 -0
- package/dist/esm/types.js +167 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/plugin.cjs.js +1278 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +1281 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Plugin/AirshipCapacitorAutopilot.swift +94 -0
- package/ios/Plugin/AirshipCapacitorBootstrap.h +8 -0
- package/ios/Plugin/AirshipCapacitorBootstrap.m +24 -0
- package/ios/Plugin/AirshipCapacitorVersion.swift +7 -0
- package/ios/Plugin/AirshipPlugin.h +7 -0
- package/ios/Plugin/AirshipPlugin.m +9 -0
- package/ios/Plugin/AirshipPlugin.swift +557 -0
- package/ios/Plugin/Info.plist +24 -0
- package/package.json +75 -0
|
@@ -0,0 +1,557 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
import AirshipKit
|
|
4
|
+
import AirshipFrameworkProxy
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Please read the Capacitor iOS Plugin Development Guide
|
|
8
|
+
* here: https://capacitorjs.com/docs/plugins/ios
|
|
9
|
+
*/
|
|
10
|
+
@objc(AirshipPlugin)
|
|
11
|
+
public class AirshipPlugin: CAPPlugin {
|
|
12
|
+
|
|
13
|
+
private static let eventNames: [AirshipProxyEventType: String] = [
|
|
14
|
+
.authorizedNotificationSettingsChanged: "ios_authorized_notification_settings_changed",
|
|
15
|
+
.pushTokenReceived: "push_token_received",
|
|
16
|
+
.deepLinkReceived: "deep_link_received",
|
|
17
|
+
.channelCreated: "channel_created",
|
|
18
|
+
.messageCenterUpdated: "message_center_updated",
|
|
19
|
+
.displayMessageCenter: "display_message_center",
|
|
20
|
+
.displayPreferenceCenter: "display_preference_center",
|
|
21
|
+
.notificationResponseReceived: "notification_response_received",
|
|
22
|
+
.pushReceived: "push_received",
|
|
23
|
+
.notificationStatusChanged: "notification_status_changed"
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
@MainActor
|
|
27
|
+
public override func load() {
|
|
28
|
+
AirshipCapacitorAutopilot.shared.onPluginInitialized(
|
|
29
|
+
pluginConfig: self.getConfig()
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
Task {
|
|
33
|
+
for await _ in await AirshipProxyEventEmitter.shared.pendingEventAdded {
|
|
34
|
+
await self.notifyPendingEvents()
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@MainActor
|
|
40
|
+
private func notifyPendingEvents() async {
|
|
41
|
+
for eventType in AirshipProxyEventType.allCases {
|
|
42
|
+
await AirshipProxyEventEmitter.shared.processPendingEvents(type: eventType) { event in
|
|
43
|
+
return sendEvent(event)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@MainActor
|
|
49
|
+
private func sendEvent(_ event: AirshipProxyEvent) -> Bool {
|
|
50
|
+
guard let eventName = Self.eventNames[event.type] else {
|
|
51
|
+
return false
|
|
52
|
+
}
|
|
53
|
+
guard self.hasListeners(eventName) else {
|
|
54
|
+
return false
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
self.notifyListeners(eventName, data: event.body)
|
|
58
|
+
return true
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@objc
|
|
62
|
+
func perform(_ call: CAPPluginCall) {
|
|
63
|
+
guard let method = call.getString("method") else {
|
|
64
|
+
call.reject("Missing method")
|
|
65
|
+
return
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
CAPLog.print("⚡️ To Airship -> ", pluginId, method, call.callbackId as Any)
|
|
69
|
+
|
|
70
|
+
Task {
|
|
71
|
+
do {
|
|
72
|
+
if let result = try await self.handle(method: method, call: call) {
|
|
73
|
+
call.resolve(["value": try AirshipJSON.wrap(result).unWrap() as Any])
|
|
74
|
+
} else {
|
|
75
|
+
call.resolve([:])
|
|
76
|
+
}
|
|
77
|
+
} catch {
|
|
78
|
+
call.reject(error.localizedDescription)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
public override func addListener(_ call: CAPPluginCall) {
|
|
84
|
+
super.addListener(call)
|
|
85
|
+
|
|
86
|
+
Task {
|
|
87
|
+
await notifyPendingEvents()
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
@MainActor
|
|
92
|
+
private func handle(method: String, call: CAPPluginCall) async throws -> Any? {
|
|
93
|
+
|
|
94
|
+
switch method {
|
|
95
|
+
|
|
96
|
+
// Airship
|
|
97
|
+
case "takeOff":
|
|
98
|
+
return try AirshipCapacitorAutopilot.shared.attemptTakeOff(
|
|
99
|
+
json: try call.requireAnyArg()
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
case "isFlying":
|
|
103
|
+
return AirshipProxy.shared.isFlying()
|
|
104
|
+
|
|
105
|
+
// Channel
|
|
106
|
+
case "channel#getChannelId":
|
|
107
|
+
return try AirshipProxy.shared.channel.getChannelId()
|
|
108
|
+
|
|
109
|
+
case "channel#editTags":
|
|
110
|
+
try AirshipProxy.shared.channel.editTags(
|
|
111
|
+
json: try call.requireAnyArg()
|
|
112
|
+
)
|
|
113
|
+
return nil
|
|
114
|
+
|
|
115
|
+
case "channel#getTags":
|
|
116
|
+
return try AirshipProxy.shared.channel.getTags()
|
|
117
|
+
|
|
118
|
+
case "channel#editTagGroups":
|
|
119
|
+
try AirshipProxy.shared.channel.editTagGroups(
|
|
120
|
+
json: try call.requireAnyArg()
|
|
121
|
+
)
|
|
122
|
+
return nil
|
|
123
|
+
|
|
124
|
+
case "channel#editSubscriptionLists":
|
|
125
|
+
try AirshipProxy.shared.channel.editSubscriptionLists(
|
|
126
|
+
json: try call.requireAnyArg()
|
|
127
|
+
)
|
|
128
|
+
return nil
|
|
129
|
+
|
|
130
|
+
case "channel#editAttributes":
|
|
131
|
+
try AirshipProxy.shared.channel.editAttributes(
|
|
132
|
+
json: try call.requireAnyArg()
|
|
133
|
+
)
|
|
134
|
+
return nil
|
|
135
|
+
|
|
136
|
+
case "channel#getSubscriptionLists":
|
|
137
|
+
return try await AirshipProxy.shared.channel.getSubscriptionLists()
|
|
138
|
+
|
|
139
|
+
case "channel#enableChannelCreation":
|
|
140
|
+
try AirshipProxy.shared.channel.enableChannelCreation()
|
|
141
|
+
return nil
|
|
142
|
+
|
|
143
|
+
// Contact
|
|
144
|
+
case "contact#editTagGroups":
|
|
145
|
+
try AirshipProxy.shared.contact.editTagGroups(
|
|
146
|
+
json: try call.requireAnyArg()
|
|
147
|
+
)
|
|
148
|
+
return nil
|
|
149
|
+
|
|
150
|
+
case "contact#editSubscriptionLists":
|
|
151
|
+
try AirshipProxy.shared.contact.editSubscriptionLists(
|
|
152
|
+
json: try call.requireAnyArg()
|
|
153
|
+
)
|
|
154
|
+
return nil
|
|
155
|
+
|
|
156
|
+
case "contact#editAttributes":
|
|
157
|
+
try AirshipProxy.shared.contact.editAttributes(
|
|
158
|
+
json: try call.requireAnyArg()
|
|
159
|
+
)
|
|
160
|
+
return nil
|
|
161
|
+
|
|
162
|
+
case "contact#getSubscriptionLists":
|
|
163
|
+
return try await AirshipProxy.shared.contact.getSubscriptionLists()
|
|
164
|
+
|
|
165
|
+
case "contact#identify":
|
|
166
|
+
try AirshipProxy.shared.contact.identify(
|
|
167
|
+
try call.requireStringArg()
|
|
168
|
+
)
|
|
169
|
+
return nil
|
|
170
|
+
|
|
171
|
+
case "contact#reset":
|
|
172
|
+
try AirshipProxy.shared.contact.reset()
|
|
173
|
+
return nil
|
|
174
|
+
|
|
175
|
+
case "contact#notifyRemoteLogin":
|
|
176
|
+
try AirshipProxy.shared.contact.notifyRemoteLogin()
|
|
177
|
+
return nil
|
|
178
|
+
|
|
179
|
+
case "contact#getNamedUserId":
|
|
180
|
+
return try await AirshipProxy.shared.contact.getNamedUser()
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
// Push
|
|
184
|
+
case "push#getPushToken":
|
|
185
|
+
return try AirshipProxy.shared.push.getRegistrationToken()
|
|
186
|
+
|
|
187
|
+
case "push#setUserNotificationsEnabled":
|
|
188
|
+
try AirshipProxy.shared.push.setUserNotificationsEnabled(
|
|
189
|
+
try call.requireBooleanArg()
|
|
190
|
+
)
|
|
191
|
+
return nil
|
|
192
|
+
|
|
193
|
+
case "push#enableUserNotifications":
|
|
194
|
+
return try await AirshipProxy.shared.push.enableUserPushNotifications()
|
|
195
|
+
|
|
196
|
+
case "push#isUserNotificationsEnabled":
|
|
197
|
+
return try AirshipProxy.shared.push.isUserNotificationsEnabled()
|
|
198
|
+
|
|
199
|
+
case "push#getNotificationStatus":
|
|
200
|
+
return try await AirshipProxy.shared.push.getNotificationStatus()
|
|
201
|
+
|
|
202
|
+
case "push#getActiveNotifications":
|
|
203
|
+
return await AirshipProxy.shared.push.getActiveNotifications()
|
|
204
|
+
|
|
205
|
+
case "push#clearNotification":
|
|
206
|
+
AirshipProxy.shared.push.clearNotification(
|
|
207
|
+
try call.requireStringArg()
|
|
208
|
+
)
|
|
209
|
+
return nil
|
|
210
|
+
|
|
211
|
+
case "push#clearNotifications":
|
|
212
|
+
AirshipProxy.shared.push.clearNotifications()
|
|
213
|
+
return nil
|
|
214
|
+
|
|
215
|
+
case "push#ios#getBadgeNumber":
|
|
216
|
+
return try AirshipProxy.shared.push.getBadgeNumber()
|
|
217
|
+
|
|
218
|
+
case "push#ios#setBadgeNumber":
|
|
219
|
+
try AirshipProxy.shared.push.setBadgeNumber(
|
|
220
|
+
try call.requireIntArg()
|
|
221
|
+
)
|
|
222
|
+
return nil
|
|
223
|
+
|
|
224
|
+
case "push#ios#setAutobadgeEnabled":
|
|
225
|
+
try AirshipProxy.shared.push.setAutobadgeEnabled(
|
|
226
|
+
try call.requireBooleanArg()
|
|
227
|
+
)
|
|
228
|
+
return nil
|
|
229
|
+
|
|
230
|
+
case "push#ios#isAutobadgeEnabled":
|
|
231
|
+
return try AirshipProxy.shared.push.isAutobadgeEnabled()
|
|
232
|
+
|
|
233
|
+
case "push#ios#resetBadgeNumber":
|
|
234
|
+
try AirshipProxy.shared.push.setBadgeNumber(0)
|
|
235
|
+
return nil
|
|
236
|
+
|
|
237
|
+
case "push#ios#setNotificationOptions":
|
|
238
|
+
try AirshipProxy.shared.push.setNotificationOptions(
|
|
239
|
+
names: try call.requireStringArrayArg()
|
|
240
|
+
)
|
|
241
|
+
return nil
|
|
242
|
+
|
|
243
|
+
case "push#ios#setForegroundPresentationOptions":
|
|
244
|
+
try AirshipProxy.shared.push.setForegroundPresentationOptions(
|
|
245
|
+
names: try call.requireStringArrayArg()
|
|
246
|
+
)
|
|
247
|
+
return nil
|
|
248
|
+
|
|
249
|
+
case "push#ios#getAuthorizedNotificationStatus":
|
|
250
|
+
return try AirshipProxy.shared.push.getAuthroizedNotificationStatus()
|
|
251
|
+
|
|
252
|
+
case "push#ios#getAuthorizedNotificationSettings":
|
|
253
|
+
return try AirshipProxy.shared.push.getAuthorizedNotificationSettings()
|
|
254
|
+
|
|
255
|
+
case "push#ios#setQuietTimeEnabled":
|
|
256
|
+
try AirshipProxy.shared.push.setQuietTimeEnabled(
|
|
257
|
+
try call.requireBooleanArg()
|
|
258
|
+
)
|
|
259
|
+
return nil
|
|
260
|
+
|
|
261
|
+
case "push#ios#isQuietTimeEnabled":
|
|
262
|
+
return try AirshipProxy.shared.push.isQuietTimeEnabled()
|
|
263
|
+
|
|
264
|
+
case "push#ios#setQuietTime":
|
|
265
|
+
try AirshipProxy.shared.push.setQuietTime(
|
|
266
|
+
try call.requireCodableArg()
|
|
267
|
+
)
|
|
268
|
+
return nil
|
|
269
|
+
|
|
270
|
+
case "push#ios#getQuietTime":
|
|
271
|
+
return try AirshipProxy.shared.push.getQuietTime()
|
|
272
|
+
|
|
273
|
+
// In-App
|
|
274
|
+
case "inApp#setPaused":
|
|
275
|
+
try AirshipProxy.shared.inApp.setPaused(
|
|
276
|
+
try call.requireBooleanArg()
|
|
277
|
+
)
|
|
278
|
+
return nil
|
|
279
|
+
|
|
280
|
+
case "inApp#isPaused":
|
|
281
|
+
return try AirshipProxy.shared.inApp.isPaused()
|
|
282
|
+
|
|
283
|
+
case "inApp#setDisplayInterval":
|
|
284
|
+
try AirshipProxy.shared.inApp.setDisplayInterval(
|
|
285
|
+
try call.requireIntArg()
|
|
286
|
+
)
|
|
287
|
+
return nil
|
|
288
|
+
|
|
289
|
+
case "inApp#getDisplayInterval":
|
|
290
|
+
return try AirshipProxy.shared.inApp.getDisplayInterval()
|
|
291
|
+
|
|
292
|
+
// Analytics
|
|
293
|
+
case "analytics#trackScreen":
|
|
294
|
+
try AirshipProxy.shared.analytics.trackScreen(
|
|
295
|
+
try? call.requireStringArg()
|
|
296
|
+
)
|
|
297
|
+
return nil
|
|
298
|
+
|
|
299
|
+
case "analytics#addCustomEvent":
|
|
300
|
+
try AirshipProxy.shared.analytics.addEvent(
|
|
301
|
+
call.requireAnyArg()
|
|
302
|
+
)
|
|
303
|
+
return nil
|
|
304
|
+
|
|
305
|
+
case "analytics#associateIdentifier":
|
|
306
|
+
let args = try call.requireStringArrayArg()
|
|
307
|
+
guard args.count == 1 || args.count == 2 else {
|
|
308
|
+
throw AirshipErrors.error("Call requires 1 to 2 strings.")
|
|
309
|
+
}
|
|
310
|
+
try AirshipProxy.shared.analytics.associateIdentifier(
|
|
311
|
+
identifier: args.count == 2 ? args[1] : nil,
|
|
312
|
+
key: args[0]
|
|
313
|
+
)
|
|
314
|
+
return nil
|
|
315
|
+
|
|
316
|
+
// Message Center
|
|
317
|
+
case "messageCenter#getMessages":
|
|
318
|
+
return try? await AirshipProxy.shared.messageCenter.getMessages()
|
|
319
|
+
|
|
320
|
+
case "messageCenter#display":
|
|
321
|
+
try AirshipProxy.shared.messageCenter.display(
|
|
322
|
+
messageID: try? call.requireStringArg()
|
|
323
|
+
)
|
|
324
|
+
return nil
|
|
325
|
+
|
|
326
|
+
case "messageCenter#showMessageView":
|
|
327
|
+
try AirshipProxy.shared.messageCenter.showMessageView(
|
|
328
|
+
messageID: try call.requireStringArg()
|
|
329
|
+
)
|
|
330
|
+
return nil
|
|
331
|
+
|
|
332
|
+
case "messageCenter#dismiss":
|
|
333
|
+
try AirshipProxy.shared.messageCenter.dismiss()
|
|
334
|
+
return nil
|
|
335
|
+
|
|
336
|
+
case "messageCenter#markMessageRead":
|
|
337
|
+
try await AirshipProxy.shared.messageCenter.markMessageRead(
|
|
338
|
+
messageID: call.requireStringArg()
|
|
339
|
+
)
|
|
340
|
+
return nil
|
|
341
|
+
|
|
342
|
+
case "messageCenter#deleteMessage":
|
|
343
|
+
try await AirshipProxy.shared.messageCenter.deleteMessage(
|
|
344
|
+
messageID: call.requireStringArg()
|
|
345
|
+
)
|
|
346
|
+
return nil
|
|
347
|
+
|
|
348
|
+
case "messageCenter#getUnreadMessageCount":
|
|
349
|
+
return try await AirshipProxy.shared.messageCenter.getUnreadCount()
|
|
350
|
+
|
|
351
|
+
case "messageCenter#refreshMessages":
|
|
352
|
+
try await AirshipProxy.shared.messageCenter.refresh()
|
|
353
|
+
return nil
|
|
354
|
+
|
|
355
|
+
case "messageCenter#setAutoLaunchDefaultMessageCenter":
|
|
356
|
+
AirshipProxy.shared.messageCenter.setAutoLaunchDefaultMessageCenter(
|
|
357
|
+
try call.requireBooleanArg()
|
|
358
|
+
)
|
|
359
|
+
return nil
|
|
360
|
+
|
|
361
|
+
// Preference Center
|
|
362
|
+
case "preferenceCenter#display":
|
|
363
|
+
try AirshipProxy.shared.preferenceCenter.displayPreferenceCenter(
|
|
364
|
+
preferenceCenterID: try call.requireStringArg()
|
|
365
|
+
)
|
|
366
|
+
return nil
|
|
367
|
+
|
|
368
|
+
case "preferenceCenter#getConfig":
|
|
369
|
+
return try await AirshipProxy.shared.preferenceCenter.getPreferenceCenterConfig(
|
|
370
|
+
preferenceCenterID: try call.requireStringArg()
|
|
371
|
+
)
|
|
372
|
+
|
|
373
|
+
case "preferenceCenter#setAutoLaunchPreferenceCenter":
|
|
374
|
+
let args = try call.requireArrayArg()
|
|
375
|
+
guard
|
|
376
|
+
args.count == 2,
|
|
377
|
+
let identifier = args[0] as? String,
|
|
378
|
+
let autoLaunch = args[1] as? Bool
|
|
379
|
+
else {
|
|
380
|
+
throw AirshipErrors.error("Call requires [String, Bool]")
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
AirshipProxy.shared.preferenceCenter.setAutoLaunchPreferenceCenter(
|
|
384
|
+
autoLaunch,
|
|
385
|
+
preferenceCenterID: identifier
|
|
386
|
+
)
|
|
387
|
+
return nil
|
|
388
|
+
|
|
389
|
+
// Privacy Manager
|
|
390
|
+
case "privacyManager#setEnabledFeatures":
|
|
391
|
+
try AirshipProxy.shared.privacyManager.setEnabled(
|
|
392
|
+
featureNames: try call.requireStringArrayArg()
|
|
393
|
+
)
|
|
394
|
+
return nil
|
|
395
|
+
|
|
396
|
+
case "privacyManager#getEnabledFeatures":
|
|
397
|
+
return try AirshipProxy.shared.privacyManager.getEnabledNames()
|
|
398
|
+
|
|
399
|
+
case "privacyManager#enableFeatures":
|
|
400
|
+
try AirshipProxy.shared.privacyManager.enable(
|
|
401
|
+
featureNames: try call.requireStringArrayArg()
|
|
402
|
+
)
|
|
403
|
+
return nil
|
|
404
|
+
|
|
405
|
+
case "privacyManager#disableFeatures":
|
|
406
|
+
try AirshipProxy.shared.privacyManager.disable(
|
|
407
|
+
featureNames: try call.requireStringArrayArg()
|
|
408
|
+
)
|
|
409
|
+
return nil
|
|
410
|
+
|
|
411
|
+
case "privacyManager#isFeaturesEnabled":
|
|
412
|
+
return try AirshipProxy.shared.privacyManager.isEnabled(
|
|
413
|
+
featuresNames: try call.requireStringArrayArg()
|
|
414
|
+
)
|
|
415
|
+
|
|
416
|
+
// Locale
|
|
417
|
+
case "locale#setLocaleOverride":
|
|
418
|
+
try AirshipProxy.shared.locale.setCurrentLocale(
|
|
419
|
+
try call.requireStringArg()
|
|
420
|
+
)
|
|
421
|
+
return nil
|
|
422
|
+
|
|
423
|
+
case "locale#clearLocaleOverride":
|
|
424
|
+
try AirshipProxy.shared.locale.clearLocale()
|
|
425
|
+
return nil
|
|
426
|
+
|
|
427
|
+
case "locale#getCurrentLocale":
|
|
428
|
+
return try AirshipProxy.shared.locale.getCurrentLocale()
|
|
429
|
+
|
|
430
|
+
// Actions
|
|
431
|
+
case "actions#run":
|
|
432
|
+
let args = try call.requireArrayArg()
|
|
433
|
+
guard
|
|
434
|
+
args.count == 1 || args.count == 2,
|
|
435
|
+
let actionName = args[0] as? String
|
|
436
|
+
else {
|
|
437
|
+
throw AirshipErrors.error("Call requires [String, Any?]")
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
let arg = try? AirshipJSON.wrap(args[1])
|
|
441
|
+
let result = try await AirshipProxy.shared.action.runAction(
|
|
442
|
+
actionName,
|
|
443
|
+
value: args.count == 2 ? arg : nil
|
|
444
|
+
) as? AirshipJSON
|
|
445
|
+
return result?.unWrap()
|
|
446
|
+
|
|
447
|
+
// Feature Flag
|
|
448
|
+
case "featureFlagManager#flag":
|
|
449
|
+
return try await AirshipProxy.shared.featureFlagManager.flag(
|
|
450
|
+
name: try call.requireStringArg()
|
|
451
|
+
)
|
|
452
|
+
|
|
453
|
+
case "featureFlagManager#trackInteraction":
|
|
454
|
+
try AirshipProxy.shared.featureFlagManager.trackInteraction(
|
|
455
|
+
flag: call.requireCodableArg()
|
|
456
|
+
)
|
|
457
|
+
|
|
458
|
+
return nil
|
|
459
|
+
default:
|
|
460
|
+
throw AirshipErrors.error("Not implemented \(method)")
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
extension CAPPluginCall {
|
|
466
|
+
func requireCodableArg<T: Codable>() throws -> T {
|
|
467
|
+
guard let value = self.getValue("value") else {
|
|
468
|
+
throw AirshipErrors.error("Missing argument")
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
return try AirshipJSON.wrap(value).decode()
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
func requireArrayArg() throws -> [Any] {
|
|
475
|
+
guard let value = self.getArray("value") else {
|
|
476
|
+
throw AirshipErrors.error("Argument must be an array")
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
return value
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
func requireArrayArg<T>(count: UInt, parse: (Any) throws -> T) throws -> [T] {
|
|
483
|
+
guard let value = self.getArray("value"), value.count == count else {
|
|
484
|
+
throw AirshipErrors.error("Invalid argument array")
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
return try value.map { try parse($0) }
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
func requireStringArrayArg() throws -> [String] {
|
|
491
|
+
guard let value = self.getArray("value") as? [String] else {
|
|
492
|
+
throw AirshipErrors.error("Argument must be a string array")
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
return value
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
func requireAnyArg() throws -> Any {
|
|
499
|
+
guard let value = self.getValue("value") else {
|
|
500
|
+
throw AirshipErrors.error("Argument must not be null")
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
return value
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
func requireBooleanArg() throws -> Bool {
|
|
507
|
+
guard let value = self.getBool("value") else {
|
|
508
|
+
throw AirshipErrors.error("Argument must not be a bool")
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
return value
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
func requireStringArg() throws -> String {
|
|
515
|
+
guard let value = self.getString("value") else {
|
|
516
|
+
throw AirshipErrors.error("Argument must not be a string")
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
return value
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
func requireIntArg() throws -> Int {
|
|
523
|
+
let value = try requireAnyArg()
|
|
524
|
+
|
|
525
|
+
if let int = value as? Int {
|
|
526
|
+
return int
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
if let double = value as? Double {
|
|
530
|
+
return Int(double)
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
if let number = value as? NSNumber {
|
|
534
|
+
return number.intValue
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
throw AirshipErrors.error("Argument must be an int")
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
func requireDoubleArg() throws -> Double {
|
|
541
|
+
let value = try requireAnyArg()
|
|
542
|
+
|
|
543
|
+
if let double = value as? Double {
|
|
544
|
+
return double
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
if let int = value as? Int {
|
|
548
|
+
return Double(int)
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
if let number = value as? NSNumber {
|
|
552
|
+
return number.doubleValue
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
throw AirshipErrors.error("Argument must be a double")
|
|
556
|
+
}
|
|
557
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>CFBundleDevelopmentRegion</key>
|
|
6
|
+
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
|
7
|
+
<key>CFBundleExecutable</key>
|
|
8
|
+
<string>$(EXECUTABLE_NAME)</string>
|
|
9
|
+
<key>CFBundleIdentifier</key>
|
|
10
|
+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
|
11
|
+
<key>CFBundleInfoDictionaryVersion</key>
|
|
12
|
+
<string>6.0</string>
|
|
13
|
+
<key>CFBundleName</key>
|
|
14
|
+
<string>$(PRODUCT_NAME)</string>
|
|
15
|
+
<key>CFBundlePackageType</key>
|
|
16
|
+
<string>FMWK</string>
|
|
17
|
+
<key>CFBundleShortVersionString</key>
|
|
18
|
+
<string>1.0</string>
|
|
19
|
+
<key>CFBundleVersion</key>
|
|
20
|
+
<string>$(CURRENT_PROJECT_VERSION)</string>
|
|
21
|
+
<key>NSPrincipalClass</key>
|
|
22
|
+
<string></string>
|
|
23
|
+
</dict>
|
|
24
|
+
</plist>
|
package/package.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ua/capacitor-airship",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Airship capacitor plugin",
|
|
5
|
+
"main": "dist/plugin.cjs.js",
|
|
6
|
+
"module": "dist/esm/index.js",
|
|
7
|
+
"types": "dist/esm/index.d.ts",
|
|
8
|
+
"unpkg": "dist/plugin.js",
|
|
9
|
+
"files": [
|
|
10
|
+
"android/src/main/",
|
|
11
|
+
"android/build.gradle",
|
|
12
|
+
"dist/",
|
|
13
|
+
"ios/Plugin/",
|
|
14
|
+
"UaCapacitorAirship.podspec"
|
|
15
|
+
],
|
|
16
|
+
"author": "Airship",
|
|
17
|
+
"license": "Apache-2.0",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/urbanairship/capacitor-airship.git"
|
|
21
|
+
},
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/urbanairship/capacitor-airship/issues"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"capacitor",
|
|
27
|
+
"plugin",
|
|
28
|
+
"native"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"verify": "npm run build && npm run verify:ios && npm run verify:android",
|
|
32
|
+
"verify:ios": "cd ios && pod install && xcrun xcodebuild -workspace Plugin.xcworkspace -scheme Plugin -destination generic/platform=iOS && cd ..",
|
|
33
|
+
"verify:android": "cd android && ./gradlew clean build && cd ..",
|
|
34
|
+
"lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
|
|
35
|
+
"fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
|
|
36
|
+
"eslint": "eslint . --ext ts",
|
|
37
|
+
"prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
|
|
38
|
+
"build:docs": "typedoc src/index.ts",
|
|
39
|
+
"build": "npm run clean && npm run build:docs && tsc && rollup -c rollup.config.js",
|
|
40
|
+
"clean": "rimraf ./dist",
|
|
41
|
+
"watch": "tsc --watch",
|
|
42
|
+
"prepublishOnly": "npm run build"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@capacitor/android": "^5.0.0",
|
|
46
|
+
"@capacitor/core": "^5.0.0",
|
|
47
|
+
"@capacitor/ios": "^5.0.0",
|
|
48
|
+
"@capacitor/cli": "^5.0.0",
|
|
49
|
+
"@ionic/eslint-config": "^0.3.0",
|
|
50
|
+
"@ionic/prettier-config": "^1.0.1",
|
|
51
|
+
"@ionic/swiftlint-config": "^1.1.2",
|
|
52
|
+
"eslint": "^7.11.0",
|
|
53
|
+
"prettier": "~2.3.0",
|
|
54
|
+
"prettier-plugin-java": "~1.0.2",
|
|
55
|
+
"rimraf": "^3.0.2",
|
|
56
|
+
"rollup": "^2.32.0",
|
|
57
|
+
"typescript": "~4.8.0",
|
|
58
|
+
"typedoc": "0.23.24"
|
|
59
|
+
},
|
|
60
|
+
"peerDependencies": {
|
|
61
|
+
"@capacitor/core": "^5.0.0"
|
|
62
|
+
},
|
|
63
|
+
"prettier": "@ionic/prettier-config",
|
|
64
|
+
"eslintConfig": {
|
|
65
|
+
"extends": "@ionic/eslint-config/recommended"
|
|
66
|
+
},
|
|
67
|
+
"capacitor": {
|
|
68
|
+
"ios": {
|
|
69
|
+
"src": "ios"
|
|
70
|
+
},
|
|
71
|
+
"android": {
|
|
72
|
+
"src": "android"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|