indigitall-capacitor-plugin 0.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.
Files changed (97) hide show
  1. package/IndigitallCapacitorPlugin.podspec +18 -0
  2. package/README.md +171 -0
  3. package/android/build.gradle +60 -0
  4. package/android/src/main/AndroidManifest.xml +47 -0
  5. package/android/src/main/java/com/indigitall/capacitor/IndigitallCpPlugin.java +263 -0
  6. package/android/src/main/java/com/indigitall/capacitor/IndigitallCustomerPlugin.java +143 -0
  7. package/android/src/main/java/com/indigitall/capacitor/IndigitallInAppPlugin.java +159 -0
  8. package/android/src/main/java/com/indigitall/capacitor/IndigitallInboxPlugin.java +150 -0
  9. package/android/src/main/java/com/indigitall/capacitor/implementations/CustomerCp.java +91 -0
  10. package/android/src/main/java/com/indigitall/capacitor/implementations/InAppCp.java +74 -0
  11. package/android/src/main/java/com/indigitall/capacitor/implementations/InboxCp.java +118 -0
  12. package/android/src/main/java/com/indigitall/capacitor/implementations/IndigitallCp.java +130 -0
  13. package/android/src/main/java/com/indigitall/capacitor/utils/IndigitallParse.java +480 -0
  14. package/android/src/main/res/.gitkeep +0 -0
  15. package/dist/docs.json +155 -0
  16. package/dist/esm/Customer.d.ts +4 -0
  17. package/dist/esm/Customer.js +61 -0
  18. package/dist/esm/Customer.js.map +1 -0
  19. package/dist/esm/InApp.d.ts +3 -0
  20. package/dist/esm/InApp.js +187 -0
  21. package/dist/esm/InApp.js.map +1 -0
  22. package/dist/esm/Inbox.d.ts +4 -0
  23. package/dist/esm/Inbox.js +61 -0
  24. package/dist/esm/Inbox.js.map +1 -0
  25. package/dist/esm/Push.d.ts +3 -0
  26. package/dist/esm/Push.js +110 -0
  27. package/dist/esm/Push.js.map +1 -0
  28. package/dist/esm/callbacks/callbacksType.d.ts +20 -0
  29. package/dist/esm/callbacks/callbacksType.js +2 -0
  30. package/dist/esm/callbacks/callbacksType.js.map +1 -0
  31. package/dist/esm/definitions/customerDefinitions.d.ts +34 -0
  32. package/dist/esm/definitions/customerDefinitions.js +2 -0
  33. package/dist/esm/definitions/customerDefinitions.js.map +1 -0
  34. package/dist/esm/definitions/inAppDefinitions.d.ts +35 -0
  35. package/dist/esm/definitions/inAppDefinitions.js +2 -0
  36. package/dist/esm/definitions/inAppDefinitions.js.map +1 -0
  37. package/dist/esm/definitions/inboxDefinitions.d.ts +30 -0
  38. package/dist/esm/definitions/inboxDefinitions.js +2 -0
  39. package/dist/esm/definitions/inboxDefinitions.js.map +1 -0
  40. package/dist/esm/definitions/pushDefinitions.d.ts +38 -0
  41. package/dist/esm/definitions/pushDefinitions.js +2 -0
  42. package/dist/esm/definitions/pushDefinitions.js.map +1 -0
  43. package/dist/esm/index.d.ts +4 -0
  44. package/dist/esm/index.js +5 -0
  45. package/dist/esm/index.js.map +1 -0
  46. package/dist/esm/models/InCustomer.d.ts +16 -0
  47. package/dist/esm/models/InCustomer.js +8 -0
  48. package/dist/esm/models/InCustomer.js.map +1 -0
  49. package/dist/esm/models/InDevice.d.ts +31 -0
  50. package/dist/esm/models/InDevice.js +2 -0
  51. package/dist/esm/models/InDevice.js.map +1 -0
  52. package/dist/esm/models/InInApp.d.ts +31 -0
  53. package/dist/esm/models/InInApp.js +2 -0
  54. package/dist/esm/models/InInApp.js.map +1 -0
  55. package/dist/esm/models/InInbox.d.ts +31 -0
  56. package/dist/esm/models/InInbox.js +8 -0
  57. package/dist/esm/models/InInbox.js.map +1 -0
  58. package/dist/esm/models/InPush.d.ts +22 -0
  59. package/dist/esm/models/InPush.js +2 -0
  60. package/dist/esm/models/InPush.js.map +1 -0
  61. package/dist/esm/params/customerParams.d.ts +11 -0
  62. package/dist/esm/params/customerParams.js +3 -0
  63. package/dist/esm/params/customerParams.js.map +1 -0
  64. package/dist/esm/params/inAppParams.d.ts +17 -0
  65. package/dist/esm/params/inAppParams.js +3 -0
  66. package/dist/esm/params/inAppParams.js.map +1 -0
  67. package/dist/esm/params/inboxParams.d.ts +15 -0
  68. package/dist/esm/params/inboxParams.js +3 -0
  69. package/dist/esm/params/inboxParams.js.map +1 -0
  70. package/dist/esm/params/pushParams.d.ts +22 -0
  71. package/dist/esm/params/pushParams.js +2 -0
  72. package/dist/esm/params/pushParams.js.map +1 -0
  73. package/dist/plugin.cjs.js +434 -0
  74. package/dist/plugin.cjs.js.map +1 -0
  75. package/dist/plugin.js +437 -0
  76. package/dist/plugin.js.map +1 -0
  77. package/ios/Plugin/IndigitallCpPlugin.swift +152 -0
  78. package/ios/Plugin/IndigitallCustomerPlugin.swift +76 -0
  79. package/ios/Plugin/IndigitallInAppPlugin.swift +54 -0
  80. package/ios/Plugin/IndigitallInboxPlugin.swift +81 -0
  81. package/ios/Plugin/Info.plist +24 -0
  82. package/ios/Plugin/handlers/IndigitallNotificationHandler.swift +38 -0
  83. package/ios/Plugin/implementations/CustomerCp.swift +56 -0
  84. package/ios/Plugin/implementations/InAppCp.swift +88 -0
  85. package/ios/Plugin/implementations/InboxCp.swift +78 -0
  86. package/ios/Plugin/implementations/IndigitallCp.swift +122 -0
  87. package/ios/Plugin/interfaces/IndigitallCpPlugin.h +10 -0
  88. package/ios/Plugin/interfaces/IndigitallCpPlugin.m +19 -0
  89. package/ios/Plugin/interfaces/IndigitallCustomerPlugin.h +10 -0
  90. package/ios/Plugin/interfaces/IndigitallCustomerPlugin.m +16 -0
  91. package/ios/Plugin/interfaces/IndigitallInAppPlugin.h +10 -0
  92. package/ios/Plugin/interfaces/IndigitallInAppPlugin.m +13 -0
  93. package/ios/Plugin/interfaces/IndigitallInboxPlugin.h +10 -0
  94. package/ios/Plugin/interfaces/IndigitallInboxPlugin.m +13 -0
  95. package/ios/Plugin/utils/IndigitallParse.h +27 -0
  96. package/ios/Plugin/utils/IndigitallParse.m +351 -0
  97. package/package.json +79 -0
