cordova-plugin-reteno 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.
Files changed (60) hide show
  1. package/.editorconfig +17 -0
  2. package/.travis.yml +108 -0
  3. package/CODE_OF_CONDUCT.md +133 -0
  4. package/CONTRIBUTING.md +114 -0
  5. package/LICENSE +20 -0
  6. package/docs/android.md +34 -0
  7. package/docs/api.md +8 -0
  8. package/docs/ios.md +62 -0
  9. package/package.json +41 -0
  10. package/plugin.xml +69 -0
  11. package/src/android/.idea/.name +1 -0
  12. package/src/android/.idea/compiler.xml +6 -0
  13. package/src/android/.idea/gradle.xml +20 -0
  14. package/src/android/.idea/misc.xml +10 -0
  15. package/src/android/.idea/vcs.xml +6 -0
  16. package/src/android/app/build.gradle +40 -0
  17. package/src/android/app/proguard-rules.pro +21 -0
  18. package/src/android/app/src/androidTest/java/com/reteno/plugin/ExampleInstrumentedTest.java +26 -0
  19. package/src/android/app/src/main/AndroidManifest.xml +20 -0
  20. package/src/android/app/src/main/java/com/reteno/plugin/CordovaRetenoApplication.java +7 -0
  21. package/src/android/app/src/main/java/com/reteno/plugin/RetenoEvent.java +74 -0
  22. package/src/android/app/src/main/java/com/reteno/plugin/RetenoPlugin.java +162 -0
  23. package/src/android/app/src/main/java/com/reteno/plugin/RetenoPushReceiver.java +14 -0
  24. package/src/android/app/src/main/java/com/reteno/plugin/RetenoUserAttributes.java +176 -0
  25. package/src/android/app/src/main/java/com/reteno/plugin/RetenoUtil.java +12 -0
  26. package/src/android/app/src/main/res/drawable/ic_launcher_background.xml +170 -0
  27. package/src/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml +30 -0
  28. package/src/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +6 -0
  29. package/src/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +6 -0
  30. package/src/android/app/src/main/res/mipmap-hdpi/ic_launcher.webp +0 -0
  31. package/src/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp +0 -0
  32. package/src/android/app/src/main/res/mipmap-mdpi/ic_launcher.webp +0 -0
  33. package/src/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp +0 -0
  34. package/src/android/app/src/main/res/mipmap-xhdpi/ic_launcher.webp +0 -0
  35. package/src/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp +0 -0
  36. package/src/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp +0 -0
  37. package/src/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp +0 -0
  38. package/src/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp +0 -0
  39. package/src/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp +0 -0
  40. package/src/android/app/src/main/res/values/colors.xml +10 -0
  41. package/src/android/app/src/main/res/values/strings.xml +3 -0
  42. package/src/android/app/src/main/res/values/themes.xml +16 -0
  43. package/src/android/app/src/main/res/values-night/themes.xml +16 -0
  44. package/src/android/app/src/main/res/xml/backup_rules.xml +13 -0
  45. package/src/android/app/src/main/res/xml/data_extraction_rules.xml +19 -0
  46. package/src/android/build.gradle +5 -0
  47. package/src/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  48. package/src/android/gradle/wrapper/gradle-wrapper.properties +5 -0
  49. package/src/android/gradle.properties +22 -0
  50. package/src/android/gradlew +185 -0
  51. package/src/android/gradlew.bat +89 -0
  52. package/src/android/reteno.gradle +13 -0
  53. package/src/android/settings.gradle +16 -0
  54. package/src/ios/RetenoEvent.swift +67 -0
  55. package/src/ios/RetenoPlugin-Bridging-Header.h +1 -0
  56. package/src/ios/RetenoPlugin.swift +221 -0
  57. package/src/ios/RetenoUserAttributes.swift +150 -0
  58. package/src/ios/RetenoUtils.swift +12 -0
  59. package/types/index.d.ts +98 -0
  60. package/www/cordova-plugin-reteno.js +54 -0
