indigitall-capacitor-plugin 3.0.0 → 3.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/dist/esm/Push.js +1 -1
- package/dist/esm/Push.js.map +1 -1
- package/dist/plugin.cjs.js +1 -1
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +1 -1
- package/dist/plugin.js.map +1 -1
- package/ios/ObjC/CpINDefaults.h +23 -0
- package/ios/ObjC/CpINDefaults.m +52 -0
- package/ios/ObjC/IndigitallCpPlugin.h +10 -0
- package/ios/ObjC/IndigitallCpPlugin.m +28 -0
- package/ios/ObjC/IndigitallCustomerPlugin.h +10 -0
- package/ios/ObjC/IndigitallCustomerPlugin.m +14 -0
- package/ios/ObjC/IndigitallInAppPlugin.h +10 -0
- package/ios/ObjC/IndigitallInAppPlugin.m +19 -0
- package/ios/ObjC/IndigitallInboxPlugin.h +10 -0
- package/ios/ObjC/IndigitallInboxPlugin.m +13 -0
- package/ios/ObjC/IndigitallLAParse.h +20 -0
- package/ios/ObjC/IndigitallLAParse.m +52 -0
- package/ios/ObjC/IndigitallLAPlugin.h +17 -0
- package/ios/ObjC/IndigitallLAPlugin.m +19 -0
- package/ios/ObjC/IndigitallParse.h +32 -0
- package/ios/ObjC/IndigitallParse.m +469 -0
- package/package.json +2 -2
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
//
|
|
2
|
+
// IndigitallLAParse.m
|
|
3
|
+
// IndigitallCapacitorPlugin
|
|
4
|
+
//
|
|
5
|
+
// Created by Guillermo Claros on 4/8/25.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#import "IndigitallLAParse.h"
|
|
9
|
+
|
|
10
|
+
@implementation IndigitallLAParse
|
|
11
|
+
+ (NSDictionary *)jsonFromDevice: (INLADevice *)device {
|
|
12
|
+
NSMutableDictionary *obj = [[NSMutableDictionary alloc]init];
|
|
13
|
+
if (device != nil) {
|
|
14
|
+
obj = [@{
|
|
15
|
+
@"enable" : device.enabled,
|
|
16
|
+
@"deviceId": device.deviceID ?: @"",
|
|
17
|
+
@"platform": device.platform ?: @"",
|
|
18
|
+
@"version": device.sdkVersion ?: @"",
|
|
19
|
+
@"productName" : device.productName ?: @"",
|
|
20
|
+
@"productVersion" : device.productVersion ?: @"",
|
|
21
|
+
@"osName": device.osName ?: @"",
|
|
22
|
+
@"osVersion": device.osVersion ?: @"",
|
|
23
|
+
@"deviceBrand": device.deviceBrand ?: @"",
|
|
24
|
+
@"deviceModel": device.deviceModel ?: @"",
|
|
25
|
+
@"operator": device.carrier ?: @"",
|
|
26
|
+
@"deviceType": device.deviceType ?: @"",
|
|
27
|
+
@"appVersion": device.appVersion ?: @"",
|
|
28
|
+
@"locale": device.locale ?: @"",
|
|
29
|
+
@"timeZone": device.timeZone ?: @"",
|
|
30
|
+
@"timeOffset": @(device.timeOffset) ?: 0,
|
|
31
|
+
@"externalCode": device.externalCode ?: @"",
|
|
32
|
+
} mutableCopy];
|
|
33
|
+
}
|
|
34
|
+
return [obj copy];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
+ (NSDictionary *) jsonFromINLiveActivity: (INLiveActivity *)la {
|
|
38
|
+
NSMutableDictionary *obj = [[NSMutableDictionary alloc]init];
|
|
39
|
+
if (la != nil) {
|
|
40
|
+
obj = [@{
|
|
41
|
+
@"id" : la.liveActivityId,
|
|
42
|
+
@"createdAt": la.createdAt ?: @"",
|
|
43
|
+
@"updatedAt": la.updatedAt ?: @"",
|
|
44
|
+
@"applicationId": @(la.applicationId),
|
|
45
|
+
@"status" : la.status ?: @"",
|
|
46
|
+
@"iosChannelId" : la.iOSChannelId ?: @"",
|
|
47
|
+
|
|
48
|
+
} mutableCopy];
|
|
49
|
+
}
|
|
50
|
+
return ([obj copy]);
|
|
51
|
+
}
|
|
52
|
+
@end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//
|
|
2
|
+
// IndigitallLAPlugin.h
|
|
3
|
+
// IndigitallCapacitorPlugin
|
|
4
|
+
//
|
|
5
|
+
// Created by Guillermo Claros on 4/8/25.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#import <UIKit/UIKit.h>
|
|
9
|
+
|
|
10
|
+
//! Project version number for Plugin.
|
|
11
|
+
FOUNDATION_EXPORT double PluginVersionNumber;
|
|
12
|
+
|
|
13
|
+
//! Project version string for Plugin.
|
|
14
|
+
FOUNDATION_EXPORT const unsigned char PluginVersionString[];
|
|
15
|
+
|
|
16
|
+
// In this header, you should import all the public headers of your framework using statements like #import <Plugin/PublicHeader.h>
|
|
17
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//
|
|
2
|
+
// IndigitallLAPlugin.m
|
|
3
|
+
// IndigitallCapacitorPlugin
|
|
4
|
+
//
|
|
5
|
+
// Created by Guillermo Claros on 4/8/25.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#import <Foundation/Foundation.h>
|
|
9
|
+
#import <Capacitor/Capacitor.h>
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
CAP_PLUGIN(IndigitallCustomerPlugin, "LiveActivityCp",
|
|
13
|
+
CAP_PLUGIN_METHOD(logIn, CAPPluginReturnPromise);
|
|
14
|
+
CAP_PLUGIN_METHOD(logOut, CAPPluginReturnPromise);
|
|
15
|
+
CAP_PLUGIN_METHOD(getListEnabledLiveActivities, CAPPluginReturnPromise);
|
|
16
|
+
CAP_PLUGIN_METHOD(subscribeToLiveActivities, CAPPluginReturnPromise);
|
|
17
|
+
CAP_PLUGIN_METHOD(setPushToStartTokenUpdates, CAPPluginReturnPromise);
|
|
18
|
+
CAP_PLUGIN_METHOD(setPushTokenUpdates, CAPPluginReturnPromise);
|
|
19
|
+
)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//
|
|
2
|
+
// IndigitallParse.h
|
|
3
|
+
// Plugin
|
|
4
|
+
//
|
|
5
|
+
// Created by indigitall on 10/2/22.
|
|
6
|
+
// Copyright © 2022 Max Lynch. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#import <Foundation/Foundation.h>
|
|
10
|
+
#import <Indigitall/Indigitall.h>
|
|
11
|
+
|
|
12
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
13
|
+
|
|
14
|
+
@interface IndigitallParse : NSObject
|
|
15
|
+
|
|
16
|
+
+ (NSDictionary *)jsonFromDevice: (INDevice *)device;
|
|
17
|
+
+ (NSArray<NSDictionary *>*) jsonArrayFromtopics: (NSArray<INTopic *>*) topics;
|
|
18
|
+
+ (NSDictionary *)jsonFromInApp: (INInApp *)inApp;
|
|
19
|
+
+ (INInApp *)inAppFromJson: (NSDictionary *)json;
|
|
20
|
+
+ (NSDictionary *) jsonFromCustomer: (INCustomer *) customer;
|
|
21
|
+
+ (NSArray<NSDictionary *> *) jsonFromCustomerFields: (NSArray<INCustomerField *>*)customerFields;
|
|
22
|
+
+ (NSDictionary *) jsonFromMessagesCounter: (INInboxCounters *) inboxCounter;
|
|
23
|
+
+ (NSDictionary *) jsonFromInbox: (INInbox *) inbox newNotifications:(nullable NSArray<INInboxNotification *> *)newNotifications;
|
|
24
|
+
+ (NSArray<NSDictionary *>*) jsonArrayFromInboxNotification: (nullable NSArray<INInboxNotification *>*) inboxNotifications;
|
|
25
|
+
+ (INInApp *) parseInAppFromJson: (NSDictionary * )json;
|
|
26
|
+
+ (NSDictionary *)jsonFromInAppShow: (INInApp *_Nullable)inApp withError: (INError *) error ;
|
|
27
|
+
+ (NSDictionary *)jsonFromInAppShow: (INInAppShow *)inAppShow;
|
|
28
|
+
+ (NSDictionary *)jsonFromInAppProperties: (INInAppProperties *)properties;
|
|
29
|
+
+ (NSDictionary *)jsonFromAction: (INCoreAction *)action;
|
|
30
|
+
@end
|
|
31
|
+
|
|
32
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,469 @@
|
|
|
1
|
+
//
|
|
2
|
+
// IndigitallParse.m
|
|
3
|
+
// Plugin
|
|
4
|
+
//
|
|
5
|
+
// Created by indigitall on 10/2/22.
|
|
6
|
+
// Copyright © 2022 Max Lynch. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#import "IndigitallParse.h"
|
|
10
|
+
|
|
11
|
+
@implementation IndigitallParse
|
|
12
|
+
|
|
13
|
+
+ (NSDictionary *)jsonFromDevice: (INDevice *)device{
|
|
14
|
+
NSMutableDictionary *obj = [[NSMutableDictionary alloc]init];
|
|
15
|
+
if (device != nil) {
|
|
16
|
+
|
|
17
|
+
obj = [@{
|
|
18
|
+
@"enable" : device.enabled,
|
|
19
|
+
@"deviceId": device.deviceID ?: @"",
|
|
20
|
+
@"pushToken" : device.pushToken ?: @"",
|
|
21
|
+
@"platform": device.platform ?: @"",
|
|
22
|
+
@"version": device.sdkVersion ?: @"",
|
|
23
|
+
@"productName" : device.productName ?: @"",
|
|
24
|
+
@"productVersion" : device.productVersion ?: @"",
|
|
25
|
+
@"osName": device.osName ?: @"",
|
|
26
|
+
@"osVersion": device.osVersion ?: @"",
|
|
27
|
+
@"deviceBrand": device.deviceBrand ?: @"",
|
|
28
|
+
@"deviceModel": device.deviceModel ?: @"",
|
|
29
|
+
@"operator": device.carrier ?: @"",
|
|
30
|
+
@"deviceType": device.deviceType ?: @"",
|
|
31
|
+
@"appVersion": device.appVersion ?: @"",
|
|
32
|
+
@"locale": device.locale ?: @"",
|
|
33
|
+
@"timeZone": device.timeZone ?: @"",
|
|
34
|
+
@"timeOffset": @(device.timeOffset) ?: 0L,
|
|
35
|
+
@"externalApps": [self jsonArrayFromExternalApps: device.externalApplications],
|
|
36
|
+
@"externalCode": device.externalCode ?: @"",
|
|
37
|
+
} mutableCopy];
|
|
38
|
+
}
|
|
39
|
+
return [obj mutableCopy];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
+ (NSArray<NSDictionary *>*) jsonArrayFromExternalApps: (NSArray<INCoreExternalApp *>*)externalApps{
|
|
43
|
+
NSArray<NSDictionary *>* array = [NSArray new];
|
|
44
|
+
@try{
|
|
45
|
+
if (externalApps != nil){
|
|
46
|
+
for (int i=0;i<externalApps.count;i++){
|
|
47
|
+
NSDictionary *obj = [[NSDictionary alloc]init];
|
|
48
|
+
obj = @{
|
|
49
|
+
@"id" : @(externalApps[i].iNExternalAppId) ?: 0,
|
|
50
|
+
@"name": externalApps[i].name ?: @"",
|
|
51
|
+
@"code" : externalApps[i].iosCode ?: @"",
|
|
52
|
+
};
|
|
53
|
+
array = [array arrayByAddingObject:obj];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
} @catch (NSException *exception) {
|
|
57
|
+
NSLog(@"Error jsonArrayFromExternalApps ");
|
|
58
|
+
}
|
|
59
|
+
return array;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
+ (NSArray<NSDictionary *>*) jsonArrayFromtopics: (NSArray<INTopic *>*) topics{
|
|
63
|
+
NSArray<NSDictionary *>* array = [NSArray new];
|
|
64
|
+
@try{
|
|
65
|
+
for (int i=0;i<topics.count;i++){
|
|
66
|
+
NSDictionary *obj = [[NSDictionary alloc]init];
|
|
67
|
+
obj = @{
|
|
68
|
+
@"code" : topics[i].code ?: @"",
|
|
69
|
+
@"name": topics[i].name ?: @"",
|
|
70
|
+
@"parentCode" : topics[i].parentCode ?: @"",
|
|
71
|
+
@"visible" :@(topics[i].visible) ?: false,
|
|
72
|
+
@"channel" :@(topics[i].channel) ?: @"push",
|
|
73
|
+
@"subscribed" :@(topics[i].subscribed) ?: false
|
|
74
|
+
};
|
|
75
|
+
array = [array arrayByAddingObject:obj];
|
|
76
|
+
|
|
77
|
+
}
|
|
78
|
+
} @catch (NSException *exception) {
|
|
79
|
+
NSLog(@"Error jsonArrayFromtopics %@", exception);
|
|
80
|
+
}
|
|
81
|
+
return array;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
+ (INInApp *)inAppFromJson: (NSDictionary *)json {
|
|
85
|
+
INInApp *inApp = [[INInApp alloc]init];
|
|
86
|
+
if ([json objectForKey:@"inAppId"]) { inApp.inAppId = [[json objectForKey:@"inAppId"]intValue]; }
|
|
87
|
+
|
|
88
|
+
if ([json objectForKey:@"creationDate"]) { inApp.creationDate = [json objectForKey:@"creationDate"]; }
|
|
89
|
+
if ([json objectForKey:@"schema"]) {
|
|
90
|
+
NSDictionary *schema = [json objectForKey:@"schema"];
|
|
91
|
+
if ([schema objectForKey:@"code"]) { inApp.code = [schema objectForKey:@"code"]; }
|
|
92
|
+
if ([schema objectForKey:@"width"]) { inApp.inAppHeight = [[schema objectForKey:@"width"]intValue]; }
|
|
93
|
+
if ([schema objectForKey:@"height"]) { inApp.inAppWidth = [[schema objectForKey:@"height"]intValue]; }
|
|
94
|
+
}
|
|
95
|
+
if ([json objectForKey:@"properties"]) {
|
|
96
|
+
NSDictionary *properties = [json objectForKey:@"properties"];
|
|
97
|
+
inApp.properties = [[INInAppProperties alloc]init];
|
|
98
|
+
if ([properties objectForKey:@"numberOfClicks"]) { inApp.properties.numberOfClicks = [[properties objectForKey:@"numberOfClicks"]intValue]; }
|
|
99
|
+
if ([properties objectForKey:@"numberOfShows"]) { inApp.properties.numberOfShows = [[properties objectForKey:@"numberOfShows"]intValue]; }
|
|
100
|
+
if ([properties objectForKey:@"contentUrl"]) { inApp.properties.InAppContentUrl = [NSURL URLWithString:[properties objectForKey:@"contentUrl"]]; }
|
|
101
|
+
if ([properties objectForKey:@"dismissForever"] ) { inApp.properties.dismissForever = [[properties objectForKey:@"dismissForever"]boolValue]; }
|
|
102
|
+
inApp.properties.layout = [[INInAppLayout alloc]init];
|
|
103
|
+
if ([properties objectForKey:@"borderRadius"]) { inApp.properties.layout.borderRadius = [[properties objectForKey:@"borderRadius"]intValue]; }
|
|
104
|
+
if ([properties objectForKey:@"layout"]) {
|
|
105
|
+
NSDictionary *layout = [properties objectForKey:@"layout"];
|
|
106
|
+
if ([layout objectForKey:@"borderRadius"]) { inApp.properties.layout.borderRadius = [[properties objectForKey:@"borderRadius"]intValue]; }
|
|
107
|
+
|
|
108
|
+
}
|
|
109
|
+
if ([properties objectForKey:@"action"]) {
|
|
110
|
+
inApp.properties.action = [[INInAppAction alloc]init];
|
|
111
|
+
NSDictionary *actions = [properties objectForKey:@"action"];
|
|
112
|
+
if ([actions objectForKey:@"app"]) { inApp.properties.action.app = [actions objectForKey:@"app"]; }
|
|
113
|
+
if ([actions objectForKey:@"share"]) { inApp.properties.action.share = [actions objectForKey:@"share"]; }
|
|
114
|
+
if ([actions objectForKey:@"call"]) { inApp.properties.action.call = [actions objectForKey:@"call"]; }
|
|
115
|
+
if ([actions objectForKey:@"wallet"]) { inApp.properties.action.wallet = [actions objectForKey:@"wallet"]; }
|
|
116
|
+
if ([actions objectForKey:@"url"]) { inApp.properties.action.url = [actions objectForKey:@"url"]; }
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if ([json objectForKey:@"expiredDate"]) { inApp.expiredDate = [json objectForKey:@"expiredDate"]; }
|
|
121
|
+
if ([json objectForKey:@"showOnce"]) { inApp.showOnce = [[json objectForKey:@"showOnce"]boolValue]; }
|
|
122
|
+
if ([json objectForKey:@"lastVersionId"]) { inApp.lastVersionId = [[json objectForKey:@"lastVersionId"]intValue]; }
|
|
123
|
+
return inApp;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
+ (NSDictionary *)jsonFromAction: (INCoreAction *)action{
|
|
128
|
+
NSMutableDictionary *obj = [[NSMutableDictionary alloc]init];
|
|
129
|
+
if (action != nil) {
|
|
130
|
+
obj = [@{
|
|
131
|
+
@"app" : action.app ?: @"",
|
|
132
|
+
@"url": action.url ?: @"",
|
|
133
|
+
@"share" : action.share ?: @"",
|
|
134
|
+
@"call": action.call ?: @"",
|
|
135
|
+
@"market": action.market ?: @"",
|
|
136
|
+
@"noAction" : action.noAction ?: @"",
|
|
137
|
+
@"wallet" : action.wallet ?: @"",
|
|
138
|
+
@"webview" : action.webview ?: @"",
|
|
139
|
+
@"type" : @(action.type),
|
|
140
|
+
// TODO: añadir aquí?
|
|
141
|
+
} mutableCopy];
|
|
142
|
+
}
|
|
143
|
+
return [obj mutableCopy];
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
+ (NSDictionary *) jsonFromCustomer: (INCustomer *) customer{
|
|
147
|
+
NSMutableDictionary *obj = [[NSMutableDictionary alloc]init];
|
|
148
|
+
if (customer != nil) {
|
|
149
|
+
obj = [@{
|
|
150
|
+
@"id" : customer.customerId ?: @"",
|
|
151
|
+
@"customerId": customer.customerId ?: @"",
|
|
152
|
+
@"applicationId" : customer.applicationId ?: @"",
|
|
153
|
+
@"createdAt": customer.createdAt ?: @"",
|
|
154
|
+
@"updatedAt": customer.updatedAt ?: @""
|
|
155
|
+
} mutableCopy];
|
|
156
|
+
}
|
|
157
|
+
return [obj copy];
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
+ (NSArray<NSDictionary *> *) jsonFromCustomerFields: (NSArray<INCustomerField *>*)customerFields{
|
|
161
|
+
NSMutableArray<NSDictionary *> *array = [[NSMutableArray alloc]init];
|
|
162
|
+
for (int i = 0; i < customerFields.count; i++) {
|
|
163
|
+
if (customerFields[i].customerFieldKey && customerFields[i].customerFieldValue){
|
|
164
|
+
NSMutableDictionary *obj = [[NSMutableDictionary alloc]init];
|
|
165
|
+
obj = [@{
|
|
166
|
+
customerFields[i].customerFieldKey : customerFields[i].customerFieldValue,
|
|
167
|
+
} mutableCopy];
|
|
168
|
+
[array addObject:[obj copy]];
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return [array copy];
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
+ (NSDictionary *) jsonFromMessagesCounter: (INInboxCounters *) inboxCounter{
|
|
176
|
+
NSMutableDictionary *obj = [[NSMutableDictionary alloc]init];
|
|
177
|
+
if (inboxCounter != nil) {
|
|
178
|
+
obj = [@{
|
|
179
|
+
@"click" : @(inboxCounter.click) ?: 0,
|
|
180
|
+
@"sent": @(inboxCounter.sent) ?: 0,
|
|
181
|
+
@"deleted" : @(inboxCounter.deleted) ?: 0,
|
|
182
|
+
@"lastAccess": inboxCounter.unread.lastAccess ?: @"",
|
|
183
|
+
@"count": @(inboxCounter.unread.count) ?: 0
|
|
184
|
+
} mutableCopy];
|
|
185
|
+
}
|
|
186
|
+
return [obj mutableCopy];
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
+ (NSDictionary *) jsonFromInbox: (INInbox *) inbox newNotifications:(nullable NSArray<INInboxNotification *> *)newNotifications {
|
|
190
|
+
NSMutableDictionary *obj = [[NSMutableDictionary alloc]init];
|
|
191
|
+
if (inbox != nil) {
|
|
192
|
+
|
|
193
|
+
obj = [@{
|
|
194
|
+
@"lastAccess" : inbox.lastAccess ?: @"",
|
|
195
|
+
@"count": @(inbox.count) ?: 0,
|
|
196
|
+
@"pageSize" : inbox.pageSize ?: 0,
|
|
197
|
+
@"numPage": inbox.page ?: 0,
|
|
198
|
+
@"notifications": [self jsonArrayFromInboxNotification: inbox.notifications] ?:@"",
|
|
199
|
+
@"newNotifications": [self jsonArrayFromInboxNotification: newNotifications] ?:@""
|
|
200
|
+
} mutableCopy];
|
|
201
|
+
}
|
|
202
|
+
return [obj mutableCopy];
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
+ (NSArray<NSDictionary *>*) jsonArrayFromInboxNotification: (nullable NSArray<INInboxNotification *>*) inboxNotifications{
|
|
206
|
+
NSArray<NSDictionary *>* array = [NSArray new];
|
|
207
|
+
if (inboxNotifications) {
|
|
208
|
+
@try{
|
|
209
|
+
for (int i=0;i<inboxNotifications.count;i++){
|
|
210
|
+
NSDictionary *obj = [[NSDictionary alloc]init];
|
|
211
|
+
obj = @{
|
|
212
|
+
@"id" : inboxNotifications[i].idInboxNotification ?: @"",
|
|
213
|
+
@"sentAt": inboxNotifications[i].sentAt ?: @"",
|
|
214
|
+
@"status" : inboxNotifications[i].inboxStatus ?: INInboxStatus.SENT,
|
|
215
|
+
@"sendingId" :inboxNotifications[i].sendingId ?: 0,
|
|
216
|
+
@"campaignId" :inboxNotifications[i].campaignId ?: 0,
|
|
217
|
+
@"message" :[self jsonFromPush:inboxNotifications[i].message]?:@"",
|
|
218
|
+
@"category" :[self jsonFromCategory:inboxNotifications[i].category]?:@""
|
|
219
|
+
};
|
|
220
|
+
if (obj != nil) array = [array arrayByAddingObject:obj];
|
|
221
|
+
|
|
222
|
+
}
|
|
223
|
+
} @catch (NSException *exception) {
|
|
224
|
+
NSLog(@"Error jsonArrayFromInboxNotification %@", exception);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return array;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
+ (NSDictionary *) jsonFromCategory: (INInboxCategory *) category{
|
|
231
|
+
NSMutableDictionary *obj = [[NSMutableDictionary alloc]init];
|
|
232
|
+
if (category != nil) {
|
|
233
|
+
obj = [@{
|
|
234
|
+
@"id" : @(category.idCategory) ?: 0,
|
|
235
|
+
@"name": category.name ?: @"",
|
|
236
|
+
@"code": category.code ?: @""
|
|
237
|
+
} mutableCopy];
|
|
238
|
+
}
|
|
239
|
+
return [obj mutableCopy];
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
+ (NSDictionary *) jsonFromPush: (INPush *) message{
|
|
243
|
+
NSMutableDictionary *obj = [[NSMutableDictionary alloc]init];
|
|
244
|
+
if (message != nil) {
|
|
245
|
+
|
|
246
|
+
obj = [@{
|
|
247
|
+
@"title" : message.title ?: @"",
|
|
248
|
+
@"body": message.body ?: @"",
|
|
249
|
+
@"image": message.image ?: @"",
|
|
250
|
+
@"gif": message.gif ?: @"",
|
|
251
|
+
@"action": [self jsonFromPushAction:message.action] ?: @"",
|
|
252
|
+
@"buttons": [self jsonArrayFromPushButtons:message.buttons] ?: @"",
|
|
253
|
+
@"data": message.data ?: @"",
|
|
254
|
+
@"securedData": message.securedData ?: @""
|
|
255
|
+
|
|
256
|
+
} mutableCopy];
|
|
257
|
+
}
|
|
258
|
+
return [obj mutableCopy];
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
+ (NSDictionary *) jsonFromPushAction: (INPushAction *) action{
|
|
262
|
+
NSMutableDictionary *obj = [[NSMutableDictionary alloc]init];
|
|
263
|
+
if (action != nil) {
|
|
264
|
+
if (action.app) [obj setValue:action.app forKey:@"app"];
|
|
265
|
+
if (action.url) [obj setValue:action.url forKey:@"url"];
|
|
266
|
+
if (action.share) [obj setValue:action.share forKey:@"share"];
|
|
267
|
+
if (action.call) [obj setValue:action.call forKey:@"call"];
|
|
268
|
+
if (action.market) [obj setValue:action.market forKey:@"market"];
|
|
269
|
+
if (action.noAction) [obj setValue:action.noAction forKey:@"noAction"];
|
|
270
|
+
if (action.wallet) [obj setValue:action.wallet forKey:@"wallet"];
|
|
271
|
+
if (action.webview) [obj setValue:action.webview forKey:@"webview"];
|
|
272
|
+
if (action.type) [obj setValue:@(action.type) forKey:@"type"];
|
|
273
|
+
}
|
|
274
|
+
return [obj copy];
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
+ (NSArray<NSDictionary *>*) jsonArrayFromPushButtons: (NSArray<INPushButton *>*) buttons{
|
|
278
|
+
NSArray<NSDictionary *>* array = [NSArray new];
|
|
279
|
+
@try{
|
|
280
|
+
if (buttons != nil){
|
|
281
|
+
for (int i=0;i<buttons.count;i++){
|
|
282
|
+
NSDictionary *obj = [[NSDictionary alloc]init];
|
|
283
|
+
obj = @{
|
|
284
|
+
@"label" : buttons[i].label ?: @"",
|
|
285
|
+
@"action": [self jsonFromPushAction: buttons[i].action] ?:@""
|
|
286
|
+
};
|
|
287
|
+
if (obj != nil) array = [array arrayByAddingObject:obj];
|
|
288
|
+
|
|
289
|
+
}
|
|
290
|
+
}else{
|
|
291
|
+
return nil;
|
|
292
|
+
}
|
|
293
|
+
} @catch (NSException *exception) {
|
|
294
|
+
NSLog(@"Error jsonArrayFromPushButtons %@", exception);
|
|
295
|
+
}
|
|
296
|
+
return array;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
+ (NSDictionary *)jsonFromInAppShow: (INInApp *_Nullable)inApp withError: (INError *) error {
|
|
300
|
+
NSMutableDictionary * obj = [NSMutableDictionary new];
|
|
301
|
+
if (inApp != nil) {
|
|
302
|
+
obj = [@{
|
|
303
|
+
@"inApp" : [self jsonFromInApp:inApp],
|
|
304
|
+
@"errorCode": @(error.errorCode),
|
|
305
|
+
@"errorMessage" : error.message ?: @"",
|
|
306
|
+
} mutableCopy];
|
|
307
|
+
} else {
|
|
308
|
+
obj = [@{
|
|
309
|
+
@"errorCode": @(error.errorCode),
|
|
310
|
+
@"errorMessage" : error.message ?: @"",
|
|
311
|
+
} mutableCopy];
|
|
312
|
+
}
|
|
313
|
+
return obj;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
+ (NSDictionary *)jsonFromInApp: (INInApp *)inApp{
|
|
317
|
+
NSMutableDictionary *obj = [[NSMutableDictionary alloc]init];
|
|
318
|
+
if (inApp != nil) {
|
|
319
|
+
|
|
320
|
+
[obj setValue:@(inApp.inAppId) forKey:@"inAppId"];
|
|
321
|
+
if (inApp.inAppWidth != 0) [obj setValue:@(inApp.inAppWidth) forKey:@"inAppWidth"];
|
|
322
|
+
if (inApp.inAppHeight != 0) [obj setValue:@(inApp.inAppHeight) forKey:@"inAppHeight"];
|
|
323
|
+
if (inApp.lastVersionId != 0) [obj setValue:@(inApp.lastVersionId) forKey:@"lastVersionId"];
|
|
324
|
+
if (inApp.code != nil) [obj setValue:inApp.code forKey:@"code"];
|
|
325
|
+
if (inApp.properties != nil) [obj setValue:[self jsonFromInAppProperties:inApp.properties] forKey:@"properties"];
|
|
326
|
+
if (inApp.inAppShow != nil) [obj setValue:[self jsonFromInAppShow: inApp.inAppShow] forKey:@"inAppShow"];
|
|
327
|
+
if (inApp.showOnce) [obj setValue:@(inApp.showOnce) forKey:@"showOnce"];
|
|
328
|
+
if (inApp.expiredDate != nil) [obj setValue:inApp.expiredDate forKey:@"expiredDate"];
|
|
329
|
+
if (inApp.creationDate != nil) [obj setValue:inApp.creationDate forKey:@"creationDate"];
|
|
330
|
+
if (inApp.cacheTtl != 0) [obj setValue:@(inApp.cacheTtl) forKey:@"cacheTtl"];
|
|
331
|
+
if (inApp.customData != nil) [obj setValue:inApp.customData forKey:@"customData"];
|
|
332
|
+
if (inApp.version != 0) [obj setValue:@(inApp.version) forKey:@"version"];
|
|
333
|
+
if (inApp.filters != nil) [obj setValue:[self jsonFromInAppFilters: inApp.filters] forKey:@"filters"];
|
|
334
|
+
if (inApp.name != nil) [obj setValue:inApp.name forKey:@"name"];
|
|
335
|
+
|
|
336
|
+
}
|
|
337
|
+
return [obj copy];
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
NSString *JSON_INAPP_FILTERS = @"filters";
|
|
341
|
+
NSString *JSON_INAPP_NAME = @"name";
|
|
342
|
+
NSString *JSON_INAPP_VERSION = @"inAppVersion";
|
|
343
|
+
+ (INInApp *) parseInAppFromJson: (NSDictionary * )json {
|
|
344
|
+
INInApp *inApp = [INInApp new];
|
|
345
|
+
if ([json objectForKey:INInAppAPIConstants.inAppId]){
|
|
346
|
+
inApp.inAppId = [[json objectForKey:INInAppAPIConstants.inAppId]intValue] ;
|
|
347
|
+
}
|
|
348
|
+
//TODO: borrar showOnce de modelo y InAppUtils cuando desaparezca esta opción del panel
|
|
349
|
+
if ([json objectForKey:INInAppAPIConstants.showOnce]){
|
|
350
|
+
inApp.showOnce = [[json objectForKey:INInAppAPIConstants.showOnce]boolValue];
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
if ([json objectForKey:INInAppAPIConstants.CREATION_DATE]){
|
|
354
|
+
inApp.creationDate = [[json objectForKey:INInAppAPIConstants.CREATION_DATE]stringValue];
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
if ([json objectForKey:INInAppAPIConstants.EXPIRED_DATE]){
|
|
358
|
+
inApp.expiredDate = [[json objectForKey:INInAppAPIConstants.EXPIRED_DATE]stringValue];
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
if ([json objectForKey:INInAppAPIConstants.LAST_VERSION_ID]){
|
|
362
|
+
inApp.lastVersionId = [[json objectForKey:INInAppAPIConstants.LAST_VERSION_ID]intValue];
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
if ([json objectForKey:INInAppAPIConstants.CACHE_Ttl]){
|
|
366
|
+
inApp.cacheTtl = [[json objectForKey:INInAppAPIConstants.CACHE_Ttl]doubleValue];
|
|
367
|
+
} else {
|
|
368
|
+
inApp.cacheTtl = 60 * 60;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
if ([json objectForKey:INInAppAPIConstants.properties] ){
|
|
372
|
+
inApp.properties = [[INInAppProperties alloc]initWithJson:[json objectForKey:INInAppAPIConstants.properties]];
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
if ([json objectForKey:INInAppAPIConstants.INAPP_SHOW] ){
|
|
376
|
+
inApp.inAppShow = [[INInAppShow alloc]initWithNSDictionary:[json objectForKey:INInAppAPIConstants.INAPP_SHOW]];
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
if ([json objectForKey:INInAppAPIConstants.INAPP_VERSION]){
|
|
380
|
+
inApp.version = [[json objectForKey:INInAppAPIConstants.INAPP_VERSION]intValue];
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
if ([json objectForKey:INInAppAPIConstants.INAPP_CUSTOM_DATA] &&
|
|
384
|
+
![[json objectForKey:INInAppAPIConstants.INAPP_CUSTOM_DATA]isEqual:@""] ){
|
|
385
|
+
id customDataData = [json objectForKey:INInAppAPIConstants.INAPP_CUSTOM_DATA];
|
|
386
|
+
NSMutableDictionary *dicCustomData = [NSMutableDictionary new];
|
|
387
|
+
if ([customDataData isKindOfClass:[NSString class]]) {
|
|
388
|
+
NSString * stringCustomData = customDataData;
|
|
389
|
+
NSData *data = [stringCustomData dataUsingEncoding:NSUTF8StringEncoding];
|
|
390
|
+
id json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
|
|
391
|
+
dicCustomData = json;
|
|
392
|
+
} else {
|
|
393
|
+
dicCustomData = [customDataData copy];
|
|
394
|
+
}
|
|
395
|
+
inApp.customData = dicCustomData;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
NSDictionary *schema = [json objectForKey:INInAppAPIConstants.schema];
|
|
399
|
+
if (schema != nil){
|
|
400
|
+
inApp.code = [schema objectForKey:INInAppAPIConstants.code];
|
|
401
|
+
if (inApp.code){
|
|
402
|
+
inApp.inAppWidth = [[schema objectForKey:INInAppAPIConstants.width] intValue];
|
|
403
|
+
inApp.inAppHeight = [[schema objectForKey:INInAppAPIConstants.height] intValue];
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
if ([json objectForKey:JSON_INAPP_FILTERS]){
|
|
408
|
+
if ([[json objectForKey:JSON_INAPP_FILTERS] isKindOfClass:[NSString class]]){
|
|
409
|
+
inApp.filters = [[INInAppFilters alloc]initWithJson: [INCoreUtils toNSDictionary:[[json objectForKey:JSON_INAPP_FILTERS]stringValue]]];
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
if ([json objectForKey:JSON_INAPP_NAME]){
|
|
413
|
+
inApp.name = [[json objectForKey:JSON_INAPP_NAME]stringValue];
|
|
414
|
+
}
|
|
415
|
+
if ([json objectForKey:JSON_INAPP_VERSION]) {
|
|
416
|
+
inApp.inAppVersion = [[json objectForKey:JSON_INAPP_VERSION]intValue];
|
|
417
|
+
} else {
|
|
418
|
+
inApp.inAppVersion = inApp.version;
|
|
419
|
+
}
|
|
420
|
+
return inApp;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
+ (NSDictionary *)jsonFromInAppFilters: (INInAppFilters *) filters {
|
|
424
|
+
NSMutableDictionary *obj = [[NSMutableDictionary alloc]init];
|
|
425
|
+
if (filters != nil) {
|
|
426
|
+
obj = [@{
|
|
427
|
+
@"platforms" : filters.platforms?: @"",
|
|
428
|
+
@"areas": filters.areas?: @"",
|
|
429
|
+
@"audience" : filters.audience?: @"",
|
|
430
|
+
@"topics": filters.topics.toJson ?: @"",
|
|
431
|
+
@"externalApps": filters.externalApps ?: @"",
|
|
432
|
+
@"deviceCodes" : filters.deviceCodes?: @"",
|
|
433
|
+
@"deviceCodesActive" : @(filters.deviceCodesActive) ?: false,
|
|
434
|
+
@"deviceTypes": filters.deviceTypes?: @"",
|
|
435
|
+
@"browserTypes" : filters.browserTypes?: @"",
|
|
436
|
+
@"activePushDevices" : @(filters.activePushDevices) ?: false
|
|
437
|
+
} mutableCopy];
|
|
438
|
+
}
|
|
439
|
+
return obj;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
+ (NSDictionary *)jsonFromInAppShow: (INInAppShow *)inAppShow{
|
|
443
|
+
NSMutableDictionary *obj = [[NSMutableDictionary alloc]init];
|
|
444
|
+
if (inAppShow != nil) {
|
|
445
|
+
obj = [@{
|
|
446
|
+
@"wasDismissed" : @(inAppShow.wasDismissed),
|
|
447
|
+
@"timesShowed": @(inAppShow.timesShowed),
|
|
448
|
+
@"timesClicked" : @(inAppShow.timesClicked)
|
|
449
|
+
} mutableCopy];
|
|
450
|
+
}
|
|
451
|
+
return [obj mutableCopy];
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
+ (NSDictionary *)jsonFromInAppProperties: (INInAppProperties *)properties{
|
|
455
|
+
NSMutableDictionary *obj = [[NSMutableDictionary alloc]init];
|
|
456
|
+
if (properties != nil) {
|
|
457
|
+
obj = [@{
|
|
458
|
+
@"contentUrl" : properties.InAppContentUrl.absoluteString ?: @"",
|
|
459
|
+
@"numberOfShows": @(properties.numberOfShows),
|
|
460
|
+
@"numberOfClicks" : @(properties.numberOfClicks),
|
|
461
|
+
@"dismissForever": @(properties.dismissForever),
|
|
462
|
+
@"showTime": @(properties.showTime),
|
|
463
|
+
@"action" : [self jsonFromAction:properties.action],
|
|
464
|
+
@"borderRadius" : @(properties.layout.borderRadius),
|
|
465
|
+
} mutableCopy];
|
|
466
|
+
}
|
|
467
|
+
return [obj mutableCopy];
|
|
468
|
+
}
|
|
469
|
+
@end
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "indigitall-capacitor-plugin",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Capacitor Indigitall Plugin",
|
|
6
6
|
"main": "dist/plugin.cjs.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"android/build.gradle",
|
|
13
13
|
"dist/",
|
|
14
14
|
"ios/Plugin/",
|
|
15
|
-
"ObjC/",
|
|
15
|
+
"ios/ObjC/",
|
|
16
16
|
"Package.swift"
|
|
17
17
|
],
|
|
18
18
|
"author": "sdk@indigitall.com",
|