@@ -0,0 +1,76 @@
1
+ import Foundation
2
+ import Capacitor
3
+ import Indigitall
4
+
5
+ @objc(IndigitallCustomerPlugin)
6
+ public class IndigitallCustomerPlugin: CAPPlugin {
7
+
8
+ private let CUSTOMER = "customer"
9
+ private let CUSTOMER_FIELD = "customerField"
10
+ private let FIELD_NAMES_LIST = "fieldNamesList"
11
+ private let CUSTOMER_FIELDS = "customerFields"
12
+ private let LINK = "link"
13
+ private let UNLINK = "unlink"
14
+
15
+ private let customerCp = CustomerCp()
16
+
17
+ @objc func getCustomer(_ call: CAPPluginCall) {
18
+ customerCp.getCustomer { customer in
19
+ call.resolve([self.CUSTOMER: IndigitallParse.json(from: customer)])
20
+ } onError: { error in
21
+ call.reject(error.message)
22
+ }
23
+ }
24
+
25
+ @objc func getCustomerInformation(_ call: CAPPluginCall) {
26
+ if let params = call.getArray(self.FIELD_NAMES_LIST) as? [String] {
27
+ customerCp.getCustomerInformation(params: params) { customerFields in
28
+ call.resolve([self.CUSTOMER_FIELD: IndigitallParse.json(from: customerFields)])
29
+ } onError: { error in
30
+ call.reject(error.message)
31
+ }
32
+ }
33
+ }
34
+
35
+ @objc func assignOrUpdateValueToCustomerFields(_ call: CAPPluginCall) {
36
+ if let params = call.getObject(self.CUSTOMER_FIELDS) {
37
+ customerCp.assignOrUpdateValueToCustomerFields(params: params) { customer in
38
+ call.resolve([self.CUSTOMER: IndigitallParse.json(from: customer)])
39
+ } onError: { error in
40
+ call.reject(error.message)
41
+ }
42
+ }
43
+ }
44
+
45
+ @objc func deleteValuesFromCustomerFields(_ call: CAPPluginCall) {
46
+ if let params = call.getArray(self.FIELD_NAMES_LIST) as? [String] {
47
+ customerCp.deleteValuesFromCustomerFields(params: params) { customer in
48
+ call.resolve([self.CUSTOMER: IndigitallParse.json(from: customer)])
49
+ } onError: { error in
50
+ call.reject(error.message)
51
+ }
52
+ }
53
+ }
54
+
55
+ @objc func link(_ call: CAPPluginCall) {
56
+ if let params = call.getObject(self.LINK) {
57
+ customerCp.link(params: params) {
58
+ call.resolve()
59
+ } onError: { error in
60
+ call.reject(error.message)
61
+ }
62
+
63
+ }
64
+ }
65
+
66
+ @objc func unlink(_ call: CAPPluginCall) {
67
+ if let params = call.getObject(self.UNLINK) {
68
+ customerCp.unlink(params: params) {
69
+ call.resolve()
70
+ } onError: { error in
71
+ call.reject(error.message)
72
+ }
73
+ }
74
+ }
75
+
76
+ }
@@ -0,0 +1,54 @@
1
+ import Foundation
2
+ import Capacitor
3
+ import Indigitall
4
+
5
+ @objc(IndigitallInAppPlugin)
6
+ public class IndigitallInAppPlugin: CAPPlugin {
7
+
8
+ private let IN_APP = "inApp"
9
+ private let IN_APP_ID = "inAppSchemaCode"
10
+
11
+ private let inAppCp = InAppCp()
12
+
13
+ @objc func inAppGet(_ call: CAPPluginCall) {
14
+ if let params = call.getString(IN_APP_ID) {
15
+ inAppCp.inAppGet(params) { myContent, inApp in
16
+ call.resolve([self.IN_APP: IndigitallParse.jsonFrom(inApp)])
17
+ } onError: {error in
18
+ call.reject(error.message)
19
+ }
20
+ }
21
+ }
22
+
23
+ @objc func inAppWasShown(_ call: CAPPluginCall) {
24
+ let params = (call.getObject(IN_APP) ?? [:]) as Dictionary<String, Any>
25
+ inAppCp.inAppWasShown(params) {
26
+ call.resolve()
27
+ } onError: { error in
28
+ let json = "{ \"errorCode\":\(error.errorCode.rawValue), \"message\": \"\(error.message)\" }" as String;
29
+ call.reject(json)
30
+ }
31
+ }
32
+
33
+ @objc func addNewInAppClick(_ call: CAPPluginCall) {
34
+ let params = (call.getObject(IN_APP) ?? [:]) as Dictionary<String, Any>
35
+ inAppCp.addNewInAppClick(params)
36
+ call.resolve()
37
+ }
38
+
39
+ @objc func addNewInAppToDismissForever(_ call: CAPPluginCall) {
40
+ let params = (call.getObject(IN_APP) ?? [:]) as Dictionary<String, Any>
41
+ inAppCp.addNewInAppToDismissForever(params)
42
+ call.resolve()
43
+ }
44
+
45
+ @objc func showPopUp(_ call: CAPPluginCall) {
46
+ let params = (call.getObject(IN_APP) ?? [:]) as Dictionary<String, Any>
47
+ inAppCp.showPopUp(params) { action in
48
+ call.resolve(["action":action])
49
+ } onError: { error in
50
+ call.reject(error.message)
51
+ }
52
+
53
+ }
54
+ }
@@ -0,0 +1,81 @@
1
+ import Foundation
2
+ import Capacitor
3
+ import Indigitall
4
+
5
+ @objc(IndigitallInboxPlugin)
6
+ public class IndigitallInboxPlugin: CAPPlugin {
7
+
8
+ private let COUNTERS = "counters"
9
+ private let INBOX_NOTIFICATION = "inboxNotification"
10
+ private let INBOX = "inbox"
11
+ private let SENDING_ID = "sendingId"
12
+ private let NOTIFICATIONS = "notifications"
13
+ private let NOTIFICATION = "notification"
14
+ private let AUTH = "auth"
15
+
16
+ private let indigitallInboxCp = InboxCp()
17
+
18
+ @objc func getMessageCount(_ call: CAPPluginCall) {
19
+ let auth = call.getObject(AUTH)
20
+ indigitallInboxCp.auth = auth
21
+ indigitallInboxCp.getMessageCount { counters in
22
+ call.resolve([self.COUNTERS: IndigitallParse.json(fromMessagesCounter: counters)])
23
+ } onError: { error in
24
+ call.reject(error.message)
25
+ }
26
+ }
27
+
28
+ @objc func getInbox(_ call: CAPPluginCall) {
29
+ let auth = call.getObject(AUTH)
30
+ indigitallInboxCp.auth = auth
31
+ indigitallInboxCp.getInbox { inbox in
32
+ call.resolve([self.INBOX: IndigitallParse.json(from: inbox, newNotifications: nil)])
33
+ } onError: { error in
34
+ call.reject(error.message)
35
+ }
36
+ }
37
+
38
+ @objc func getNextPage(_ call: CAPPluginCall) {
39
+ indigitallInboxCp.getNextPage { inbox, notifications in
40
+ call.resolve([self.INBOX: IndigitallParse.json(from: inbox, newNotifications: notifications)])
41
+ } onError: { error in
42
+ call.reject(error.message)
43
+ }
44
+ }
45
+
46
+ @objc func massiveEditNotificationsWithSendingIdsList(_ call: CAPPluginCall) {
47
+ if let params = call.getObject(NOTIFICATIONS) {
48
+ indigitallInboxCp.massiveEditNotificationsWithSendingIdsList(params) {
49
+ call.resolve()
50
+ } onError: { error in
51
+ call.reject(error.message)
52
+ }
53
+ }
54
+ }
55
+
56
+ @objc func getInfoFromNotificationWithSendingId(_ call: CAPPluginCall) {
57
+ if let sendingId = call.getInt(SENDING_ID) {
58
+ let number = NSNumber.init(value: sendingId)
59
+ indigitallInboxCp.getInfoFromNotificationWithSendingId(number) { notification in
60
+ var array = [INInboxNotification]()
61
+ array.append(notification)
62
+ call.resolve([self.INBOX_NOTIFICATION: IndigitallParse.jsonArray(fromInboxNotification: array)])
63
+ } onError: { error in
64
+ call.reject(error.message)
65
+ }
66
+ }
67
+ }
68
+
69
+ @objc func modifyStatusFromNotificationWithSendingId(_ call: CAPPluginCall) {
70
+ if let params = call.getObject(NOTIFICATION) {
71
+ indigitallInboxCp.modifyStatusFromNotificationWithSendingId(params) { notification in
72
+ var array = [INInboxNotification]()
73
+ array.append(notification)
74
+ call.resolve([self.INBOX_NOTIFICATION: IndigitallParse.jsonArray(fromInboxNotification: array)])
75
+ } onError: { error in
76
+ call.reject(error.message)
77
+ }
78
+ }
79
+ }
80
+
81
+ }
@@ -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>
@@ -0,0 +1,38 @@
1
+ import Capacitor
2
+ import UserNotifications
3
+ import Foundation
4
+ import Indigitall
5
+
6
+ public class IndigitallNotificationHandler: NSObject, NotificationHandlerProtocol {
7
+
8
+
9
+ public func willPresent(notification: UNNotification) -> UNNotificationPresentationOptions {
10
+ return Indigitall.willPresentNotification()
11
+ }
12
+
13
+ public func didReceive(response: UNNotificationResponse) {
14
+ Indigitall.handle(with: response) { push, pushAction in
15
+ UserDefaults.standard.set(response.notification.request.content.userInfo["data"], forKey: "IndigitallHandleWithNotificationPush")
16
+ DispatchQueue.main.async {
17
+ NotificationCenter.default.post(name: NSNotification.Name("IndigitallHandleWithNotificationPush"), object: response.notification.request.content.userInfo["data"])
18
+ }
19
+ }
20
+ }
21
+
22
+ @objc public func didRegisterForRemoteNotificationsWithDeviceToken(notification: NSNotification) {
23
+ if let deviceToken = notification.object as? Data {
24
+ Indigitall.setDeviceToken(deviceToken) { (device) in
25
+ print("onNewUserRegistered DEVICE: \(String(describing: device.deviceID) )")
26
+ }
27
+ }
28
+ }
29
+
30
+ @objc public func didFailToRegisterForRemoteNotificationsWithError(notification: NSNotification) {
31
+ guard let error = notification.object as? Error else {
32
+ return
33
+ }
34
+ print("APNs registration failed: \(error)")
35
+
36
+ }
37
+
38
+ }
@@ -0,0 +1,56 @@
1
+ import Foundation
2
+ import Indigitall
3
+ import Capacitor
4
+
5
+ @objc public class CustomerCp: NSObject {
6
+
7
+ @objc public func getCustomer(onSuccess: @escaping (INCustomer) -> Void, onError: @escaping (INError) -> Void ) {
8
+ DispatchQueue.main.async(execute: {
9
+ CustomerIndigitall.getCustomerWithSuccess(onSuccess, failed: onError)
10
+ })
11
+ }
12
+
13
+ @objc public func getCustomerInformation(params: [String], onSuccess: @escaping ([INCustomerField]) -> Void, onError: @escaping (INError) -> Void ) {
14
+ DispatchQueue.main.async(execute: {
15
+ CustomerIndigitall.getCustomerInformation(withFieldNames: params, success: onSuccess, failed: onError)
16
+ })
17
+ }
18
+
19
+ @objc public func assignOrUpdateValueToCustomerFields(params: [AnyHashable: Any], onSuccess: @escaping (INCustomer) -> Void, onError: @escaping (INError) -> Void ) {
20
+ DispatchQueue.main.async(execute: {
21
+ CustomerIndigitall.updateValueToCustomerFields(withFields: params, success: onSuccess, failed: onError)
22
+ })
23
+
24
+
25
+ }
26
+
27
+ @objc public func deleteValuesFromCustomerFields(params: [String], onSuccess: @escaping (INCustomer) -> Void, onError: @escaping (INError) -> Void ) {
28
+ DispatchQueue.main.async(execute: {
29
+ CustomerIndigitall.deleteValuesFromCustomerFields(withFieldNames: params, success: onSuccess, failed: onError)
30
+ })
31
+ }
32
+
33
+ @objc public func link(params: [AnyHashable: Any], onSuccess: @escaping () -> Void, onError: @escaping (INError) -> Void ) {
34
+ if let code = params["externalId"] as? String {
35
+ let device = INDevice.init().saveExternalCode(code) as! INDevice
36
+ INDefaults.setExternalId(device.externalCode)
37
+ DispatchQueue.main.async(execute: {
38
+ CustomerIndigitall.linkCustomer(with: self.getChannel(channel: params["channel"] as? String), success: onSuccess, failed: onError)
39
+ })
40
+ }
41
+ }
42
+
43
+ @objc public func unlink(params: [AnyHashable: Any], onSuccess: @escaping () -> Void, onError: @escaping (INError) -> Void ) {
44
+ DispatchQueue.main.async(execute: {
45
+ CustomerIndigitall.unlinkCustomer(with: self.getChannel(channel: params["channel"] as? String), success: onSuccess, failed: onError)
46
+ })
47
+ }
48
+
49
+ @objc private func getChannel(channel: String?) -> INChannel {
50
+ var channelType = 0 as UInt32;
51
+ if (channel == "inApp") { channelType = 1; }
52
+ if (channel == "chat") { channelType = 2; }
53
+ return INChannel.init(channelType)
54
+ }
55
+
56
+ }
@@ -0,0 +1,88 @@
1
+ import Foundation
2
+ import Indigitall
3
+ import Capacitor
4
+
5
+ @objc public class InAppCp: NSObject {
6
+ @objc public func inAppGet(_ params: String, onSuccess: @escaping (String, INInApp) -> Void, onError: @escaping (INError) -> Void) {
7
+ DispatchQueue.main.async(execute: {
8
+ InAppHandler.init().getInApp(params, success: onSuccess, errorLoad: onError)
9
+ })
10
+ }
11
+
12
+ @objc public func inAppWasShown(_ params: Dictionary<String, Any>, onSuccess: @escaping () -> Void, onError: @escaping (INError) -> Void) {
13
+ let inApp = IndigitallParse.inApp(fromJson: params)
14
+
15
+ DispatchQueue.main.async(execute: {
16
+ if (inApp.properties.dismissForever &&
17
+ InAppUtils.is(inAppDismissForever: inApp)) {
18
+ onError(INError.init(errorCode: INAPP_SHOW_POPUP_ERROR, errorMessage: INErrorUtils.pop_UP_DISMISS_FOREVER))
19
+ } else {
20
+ InAppUtils.inAppWasShownWith(inApp) { inAppCallback, error in
21
+ onError(INError.init(errorCode: INErrorCode.init(rawValue: 2301), errorMessage: error.message))
22
+ } didShowMoreThanOnce: { inAppCallback, error in
23
+ onError(INError.init(errorCode: INErrorCode.init(rawValue: 2302), errorMessage: error.message))
24
+ } didClickOut: { inAppCallback, error in
25
+ onError(INError.init(errorCode: INErrorCode.init(rawValue: 2303), errorMessage: error.message))
26
+ } onSuccess: {
27
+ onSuccess()
28
+ }
29
+ }
30
+ })
31
+ }
32
+
33
+ @objc public func addNewInAppClick(_ params: Dictionary<String, Any>) {
34
+ let inApp = IndigitallParse.inApp(fromJson: params)
35
+ DispatchQueue.main.async(execute: {
36
+ InAppUtils.add(inAppNewClick: inApp)
37
+ InAppUtils.event(inAppRequest: inApp.inAppId, lastVersionId: inApp.lastVersionId)
38
+ })
39
+
40
+ }
41
+
42
+ @objc public func addNewInAppToDismissForever(_ params: Dictionary<String, Any>) {
43
+ let inApp = IndigitallParse.inApp(fromJson: params)
44
+ DispatchQueue.main.async(execute: {
45
+ InAppUtils.addNewInApp(toDismissForever: inApp)
46
+ })
47
+ }
48
+
49
+ @objc public func showPopUp(_ params: Dictionary<String, Any>, onSuccess: @escaping (String) -> Void, onError: @escaping (INError) -> Void) {
50
+ var inAppCode = ""
51
+ var closeIconDisabled = false
52
+ var button: UIButton?
53
+ if let iconDisabled = params["closeIconDisabled"] as? Bool { closeIconDisabled = iconDisabled }
54
+ if let imageClose = params["imageCloseButtonName"] as? String {
55
+ button = UIButton.init()
56
+ button?.setImage(UIImage.init(named: imageClose), for: .normal)
57
+ button?.translatesAutoresizingMaskIntoConstraints = false
58
+ }
59
+ if let code = params["inAppSchemaCode"] as? String { inAppCode = code }
60
+ DispatchQueue.main.async(execute: {
61
+ Indigitall.showPopup(inAppCode, closeIcon: button, closeIconDisabled: closeIconDisabled) {
62
+ //onSuccess("onSuccess")
63
+ } didCancel: {
64
+ onSuccess("didCancel")
65
+ } didClicked: {
66
+ onSuccess("didClicked")
67
+ } didDismissed: {
68
+ onSuccess("didDisimissed")
69
+ } onShowTimeFinished: { inApp, timeShow in
70
+ onSuccess("onShowTimeFinished")
71
+ } didExpired: { inApp, error in
72
+ onSuccess("didExpired")
73
+ } didShowMoreThanOnce: { inApp, error in
74
+ onSuccess("didShowMoreThanOnce")
75
+ } didClickOut: { inApp, error in
76
+ onSuccess("didClickOut")
77
+ } didDismissForever: { inApp, error in
78
+ onSuccess("didDismissForever")
79
+ } failed: { error in
80
+ onError(error)
81
+ }
82
+
83
+ })
84
+
85
+
86
+ }
87
+
88
+ }
@@ -0,0 +1,78 @@
1
+ import Foundation
2
+ import Indigitall
3
+ import Capacitor
4
+
5
+ @objc public class InboxCp: NSObject, GetAuthConfig {
6
+
7
+ var auth: [AnyHashable : Any]? = nil;
8
+
9
+ public func getAuthConfig() -> [AnyHashable : Any] {
10
+ var dic = [AnyHashable : Any]();
11
+ if let auth = self.auth {
12
+ dic = auth;
13
+ }
14
+ return dic;
15
+ }
16
+
17
+ public var inbox: Inbox?
18
+
19
+ @objc public func getMessageCount(onSuccess: @escaping (INInboxCounters) -> Void, onError: @escaping (INError) -> Void) {
20
+ DispatchQueue.main.async(execute: {
21
+ Inbox.getMessagesCount(success: onSuccess, onError: onError)
22
+ })
23
+ }
24
+
25
+ @objc public func getInbox(onSuccess: @escaping (Inbox) -> Void, onError: @escaping (INError) -> Void) {
26
+ DispatchQueue.main.async(execute: {
27
+ Inbox.getWithSuccess { inbox in
28
+ self.inbox = inbox
29
+ onSuccess(inbox)
30
+ } onError: { error in
31
+ onError(error)
32
+ }
33
+ })
34
+ }
35
+
36
+ @objc public func getNextPage(onSuccess: @escaping (Inbox, [INInboxNotification]) -> Void, onError: @escaping (INError) -> Void) {
37
+ DispatchQueue.main.async(execute: {
38
+ if let myInbox = self.inbox {
39
+ myInbox.getNextPage(success: onSuccess, onError: onError)
40
+ }
41
+ })
42
+ }
43
+
44
+ @objc public func massiveEditNotificationsWithSendingIdsList(_ params: [AnyHashable:Any],onSuccess: @escaping () -> Void, onError: @escaping (INError) -> Void) {
45
+ if let sendingIdList = params["sendingIdList"] as? [NSNumber] {
46
+ var status = InboxStatus.sent
47
+ if let paramStatus = params["status"] as? String {
48
+ if (paramStatus == "click") {status = InboxStatus.click}
49
+ if (paramStatus == "deleted") {status = InboxStatus.deleted }
50
+ }
51
+ DispatchQueue.main.async(execute: {
52
+ if let myInbox = self.inbox {
53
+ myInbox.massiveEditNotifications(withSendingIdsList: sendingIdList, status: status, onSuccess: onSuccess, onError: onError)
54
+ }
55
+ })
56
+ }
57
+ }
58
+
59
+ @objc public func getInfoFromNotificationWithSendingId(_ sendingId: NSNumber, onSuccess: @escaping (INInboxNotification) -> Void, onError: @escaping (INError) -> Void) {
60
+ DispatchQueue.main.async(execute: {
61
+ if let myInbox = self.inbox {
62
+ myInbox.getInfoFromNotification(withSendingId: sendingId, onSuccess: onSuccess, onError: onError)
63
+ }
64
+ })
65
+ }
66
+
67
+ @objc public func modifyStatusFromNotificationWithSendingId(_ params: [AnyHashable: Any], onSuccess: @escaping (INInboxNotification) -> Void, onError: @escaping (INError) -> Void) {
68
+ if let myInbox = self.inbox {
69
+ if let sendingId = params["sendingId"] as? NSNumber {
70
+ let status = params["status"] as? String ?? InboxStatus.sent;
71
+ DispatchQueue.main.async(execute: {
72
+ myInbox.modifyStatusFromNotification(withSendingId: sendingId, status: status, onSuccess: onSuccess, onError: onError)
73
+ })
74
+ }
75
+ }
76
+ }
77
+
78
+ }
@@ -0,0 +1,122 @@
1
+ import Foundation
2
+ import Indigitall
3
+ import Capacitor
4
+
5
+ @objc public class IndigitallCp: NSObject {
6
+
7
+
8
+ @objc public func initialize(_ params: [String: Any], onSuccess: @escaping ([INPermissions], INDevice) -> Void, onError: @escaping (INError) -> Void ){
9
+ if let appKey = params["appKey"] as? String {
10
+ let config = INConfig.init(appKey: appKey)
11
+ config.pushPermissionMode = automatic
12
+ config.locationPermissionMode = manual
13
+ config.setProductName(params["productName"] as! String)
14
+ config.setProductVersion(params["productVersion"] as! String)
15
+ if (params["requestLocation"] as? Bool ?? false) { config.locationPermissionMode = automatic }
16
+ if (params["wifiFilterEnabled"] as? Bool ?? false) { config.wifiFilterEnabled = true }
17
+ if let urlDevice = params["urlDeviceApi"] { config.domain = urlDevice as? String ?? "https://device-api.indigitall.com/v1" }
18
+ if let urlInApp = params["urlInAppApi"] { config.domainInApp = urlInApp as? String ?? "https://inapp-api.indigitall.com/v1" }
19
+ if let urlInbox = params["urlInboxApi"] { config.domainInbox = urlInbox as? String ?? "https://inbox-api.indigitall.com/v1" }
20
+
21
+ DispatchQueue.main.async(execute: {
22
+ Indigitall.initialize(with: config, onIndigitallInitialized: onSuccess, onErrorInitialized: onError)
23
+ })
24
+ }
25
+ }
26
+
27
+ @objc public func deviceGet(_ onSuccess: @escaping (INDevice) -> Void, onError: @escaping (INError) -> Void) {
28
+ DispatchQueue.main.async(execute: {
29
+ Indigitall.getDeviceWith(onSuccess: onSuccess, onError: onError)
30
+ })
31
+ }
32
+
33
+ @objc public func deviceEnable(_ onSuccess: @escaping (INDevice) -> Void, onError: @escaping (INError) -> Void) {
34
+ DispatchQueue.main.async(execute: {
35
+ Indigitall.enableDeviceWith(onSuccess: onSuccess, onError: onError)
36
+ })
37
+ }
38
+
39
+ @objc public func deviceDisable(_ onSuccess: @escaping (INDevice) -> Void, onError: @escaping (INError) -> Void) {
40
+ DispatchQueue.main.async(execute: {
41
+ Indigitall.disableDeviceWith(onSuccess: onSuccess, onError: onError)
42
+ })
43
+ }
44
+
45
+ @objc public func topicsList(_ onSuccess: @escaping ([INTopic]) -> Void, onError: @escaping (INError) -> Void) {
46
+ DispatchQueue.main.async(execute: {
47
+ Indigitall.topicsListWith(onSuccess: onSuccess, onError: onError)
48
+ })
49
+
50
+ }
51
+
52
+ @objc public func topicsSubscribe(_ array: Array<Any>, onSuccess: @escaping ([INTopic]) -> Void, onError: @escaping (INError) -> Void) {
53
+ if let params = array as? [String] {
54
+ DispatchQueue.main.async(execute: {
55
+ Indigitall.topicsSubscribe(withArrayString: params, onSuccess: onSuccess, onError: onError)
56
+ })
57
+ } else if let params = array as? [Dictionary<String, Any>] {
58
+ var array = [INTopic]()
59
+ for topic in params {
60
+ let newTopic = INTopic.init(topic as! NSMutableDictionary)
61
+ array.append(newTopic)
62
+ }
63
+ DispatchQueue.main.async(execute: {
64
+ Indigitall.topicsSubscribe(withTopic: array, onSuccess: onSuccess, onError: onError)
65
+ })
66
+ }
67
+ }
68
+
69
+ @objc public func topicsUnsubscribe(_ array: Array<Any>, onSuccess: @escaping ([INTopic]) -> Void, onError: @escaping (INError) -> Void) {
70
+ if let params = array as? Array<String> {
71
+ DispatchQueue.main.async(execute: {
72
+ Indigitall.topicsUnSubscribe(withArrayString: params, onSuccess: onSuccess, onError: onError)
73
+ })
74
+ } else if let params = array as? Array<Dictionary<String, Any>> {
75
+ var array = [INTopic]()
76
+ for topic in params {
77
+ let newTopic = INTopic.init(topic as! NSMutableDictionary)
78
+ array.append(newTopic)
79
+ }
80
+ DispatchQueue.main.async(execute: {
81
+ Indigitall.topicsUnSubscribe(withTopic: array, onSuccess: onSuccess, onError: onError)
82
+ })
83
+ }
84
+ }
85
+
86
+ @objc public func sendCustomEvent(_ params: [String: Any], onSuccess: @escaping () -> Void, onError: @escaping (INError) -> Void) {
87
+ if let event = params["event"] as? String{
88
+ if let customData = params["customData"] as? Dictionary<String, Any> {
89
+ DispatchQueue.main.async(execute: {
90
+ Indigitall.sendCustomEvent(event, customData: customData, onSuccess: onSuccess, onError: onError)
91
+ })
92
+ }
93
+ }
94
+ }
95
+
96
+ // @objc public func getPush(onSuccess: @escaping (Dictionary<String, Any>) -> Void, onError: @escaping (INError) -> Void) {
97
+ // NotificationCenter.default.addObserver(forName:NSNotification.Name("IndigitallHandleWithNotificationPush"), object: nil, queue: nil) { note in
98
+ // if (UserDefaults.standard.dictionary(forKey: "IndigitallHandleWithNotificationPush") != nil){
99
+ // webView?.reload()
100
+ // }
101
+ // }
102
+ // DispatchQueue.main.async(execute: {
103
+ //
104
+ // })
105
+ // }
106
+
107
+ @objc public func logIn(_ params: String, onSuccess: @escaping (INDevice) -> Void, onError: @escaping (INError) -> Void) {
108
+ DispatchQueue.main.async(execute: {
109
+ Indigitall.logIn(withId: params, onSuccess: onSuccess, onError: onError)
110
+ })
111
+ }
112
+
113
+ @objc public func logOut(onSuccess: @escaping (INDevice) -> Void, onError: @escaping (INError) -> Void) {
114
+ DispatchQueue.main.async(execute: {
115
+ Indigitall.logOut(success: onSuccess, onError: onError)
116
+ })
117
+ }
118
+
119
+
120
+
121
+
122
+ }
@@ -0,0 +1,10 @@
1
+ #import <UIKit/UIKit.h>
2
+
3
+ //! Project version number for Plugin.
4
+ FOUNDATION_EXPORT double PluginVersionNumber;
5
+
6
+ //! Project version string for Plugin.
7
+ FOUNDATION_EXPORT const unsigned char PluginVersionString[];
8
+
9
+ // In this header, you should import all the public headers of your framework using statements like #import <Plugin/PublicHeader.h>
10
+
@@ -0,0 +1,19 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import <Capacitor/Capacitor.h>
3
+
4
+ // Define the plugin using the CAP_PLUGIN Macro, and
5
+ // each method the plugin supports using the CAP_PLUGIN_METHOD macro.
6
+ CAP_PLUGIN(IndigitallCpPlugin, "IndigitallCp",
7
+ CAP_PLUGIN_METHOD(initialize, CAPPluginReturnPromise);
8
+ CAP_PLUGIN_METHOD(deviceGet, CAPPluginReturnPromise);
9
+ CAP_PLUGIN_METHOD(deviceEnable, CAPPluginReturnPromise);
10
+ CAP_PLUGIN_METHOD(deviceDisable, CAPPluginReturnPromise);
11
+ CAP_PLUGIN_METHOD(topicsList, CAPPluginReturnPromise);
12
+ CAP_PLUGIN_METHOD(topicsSubscribe, CAPPluginReturnPromise);
13
+ CAP_PLUGIN_METHOD(topicsUnsubscribe, CAPPluginReturnPromise);
14
+ CAP_PLUGIN_METHOD(sendCustomEvent, CAPPluginReturnPromise);
15
+ CAP_PLUGIN_METHOD(getPush, CAPPluginReturnPromise);
16
+ CAP_PLUGIN_METHOD(logIn, CAPPluginReturnPromise);
17
+ CAP_PLUGIN_METHOD(logOut, CAPPluginReturnPromise);
18
+
19
+ )
@@ -0,0 +1,10 @@
1
+ #import <UIKit/UIKit.h>
2
+
3
+ //! Project version number for Plugin.
4
+ FOUNDATION_EXPORT double PluginVersionNumber;
5
+
6
+ //! Project version string for Plugin.
7
+ FOUNDATION_EXPORT const unsigned char PluginVersionString[];
8
+
9
+ // In this header, you should import all the public headers of your framework using statements like #import <Plugin/PublicHeader.h>
10
+