@@ -0,0 +1,16 @@
1
+ pluginManagement {
2
+ repositories {
3
+ google()
4
+ mavenCentral()
5
+ gradlePluginPortal()
6
+ }
7
+ }
8
+ dependencyResolutionManagement {
9
+ repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
10
+ repositories {
11
+ google()
12
+ mavenCentral()
13
+ }
14
+ }
15
+ include ':app'
16
+ rootProject.name = "Reteno Plugin"
@@ -0,0 +1,67 @@
1
+ import Foundation
2
+ import Reteno
3
+
4
+ struct RetenoCustomEventParameter: Codable {
5
+ init(dictionary: [String: Any]?) throws {
6
+ self = try JSONDecoder().decode(RetenoCustomEventParameter.self, from: JSONSerialization.data(withJSONObject: dictionary ?? [:]))
7
+ }
8
+ let name: String;
9
+ let value: String?;
10
+ }
11
+
12
+ struct RetenoCustomEvent: Codable {
13
+ init(dictionary: [String: Any]?) throws {
14
+ self = try JSONDecoder().decode(RetenoCustomEvent.self, from: JSONSerialization.data(withJSONObject: dictionary ?? [:]))
15
+ }
16
+ let eventName: String;
17
+ let date: String;
18
+ let parameters: [RetenoCustomEventParameter];
19
+ let forcePush: Bool?;
20
+ }
21
+
22
+ public struct RetenoEventPayload: Codable {
23
+ init(eventName: String, stringDate: String, parameters: [RetenoCustomEventParameter], forcePush: Bool?) {
24
+ self.eventName = eventName;
25
+
26
+ let dateFormatter = ISO8601DateFormatter();
27
+ self.date = dateFormatter.date(from: stringDate) ?? Date();
28
+
29
+ self.forcePush = forcePush == nil ? false : forcePush!;
30
+
31
+ var paramArr = [Event.Parameter]();
32
+ for param in parameters {
33
+ paramArr.append(Event.Parameter(name: param.name, value: param.value ?? ""));
34
+ }
35
+ self.parameters = paramArr;
36
+ }
37
+
38
+ let eventName: String;
39
+ let date: Date;
40
+ let parameters: [Event.Parameter];
41
+ let forcePush: Bool;
42
+ }
43
+
44
+ public struct RetenoEvent {
45
+ private init() {}
46
+
47
+ private static func getStringOrNil(input: String?) -> String? {
48
+ return (input ?? "").isEmpty ? nil : input!
49
+ }
50
+
51
+ public static func buildEventPayload(payload: NSDictionary) throws -> RetenoEventPayload {
52
+ let data = payload as? [String: Any];
53
+ do {
54
+ let payloadStruct = try RetenoCustomEvent(dictionary: data);
55
+ let requestPayload = RetenoEventPayload(
56
+ eventName: payloadStruct.eventName,
57
+ stringDate: payloadStruct.date,
58
+ parameters: payloadStruct.parameters,
59
+ forcePush: payloadStruct.forcePush
60
+ );
61
+
62
+ return requestPayload;
63
+ } catch {
64
+ throw error;
65
+ }
66
+ }
67
+ }
@@ -0,0 +1 @@
1
+ #import <Cordova/CDV.h>
@@ -0,0 +1,221 @@
1
+ import Foundation
2
+ import Reteno
3
+ import SwiftUI
4
+ import UserNotifications
5
+ import Reteno
6
+ import Sentry
7
+
8
+ @objc(RetenoPlugin) class RetenoPlugin : CDVPlugin {
9
+ var retenoStarted = false
10
+
11
+ override func pluginInitialize() {
12
+
13
+ }
14
+
15
+ @objc(setApiKey:)
16
+ func setApiKey(command: CDVInvokedUrlCommand) {
17
+
18
+ var pluginResult = CDVPluginResult(
19
+ status: CDVCommandStatus_ERROR
20
+ )
21
+ let key = command.arguments[0] as? String ?? ""
22
+ if (!retenoStarted){
23
+ Reteno.start(apiKey: key, isDebugMode: true)
24
+ Reteno.userNotificationService.registerForRemoteNotifications()
25
+ retenoStarted = true
26
+ }
27
+ pluginResult = CDVPluginResult(
28
+ status: CDVCommandStatus_OK,
29
+ messageAs: key
30
+ )
31
+ self.commandDelegate!.send(
32
+ pluginResult,
33
+ callbackId: command.callbackId
34
+ )
35
+ }
36
+
37
+ @objc(logEvent:)
38
+ func logEvent(command: CDVInvokedUrlCommand) {
39
+ var pluginResult = CDVPluginResult(
40
+ status: CDVCommandStatus_ERROR
41
+ );
42
+ self.commandDelegate.run(inBackground: { [self] in
43
+ pluginResult = logEventAsync(command: command)
44
+ })
45
+
46
+ self.commandDelegate!.send(
47
+ pluginResult,
48
+ callbackId: command.callbackId
49
+ )
50
+ }
51
+
52
+ func logEventAsync(command: CDVInvokedUrlCommand) -> CDVPluginResult{
53
+ var pluginResult = CDVPluginResult(
54
+ status: CDVCommandStatus_ERROR
55
+ )
56
+ let payload = command.arguments[0] as? NSDictionary ?? NSDictionary()
57
+ var res = true;
58
+ do {
59
+ let requestPayload = try RetenoEvent.buildEventPayload(payload: payload);
60
+ Reteno.logEvent(
61
+ eventTypeKey: requestPayload.eventName,
62
+ date: requestPayload.date,
63
+ parameters: requestPayload.parameters,
64
+ forcePush: requestPayload.forcePush
65
+ );
66
+ } catch {
67
+ pluginResult = CDVPluginResult(
68
+ status: CDVCommandStatus_OK,
69
+ messageAs: error.localizedDescription
70
+ )
71
+ res = false;
72
+ }
73
+
74
+ if (res){
75
+ pluginResult = CDVPluginResult(
76
+ status: CDVCommandStatus_OK
77
+ )
78
+ }
79
+ return pluginResult ?? CDVPluginResult(status: CDVCommandStatus_ERROR);
80
+ }
81
+
82
+
83
+ @objc(setUserAttributes:)
84
+ func setUserAttributes(command: CDVInvokedUrlCommand) {
85
+ var pluginResult = CDVPluginResult(
86
+ status: CDVCommandStatus_ERROR
87
+ );
88
+ self.commandDelegate.run(inBackground: { [self] in
89
+ pluginResult = setUserAttributesAsync(command: command)
90
+ })
91
+
92
+ self.commandDelegate!.send(
93
+ pluginResult,
94
+ callbackId: command.callbackId
95
+ )
96
+ }
97
+
98
+ func setUserAttributesAsync(command: CDVInvokedUrlCommand) -> CDVPluginResult{
99
+ var pluginResult = CDVPluginResult(
100
+ status: CDVCommandStatus_ERROR
101
+ )
102
+ let payload = command.arguments[0] as? NSDictionary ?? NSDictionary()
103
+
104
+ let externalUserId = payload["externalUserId"] as? String;
105
+ var res = true;
106
+
107
+ do {
108
+ let requestPayload = try RetenoUserAttributes.buildSetUserAttributesPayload(payload: payload);
109
+ Reteno.updateUserAttributes(
110
+ externalUserId: externalUserId,
111
+ userAttributes: requestPayload.userAttributes,
112
+ subscriptionKeys: requestPayload.subscriptionKeys,
113
+ groupNamesInclude: requestPayload.groupNamesInclude,
114
+ groupNamesExclude: requestPayload.groupNamesExclude
115
+ );
116
+
117
+ } catch {
118
+ pluginResult = CDVPluginResult(
119
+ status: CDVCommandStatus_OK,
120
+ messageAs: error.localizedDescription
121
+ )
122
+ res = false;
123
+ }
124
+
125
+ if (res){
126
+ pluginResult = CDVPluginResult(
127
+ status: CDVCommandStatus_OK
128
+ )
129
+ }
130
+ self.commandDelegate!.send(
131
+ pluginResult,
132
+ callbackId: command.callbackId
133
+ )
134
+ return pluginResult ?? CDVPluginResult(status: CDVCommandStatus_ERROR);
135
+ }
136
+
137
+ @objc(setAnonymousUserAttributes:)
138
+ func setAnonymousUserAttributes(command: CDVInvokedUrlCommand) {
139
+ var pluginResult = CDVPluginResult(
140
+ status: CDVCommandStatus_ERROR
141
+ );
142
+ self.commandDelegate.run(inBackground: { [self] in
143
+ pluginResult = setAnonymousUserAttributesAsync(command: command)
144
+ })
145
+
146
+ self.commandDelegate!.send(
147
+ pluginResult,
148
+ callbackId: command.callbackId
149
+ )
150
+ }
151
+
152
+
153
+ func setAnonymousUserAttributesAsync(command: CDVInvokedUrlCommand) -> CDVPluginResult{
154
+ var pluginResult = CDVPluginResult(
155
+ status: CDVCommandStatus_ERROR
156
+ )
157
+ let payload = command.arguments[0] as? NSDictionary ?? NSDictionary()
158
+
159
+ var res = true;
160
+
161
+ do {
162
+ let userAttributes = try RetenoUserAttributes.buildAnonymousUserAttributesPayload(payload: payload);
163
+ Reteno.updateAnonymousUserAttributes(userAttributes: userAttributes);
164
+
165
+ } catch {
166
+ pluginResult = CDVPluginResult(
167
+ status: CDVCommandStatus_OK,
168
+ messageAs: error.localizedDescription
169
+ )
170
+ res = false;
171
+ }
172
+
173
+ if (res){
174
+ pluginResult = CDVPluginResult(
175
+ status: CDVCommandStatus_OK
176
+ )
177
+ }
178
+ self.commandDelegate!.send(
179
+ pluginResult,
180
+ callbackId: command.callbackId
181
+ )
182
+ return pluginResult ?? CDVPluginResult(status: CDVCommandStatus_ERROR);
183
+ }
184
+
185
+ @objc(getInitialNotification:)
186
+ func getInitialNotification(command: CDVInvokedUrlCommand) {
187
+ let pluginResult = CDVPluginResult(
188
+ status: CDVCommandStatus_ERROR
189
+ )
190
+
191
+ self.commandDelegate!.send(
192
+ pluginResult,
193
+ callbackId: command.callbackId
194
+ )
195
+ }
196
+
197
+ @objc(performRemoteToken:)
198
+ func performRemoteToken(command: CDVInvokedUrlCommand) {
199
+ let pluginResult = CDVPluginResult(
200
+ status: CDVCommandStatus_ERROR
201
+ )
202
+ let fcmToken = command.arguments[0] as? String ?? ""
203
+ Reteno.userNotificationService.processRemoteNotificationsToken(fcmToken);
204
+ self.commandDelegate!.send(
205
+ pluginResult,
206
+ callbackId: command.callbackId
207
+ )
208
+ }
209
+
210
+ @objc(setOnRetenoPushReceivedListener:)
211
+ func setOnRetenoPushReceivedListener(command: CDVInvokedUrlCommand) {
212
+ let pluginResult = CDVPluginResult(
213
+ status: CDVCommandStatus_ERROR
214
+ )
215
+
216
+ self.commandDelegate!.send(
217
+ pluginResult,
218
+ callbackId: command.callbackId
219
+ )
220
+ }
221
+ }
@@ -0,0 +1,150 @@
1
+ import Foundation
2
+ import Reteno
3
+
4
+
5
+
6
+ struct RetenoUserAttributesFieldStruct: Codable {
7
+ let key: String
8
+ let value: String
9
+ init(dictionary: [String: Any]) throws {
10
+ self = try JSONDecoder().decode(
11
+ RetenoUserAttributesFieldStruct.self,
12
+ from: JSONSerialization.data(withJSONObject: dictionary)
13
+ )
14
+ }
15
+ }
16
+
17
+ struct RetenoUserAttributesAddressStruct: Codable {
18
+ init(dictionary: [String: Any]) throws {
19
+ self = try JSONDecoder().decode(
20
+ RetenoUserAttributesAddressStruct.self,
21
+ from: JSONSerialization.data(withJSONObject: dictionary)
22
+ )
23
+ }
24
+ let region: String?
25
+ let town: String?
26
+ let address: String?
27
+ let postcode: String?
28
+ }
29
+
30
+ struct RetenoUserAttributesStruct: Codable {
31
+ init(dictionary: [String: Any]) throws {
32
+ self = try JSONDecoder().decode(
33
+ RetenoUserAttributesStruct.self,
34
+ from: JSONSerialization.data(withJSONObject: dictionary)
35
+ )
36
+ }
37
+ let phone: String?
38
+ let email: String?
39
+ let firstName: String?
40
+ let lastName: String?
41
+ let languageCode: String?
42
+ let timeZone: String?
43
+ let address: RetenoUserAttributesAddressStruct?
44
+ let fields: [RetenoUserAttributesFieldStruct]?
45
+ }
46
+
47
+ struct RetenoUserStruct: Codable {
48
+ init(dictionary: [String: Any]?) throws {
49
+ self = try JSONDecoder().decode(RetenoUserStruct.self, from: JSONSerialization.data(withJSONObject: dictionary ?? [:]))
50
+ }
51
+ let userAttributes: RetenoUserAttributesStruct?
52
+ let subscriptionKeys: [String]?
53
+ let groupNamesInclude: [String]?
54
+ let groupNamesExclude: [String]?
55
+ }
56
+
57
+ public struct RetenoSetUserAttributesPayload: Codable {
58
+ init(userAttributes: UserAttributes?, subscriptionKeys: [String], groupNamesInclude: [String], groupNamesExclude: [String]) {
59
+ self.userAttributes = userAttributes;
60
+ self.subscriptionKeys = subscriptionKeys;
61
+ self.groupNamesInclude = groupNamesInclude;
62
+ self.groupNamesExclude = groupNamesExclude;
63
+ }
64
+
65
+ let userAttributes: UserAttributes?
66
+ let subscriptionKeys: [String]
67
+ let groupNamesInclude: [String]
68
+ let groupNamesExclude: [String]
69
+ }
70
+
71
+ public struct RetenoUserAttributes {
72
+
73
+
74
+ private init() {}
75
+
76
+ private static func getStringOrNil(input: String?) -> String? {
77
+ return (input ?? "").isEmpty ? nil : input!
78
+ }
79
+
80
+ private static func buildUserAttributes(userStruct: RetenoUserStruct) -> UserAttributes {
81
+ let fields = userStruct.userAttributes?.fields?.map { field in
82
+ UserCustomField(key: field.key, value: field.value)
83
+ }
84
+
85
+ return UserAttributes(
86
+ phone: getStringOrNil(input: userStruct.userAttributes?.phone),
87
+ email: getStringOrNil(input: userStruct.userAttributes?.email),
88
+ firstName: getStringOrNil(input: userStruct.userAttributes?.firstName),
89
+ lastName: getStringOrNil(input: userStruct.userAttributes?.lastName),
90
+ languageCode: getStringOrNil(input: userStruct.userAttributes?.languageCode),
91
+ timeZone: getStringOrNil(input: userStruct.userAttributes?.timeZone),
92
+ address: userStruct.userAttributes?.address != nil ? Address(
93
+ region: getStringOrNil(input: userStruct.userAttributes?.address?.region),
94
+ town: getStringOrNil(input: userStruct.userAttributes?.address?.town),
95
+ address: getStringOrNil(input: userStruct.userAttributes?.address?.address),
96
+ postcode: getStringOrNil(input: userStruct.userAttributes?.address?.postcode)
97
+ ) : nil,
98
+ fields: fields ?? []
99
+ );
100
+ }
101
+
102
+ public static func buildSetUserAttributesPayload(payload: NSDictionary) throws -> RetenoSetUserAttributesPayload {
103
+ let user = payload["user"] as? [String: Any];
104
+ do {
105
+ let userStruct = try RetenoUserStruct(dictionary: user);
106
+ let userAttributes = userStruct.userAttributes != nil ? buildUserAttributes(userStruct: userStruct) : nil;
107
+ let requestPayload = RetenoSetUserAttributesPayload(
108
+ userAttributes: userAttributes,
109
+ subscriptionKeys: userStruct.subscriptionKeys ?? [],
110
+ groupNamesInclude: userStruct.groupNamesInclude ?? [],
111
+ groupNamesExclude: userStruct.groupNamesExclude ?? []
112
+ )
113
+ return requestPayload;
114
+ } catch {
115
+ throw error;
116
+ }
117
+ }
118
+
119
+ public static func buildAnonymousUserAttributesPayload (payload: NSDictionary) throws -> AnonymousUserAttributes{
120
+ let user = payload["user"] as? [String: Any];
121
+ do {
122
+ let userStruct = try RetenoUserStruct(dictionary: user);
123
+ let userAttributes = userStruct.userAttributes != nil ? buildAnonymousUserAttributes(userStruct: userStruct) : nil;
124
+
125
+ return userAttributes ?? AnonymousUserAttributes();
126
+ } catch {
127
+ throw error;
128
+ }
129
+ }
130
+
131
+ private static func buildAnonymousUserAttributes(userStruct: RetenoUserStruct) -> AnonymousUserAttributes {
132
+ let fields = userStruct.userAttributes?.fields?.map { field in
133
+ UserCustomField(key: field.key, value: field.value)
134
+ }
135
+
136
+ return AnonymousUserAttributes(
137
+ firstName: getStringOrNil(input: userStruct.userAttributes?.firstName),
138
+ lastName: getStringOrNil(input: userStruct.userAttributes?.lastName),
139
+ languageCode: getStringOrNil(input: userStruct.userAttributes?.languageCode),
140
+ timeZone: getStringOrNil(input: userStruct.userAttributes?.timeZone),
141
+ address: userStruct.userAttributes?.address != nil ? Address(
142
+ region: getStringOrNil(input: userStruct.userAttributes?.address?.region),
143
+ town: getStringOrNil(input: userStruct.userAttributes?.address?.town),
144
+ address: getStringOrNil(input: userStruct.userAttributes?.address?.address),
145
+ postcode: getStringOrNil(input: userStruct.userAttributes?.address?.postcode)
146
+ ) : nil,
147
+ fields: fields ?? []
148
+ );
149
+ }
150
+ }
@@ -0,0 +1,12 @@
1
+ import Foundation
2
+ import Reteno
3
+
4
+ @objc public class RetenoUtils: NSObject {
5
+ @objc func processRemoteNotificationsToken(fcmToken: String) {
6
+ Reteno.userNotificationService.processRemoteNotificationsToken(fcmToken);
7
+ }
8
+
9
+ @objc func start() {
10
+ Reteno.userNotificationService.registerForRemoteNotifications()
11
+ }
12
+ }
@@ -0,0 +1,98 @@
1
+ export type Address = {
2
+ region?: string | null;
3
+ town?: string | null;
4
+ address?: string | null;
5
+ postcode?: string | null;
6
+ };
7
+
8
+ type Field = {
9
+ key: string;
10
+ value: string;
11
+ };
12
+
13
+ type Fields = Field[];
14
+
15
+ export type UserAttributes = {
16
+ phone?: string | null;
17
+ email?: string | null;
18
+ firstName?: string | null;
19
+ lastName?: string | null;
20
+ languageCode?: string | null;
21
+ timeZone?: string | null;
22
+ address?: Address | null;
23
+ fields?: Fields | null;
24
+ };
25
+
26
+ export type User = {
27
+ userAttributes?: UserAttributes | null;
28
+ subscriptionKeys?: String[] | null;
29
+ groupNamesInclude?: String[] | null;
30
+ groupNamesExclude?: String[] | null;
31
+ };
32
+
33
+ export type SetUserAttributesPayload = {
34
+ externalUserId: string;
35
+ user: User;
36
+ };
37
+
38
+ export type CustomEventParameter = {
39
+ name: string;
40
+ value?: string;
41
+ };
42
+
43
+
44
+
45
+ export interface RetenoPlugin {
46
+ setApiKey (
47
+ apiKey: string,
48
+ success?: () => void,
49
+ error?: (err: string) => void
50
+ ): void
51
+
52
+ logEvent(
53
+ eventName: string,
54
+ date: string,
55
+ // date parameter should be in ISO8601 format
56
+ parameters: CustomEventParameter[],
57
+ forcePush?: boolean
58
+ ) : void
59
+
60
+ setUserAttributes(
61
+ payload: SetUserAttributesPayload
62
+ ) :void
63
+
64
+ setAnonymousUserAttributes(
65
+ payload: User
66
+ ) :void
67
+
68
+ getInitialNotification(
69
+ success: (value: object) => void,
70
+ error: (err: string) => void
71
+ ) : void
72
+
73
+ setOnRetenoPushReceivedListener (
74
+ success: (value: object) => void,
75
+ error: (err: string) => void
76
+ ) : void
77
+
78
+ performRemoteToken(
79
+ apiKey: string,
80
+ success?: () => void,
81
+ error?: (err: string) => void
82
+ ) : void
83
+
84
+ setDeviceToken (
85
+ deviceToken: string
86
+ ) : void
87
+
88
+ registerApplicationDidBecomeActiveListener(
89
+ fn: () => void,
90
+ ): void
91
+ registerApplicationDidEnterBackgroundListener(
92
+ fn: () => void,
93
+ ): void
94
+ }
95
+
96
+ declare global {
97
+ const RetenoPlugin: RetenoPlugin;
98
+ }
@@ -0,0 +1,54 @@
1
+ var exec = require('cordova/exec');
2
+
3
+ var PLUGIN_NAME = 'RetenoPlugin';
4
+
5
+ var onApplicationDidBecomeActiveCallback = function(){};
6
+ var onApplicationDidEnterBackgroundCallback = function(){};
7
+
8
+ /***********************
9
+ * Protected internals
10
+ ***********************/
11
+ // iOS only
12
+ exports._applicationDidBecomeActive = function(){
13
+ onApplicationDidBecomeActiveCallback();
14
+ };
15
+
16
+ exports._applicationDidEnterBackground = function(){
17
+ onApplicationDidEnterBackgroundCallback();
18
+ };
19
+
20
+ /**************
21
+ * Public API
22
+ **************/
23
+ exports.setApiKey = function (arg0, success, error) {
24
+ exec(success, error, PLUGIN_NAME, 'setApiKey', [arg0]);
25
+ };
26
+
27
+ exports.logEvent = function (arg0, success, error) {
28
+ exec(success, error, PLUGIN_NAME, "logEvent", [arg0]);
29
+ },
30
+
31
+ exports.setUserAttributes= function (arg0, success, error) {
32
+ exec(success, error, PLUGIN_NAME, "setUserAttributes", [arg0]);
33
+ };
34
+
35
+ exports.setAnonymousUserAttributes= function (arg0, success, error) {
36
+ exec(success, error, PLUGIN_NAME, "setAnonymousUserAttributes", [arg0]);
37
+ };
38
+
39
+ exports.getInitialNotification = function (arg0, success, error) {
40
+ exec(success, error, PLUGIN_NAME, "getInitialNotification", [arg0]);
41
+ };
42
+
43
+ exports.performRemoteToken = function (arg0, success, error) {
44
+ exec(success, error, PLUGIN_NAME, "performRemoteToken", [arg0]);
45
+ };
46
+
47
+ exports.setOnRetenoPushReceivedListener = function (success, error) {
48
+ exec(success, error, PLUGIN_NAME, "setOnRetenoPushReceivedListener", []);
49
+ };
50
+
51
+ exports.setDeviceToken = function (arg0, success, error) {
52
+ exec(success, error, PLUGIN_NAME, "setDeviceToken", [arg0]);
53
+ };
54
+