@clix-so/react-native-sdk 0.0.1 → 0.0.2-beta.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/README.md +51 -5
- package/lib/module/core/Clix.js +9 -7
- package/lib/module/core/Clix.js.map +1 -1
- package/lib/module/core/ClixNotification.js +122 -0
- package/lib/module/core/ClixNotification.js.map +1 -0
- package/lib/module/services/DeviceService.js +27 -19
- package/lib/module/services/DeviceService.js.map +1 -1
- package/lib/module/services/EventAPIService.js +7 -1
- package/lib/module/services/EventAPIService.js.map +1 -1
- package/lib/module/services/EventService.js +8 -5
- package/lib/module/services/EventService.js.map +1 -1
- package/lib/module/services/NotificationService.js +91 -49
- package/lib/module/services/NotificationService.js.map +1 -1
- package/lib/module/services/StorageService.js +52 -15
- package/lib/module/services/StorageService.js.map +1 -1
- package/lib/module/services/TokenService.js +13 -13
- package/lib/module/services/TokenService.js.map +1 -1
- package/lib/module/utils/ClixDateFormatter.js +19 -0
- package/lib/module/utils/ClixDateFormatter.js.map +1 -0
- package/lib/typescript/src/core/Clix.d.ts +11 -11
- package/lib/typescript/src/core/Clix.d.ts.map +1 -1
- package/lib/typescript/src/core/ClixNotification.d.ts +25 -0
- package/lib/typescript/src/core/ClixNotification.d.ts.map +1 -0
- package/lib/typescript/src/services/DeviceService.d.ts +3 -2
- package/lib/typescript/src/services/DeviceService.d.ts.map +1 -1
- package/lib/typescript/src/services/EventAPIService.d.ts +1 -1
- package/lib/typescript/src/services/EventAPIService.d.ts.map +1 -1
- package/lib/typescript/src/services/EventService.d.ts +1 -1
- package/lib/typescript/src/services/EventService.d.ts.map +1 -1
- package/lib/typescript/src/services/NotificationService.d.ts +21 -1
- package/lib/typescript/src/services/NotificationService.d.ts.map +1 -1
- package/lib/typescript/src/services/StorageService.d.ts +11 -6
- package/lib/typescript/src/services/StorageService.d.ts.map +1 -1
- package/lib/typescript/src/services/TokenService.d.ts +5 -5
- package/lib/typescript/src/services/TokenService.d.ts.map +1 -1
- package/lib/typescript/src/utils/ClixDateFormatter.d.ts +4 -0
- package/lib/typescript/src/utils/ClixDateFormatter.d.ts.map +1 -0
- package/package.json +2 -2
- package/src/core/Clix.ts +17 -21
- package/src/core/ClixNotification.ts +157 -0
- package/src/services/DeviceService.ts +35 -20
- package/src/services/EventAPIService.ts +5 -1
- package/src/services/EventService.ts +13 -5
- package/src/services/NotificationService.ts +145 -54
- package/src/services/StorageService.ts +60 -16
- package/src/services/TokenService.ts +13 -15
- package/src/utils/ClixDateFormatter.ts +19 -0
|
@@ -8,20 +8,18 @@ export class TokenService {
|
|
|
8
8
|
|
|
9
9
|
constructor(private readonly storageService: StorageService) {}
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
getCurrentToken(): string | undefined {
|
|
12
12
|
try {
|
|
13
|
-
return
|
|
14
|
-
TokenService.CURRENT_TOKEN_KEY
|
|
15
|
-
);
|
|
13
|
+
return this.storageService.get<string>(TokenService.CURRENT_TOKEN_KEY);
|
|
16
14
|
} catch (error) {
|
|
17
15
|
ClixLogger.error('Failed to get current token', error);
|
|
18
16
|
return undefined;
|
|
19
17
|
}
|
|
20
18
|
}
|
|
21
19
|
|
|
22
|
-
|
|
20
|
+
getPreviousTokens(): string[] {
|
|
23
21
|
try {
|
|
24
|
-
const result =
|
|
22
|
+
const result = this.storageService.get<string[]>(
|
|
25
23
|
TokenService.PREVIOUS_TOKENS_KEY
|
|
26
24
|
);
|
|
27
25
|
if (result === undefined) return [];
|
|
@@ -33,11 +31,11 @@ export class TokenService {
|
|
|
33
31
|
}
|
|
34
32
|
}
|
|
35
33
|
|
|
36
|
-
|
|
34
|
+
saveToken(token: string) {
|
|
37
35
|
try {
|
|
38
|
-
|
|
36
|
+
this.storageService.set(TokenService.CURRENT_TOKEN_KEY, token);
|
|
39
37
|
|
|
40
|
-
let tokens =
|
|
38
|
+
let tokens = this.getPreviousTokens();
|
|
41
39
|
|
|
42
40
|
// Remove existing token if present
|
|
43
41
|
const currentIndex = tokens.indexOf(token);
|
|
@@ -53,7 +51,7 @@ export class TokenService {
|
|
|
53
51
|
tokens = tokens.slice(-TokenService.MAX_TOKENS);
|
|
54
52
|
}
|
|
55
53
|
|
|
56
|
-
|
|
54
|
+
this.storageService.set(TokenService.PREVIOUS_TOKENS_KEY, tokens);
|
|
57
55
|
ClixLogger.debug('Token saved successfully');
|
|
58
56
|
} catch (error) {
|
|
59
57
|
ClixLogger.error('Failed to save token', error);
|
|
@@ -61,10 +59,10 @@ export class TokenService {
|
|
|
61
59
|
}
|
|
62
60
|
}
|
|
63
61
|
|
|
64
|
-
|
|
62
|
+
clearTokens() {
|
|
65
63
|
try {
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
this.storageService.remove(TokenService.PREVIOUS_TOKENS_KEY);
|
|
65
|
+
this.storageService.remove(TokenService.CURRENT_TOKEN_KEY);
|
|
68
66
|
ClixLogger.debug('All tokens cleared');
|
|
69
67
|
} catch (error) {
|
|
70
68
|
ClixLogger.error('Failed to clear tokens', error);
|
|
@@ -78,7 +76,7 @@ export class TokenService {
|
|
|
78
76
|
.join('');
|
|
79
77
|
}
|
|
80
78
|
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
reset() {
|
|
80
|
+
this.clearTokens();
|
|
83
81
|
}
|
|
84
82
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export class ClixDateFormatter {
|
|
2
|
+
static format(date: Date): string {
|
|
3
|
+
const pad = (num: number) => num.toString().padStart(2, '0');
|
|
4
|
+
|
|
5
|
+
const year = date.getFullYear();
|
|
6
|
+
const month = pad(date.getMonth() + 1);
|
|
7
|
+
const day = pad(date.getDate());
|
|
8
|
+
const hours = pad(date.getHours());
|
|
9
|
+
const minutes = pad(date.getMinutes());
|
|
10
|
+
const seconds = pad(date.getSeconds());
|
|
11
|
+
|
|
12
|
+
const offsetMinutes = date.getTimezoneOffset();
|
|
13
|
+
const offsetSign = offsetMinutes <= 0 ? '+' : '-';
|
|
14
|
+
const offsetHours = pad(Math.floor(Math.abs(offsetMinutes) / 60));
|
|
15
|
+
const offsetMinutesPart = pad(Math.abs(offsetMinutes) % 60);
|
|
16
|
+
|
|
17
|
+
return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}${offsetSign}${offsetHours}:${offsetMinutesPart}`;
|
|
18
|
+
}
|
|
19
|
+
}
|