cordova-plugin-insider 1.2.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/.github/CODEOWNERS +8 -0
- package/.github/workflows/git-leak.yml +25 -0
- package/.github/workflows/insider-cordova-SDK_release.yml +61 -0
- package/.github/workflows/release_task_merger.yml +22 -0
- package/.github/workflows/release_version_setter.yml +43 -0
- package/README.md +104 -0
- package/hooks/FSUtils.js +28 -0
- package/hooks/after_plugin_install.js +81 -0
- package/hooks/before_plugin_uninstall.js +49 -0
- package/package.json +19 -0
- package/plugin.xml +91 -0
- package/release_version.sh +27 -0
- package/slack_notifier.sh +20 -0
- package/src/android/CDVUtils.java +120 -0
- package/src/android/Constants.java +41 -0
- package/src/android/InsiderPlugin.java +814 -0
- package/src/android/build-extras.gradle +38 -0
- package/src/android/res/values/dimens.xml +4 -0
- package/src/android/res/values-sw600dp/dimens.xml +3 -0
- package/src/android/res/values-sw720dp/dimens.xml +3 -0
- package/src/android/res/values-xhdpi/dimens.xml +4 -0
- package/src/android/res/values-xxhdpi/dimens.xml +4 -0
- package/src/android/res/values-xxxhdpi/dimens.xml +4 -0
- package/src/ios/IDFAHelper.h +7 -0
- package/src/ios/IDFAHelper.m +19 -0
- package/src/ios/InsiderPlugin.h +58 -0
- package/src/ios/InsiderPlugin.m +758 -0
- package/types/CallbackType.d.ts +7 -0
- package/types/ContentOptimizerDataType.d.ts +4 -0
- package/types/Event.d.ts +9 -0
- package/types/Gender.d.ts +5 -0
- package/types/Identifier.d.ts +7 -0
- package/types/InsiderPlugin.d.ts +51 -0
- package/types/Product.d.ts +18 -0
- package/types/User.d.ts +27 -0
- package/www/CallbackType.js +7 -0
- package/www/Constants.js +86 -0
- package/www/ContentOptimizerDataType.js +4 -0
- package/www/Event.js +96 -0
- package/www/Gender.js +5 -0
- package/www/Identifier.js +66 -0
- package/www/InsiderPlugin.js +364 -0
- package/www/Product.js +211 -0
- package/www/User.js +303 -0
- package/www/Utils.js +18 -0
|
@@ -0,0 +1,758 @@
|
|
|
1
|
+
#import <Cordova/CDV.h>
|
|
2
|
+
#import "InsiderPlugin.h"
|
|
3
|
+
|
|
4
|
+
@interface InsiderPlugin (){
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
@end
|
|
8
|
+
|
|
9
|
+
@implementation InsiderPlugin
|
|
10
|
+
|
|
11
|
+
- (void) pluginInitialize {
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
- (void) init:(CDVInvokedUrlCommand *)command {
|
|
15
|
+
@try {
|
|
16
|
+
if (![command.arguments objectAtIndex:0] || ![command.arguments objectAtIndex:1] || ![command.arguments objectAtIndex:2])
|
|
17
|
+
return;
|
|
18
|
+
[self.commandDelegate runInBackground:^{
|
|
19
|
+
NSString* partnerName = [[command arguments] objectAtIndex:0];
|
|
20
|
+
NSString* appGroup = [[command arguments] objectAtIndex:1];
|
|
21
|
+
[Insider initWithLaunchOptions:nil partnerName:partnerName appGroup:appGroup];
|
|
22
|
+
[self sendSuccessResultWithString:@"Insider Cordova Plugin: Initialized" andCommand:command];
|
|
23
|
+
}];
|
|
24
|
+
} @catch (NSException *exception) {
|
|
25
|
+
[Insider sendError:exception desc:@"Insider.m - init"];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
- (void)initWithLaunchOptions:(CDVInvokedUrlCommand *)command {
|
|
31
|
+
@try{
|
|
32
|
+
if (![command.arguments objectAtIndex:0] || ![command.arguments objectAtIndex:1] || ![command.arguments objectAtIndex:2])
|
|
33
|
+
return;
|
|
34
|
+
|
|
35
|
+
[self.commandDelegate runInBackground:^{
|
|
36
|
+
[Insider registerInsiderCallbackWithSelector:@selector(registerCallback:) sender:self];
|
|
37
|
+
[Insider setHybridSDKVersion:[command.arguments objectAtIndex:1]];
|
|
38
|
+
[Insider initWithLaunchOptions:nil partnerName:[command.arguments objectAtIndex:0] appGroup:[command.arguments objectAtIndex:2]];
|
|
39
|
+
[Insider resumeSession];
|
|
40
|
+
[self sendSuccessResultWithString:@"Insider Cordova Plugin: initWithLaunchOptions" andCommand:command];
|
|
41
|
+
}];
|
|
42
|
+
} @catch (NSException *exception){
|
|
43
|
+
[Insider sendError:exception desc:@"Insider Cordova Plugin - initWithLaunchOptions"];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
- (void)initWithCustomEndpoint:(CDVInvokedUrlCommand *)command {
|
|
48
|
+
@try{
|
|
49
|
+
if (![command.arguments objectAtIndex:0] || ![command.arguments objectAtIndex:1] || ![command.arguments objectAtIndex:2] || ![command.arguments objectAtIndex:3]) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
[self.commandDelegate runInBackground:^{
|
|
53
|
+
[Insider registerInsiderCallbackWithSelector:@selector(registerCallback:) sender:self];
|
|
54
|
+
[Insider setHybridSDKVersion:[command.arguments objectAtIndex:1]];
|
|
55
|
+
[Insider initWithLaunchOptions:nil partnerName:[command.arguments objectAtIndex:0] appGroup:[command.arguments objectAtIndex:2] customEndpoint:[command.arguments objectAtIndex:3]];
|
|
56
|
+
[Insider resumeSession];
|
|
57
|
+
[self sendSuccessResultWithString:@"Insider Cordova Plugin: initWithCustomEndpoint" andCommand:command];
|
|
58
|
+
}];
|
|
59
|
+
|
|
60
|
+
} @catch (NSException *exception){
|
|
61
|
+
[Insider sendError:exception desc:@"Insider Cordova Plugin.m - initWithCustomEndpoint"];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
-(void)registerCallback:(NSDictionary *)notfDict {
|
|
66
|
+
@try {
|
|
67
|
+
if (!notfDict || [notfDict count] == 0)
|
|
68
|
+
return;
|
|
69
|
+
InsiderCallbackType type = (InsiderCallbackType)[[notfDict objectForKey:@"type"] intValue];
|
|
70
|
+
NSString* notfData = [InsiderHybrid dictToJson:notfDict];
|
|
71
|
+
|
|
72
|
+
NSString *js;
|
|
73
|
+
switch (type) {
|
|
74
|
+
case InsiderCallbackTypeNotificationOpen:{
|
|
75
|
+
NSString * data = [NSString stringWithFormat:@"{""action"":'NOTIFICATION_OPEN',""result"":""%@""}", notfData];
|
|
76
|
+
js = [NSString stringWithFormat:@"cordova.fireDocumentEvent('ins_notification_handle',%@);", data];
|
|
77
|
+
[self.commandDelegate evalJs:js];
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
case InsiderCallbackTypeInappButtonClick:{
|
|
81
|
+
NSString * data = [NSString stringWithFormat:@"{""action"":'INAPP_BUTTON_CLICK',""result"":""%@""}", notfData];
|
|
82
|
+
js = [NSString stringWithFormat:@"cordova.fireDocumentEvent('ins_notification_handle',%@);", data];
|
|
83
|
+
[self.commandDelegate evalJs:js];
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
case InsiderCallbackTypeTempStorePurchase:{
|
|
87
|
+
NSString * data = [NSString stringWithFormat:@"{""action"":'TEMP_STORE_PURCHASE',""result"":""%@""}", notfData];
|
|
88
|
+
js = [NSString stringWithFormat:@"cordova.fireDocumentEvent('ins_notification_handle',%@);", data];
|
|
89
|
+
[self.commandDelegate evalJs:js];
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
case InsiderCallbackTypeTempStoreAddedToCart:{
|
|
93
|
+
NSString * data = [NSString stringWithFormat:@"{""action"":'TEMP_STORE_ADDED_TO_CART',""result"":""%@""}", notfData];
|
|
94
|
+
js = [NSString stringWithFormat:@"cordova.fireDocumentEvent('ins_notification_handle',%@);", data];
|
|
95
|
+
[self.commandDelegate evalJs:js];
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
case InsiderCallbackTypeTempStoreCustomAction:{
|
|
99
|
+
NSString * data = [NSString stringWithFormat:@"{""action"":'TEMP_STORE_CUSTOM_ACTION',""result"":""%@""}", notfData];
|
|
100
|
+
js = [NSString stringWithFormat:@"cordova.fireDocumentEvent('ins_notification_handle',%@);", data];
|
|
101
|
+
[self.commandDelegate evalJs:js];
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
default:
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
} @catch (NSException *e){
|
|
108
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
- (void) enableIDFACollection:(CDVInvokedUrlCommand *)command {
|
|
113
|
+
@try {
|
|
114
|
+
[self.commandDelegate runInBackground:^{
|
|
115
|
+
[[IDFAHelper alloc] requestPermission];
|
|
116
|
+
NSString* booleanValueByString = [[command arguments] objectAtIndex:0];
|
|
117
|
+
[Insider enableIDFACollection:[booleanValueByString isEqualToString: @"true"]];
|
|
118
|
+
[self sendSuccessResultWithString:@"SUCCESS" andCommand:command];
|
|
119
|
+
}];
|
|
120
|
+
} @catch (NSException *exception) {
|
|
121
|
+
[Insider sendError:exception desc:@"Insider.m - enableIDFACollection"];
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
- (void) setGDPRConsent:(CDVInvokedUrlCommand *)command {
|
|
127
|
+
@try {
|
|
128
|
+
[self.commandDelegate runInBackground:^{
|
|
129
|
+
NSString* booleanValueByString = [[command arguments] objectAtIndex:0];
|
|
130
|
+
[Insider setGDPRConsent:[booleanValueByString isEqualToString: @"true"]];
|
|
131
|
+
[self sendSuccessResultWithString:@"SUCCESS" andCommand:command];
|
|
132
|
+
}];
|
|
133
|
+
} @catch (NSException *exception) {
|
|
134
|
+
[Insider sendError:exception desc:@"Insider.m - setGDPRConsent"];
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
- (void) startTrackingGeofence:(CDVInvokedUrlCommand *)command {
|
|
139
|
+
@try {
|
|
140
|
+
[self.commandDelegate runInBackground:^{
|
|
141
|
+
[Insider startTrackingGeofence];
|
|
142
|
+
[self sendSuccessResultWithString:@"SUCCESS" andCommand:command];
|
|
143
|
+
}];
|
|
144
|
+
} @catch (NSException *exception) {
|
|
145
|
+
[Insider sendError:exception desc:@"Insider.m - startTrackingGeofence"];
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
- (void)registerWithQuietPermission:(CDVInvokedUrlCommand *)command {
|
|
150
|
+
@try {
|
|
151
|
+
if (![command.arguments objectAtIndex:0]) return;
|
|
152
|
+
[self.commandDelegate runInBackground:^{
|
|
153
|
+
[Insider registerWithQuietPermission:[[command.arguments objectAtIndex:0] boolValue]];
|
|
154
|
+
[self sendSuccessResultWithString:@"SUCCESS" andCommand:command];
|
|
155
|
+
}];
|
|
156
|
+
} @catch (NSException *e) {
|
|
157
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
- (void)enableCarrierCollection:(CDVInvokedUrlCommand *)command {
|
|
162
|
+
@try {
|
|
163
|
+
if (![command.arguments objectAtIndex:0]) return;
|
|
164
|
+
[self.commandDelegate runInBackground:^{
|
|
165
|
+
[Insider enableCarrierCollection:[[command.arguments objectAtIndex:0] boolValue]];
|
|
166
|
+
[self sendSuccessResultWithString:@"SUCCESS" andCommand:command];
|
|
167
|
+
}];
|
|
168
|
+
} @catch (NSException *e){
|
|
169
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
- (void)enableIpCollection:(CDVInvokedUrlCommand *)command {
|
|
174
|
+
@try {
|
|
175
|
+
if (![command.arguments objectAtIndex:0]) return;
|
|
176
|
+
[self.commandDelegate runInBackground:^{
|
|
177
|
+
[Insider enableIpCollection:[[command.arguments objectAtIndex:0] boolValue]];
|
|
178
|
+
[self sendSuccessResultWithString:@"SUCCESS" andCommand:command];
|
|
179
|
+
}];
|
|
180
|
+
} @catch (NSException *e){
|
|
181
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
- (void)enableLocationCollection:(CDVInvokedUrlCommand *)command {
|
|
186
|
+
@try {
|
|
187
|
+
if (![command.arguments objectAtIndex:0]) return;
|
|
188
|
+
[self.commandDelegate runInBackground:^{
|
|
189
|
+
[Insider enableLocationCollection:[[command.arguments objectAtIndex:0] boolValue]];
|
|
190
|
+
[self sendSuccessResultWithString:@"SUCCESS" andCommand:command];
|
|
191
|
+
}];
|
|
192
|
+
} @catch (NSException *e){
|
|
193
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
- (void) tagEvent:(CDVInvokedUrlCommand *)command {
|
|
199
|
+
@try {
|
|
200
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
201
|
+
NSString* eventName = [[command arguments] objectAtIndex:0];
|
|
202
|
+
NSDictionary* parameters = [[command arguments] objectAtIndex:1];
|
|
203
|
+
[[Insider tagEvent:eventName].addParameters(parameters) build];
|
|
204
|
+
[self sendSuccessResultWithString:@"SUCCESS" andCommand:command];
|
|
205
|
+
});
|
|
206
|
+
} @catch (NSException *exception) {
|
|
207
|
+
[Insider sendError:exception desc:@"Insider.m - tagEvent"];
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
- (void) removeInapp:(CDVInvokedUrlCommand *)command {
|
|
213
|
+
@try {
|
|
214
|
+
[self.commandDelegate runInBackground:^{
|
|
215
|
+
[Insider removeInapp];
|
|
216
|
+
}];
|
|
217
|
+
} @catch (NSException *exception) {
|
|
218
|
+
[Insider sendError:exception desc:@"Insider.m - tagEvent"];
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
- (void)hybridIntent:(CDVInvokedUrlCommand *)command {
|
|
224
|
+
@try {
|
|
225
|
+
[self.commandDelegate runInBackground:^{
|
|
226
|
+
[Insider resumeSession];
|
|
227
|
+
}];
|
|
228
|
+
} @catch (NSException *e) {
|
|
229
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
- (void)getContentStringWithName:(CDVInvokedUrlCommand *)command {
|
|
234
|
+
@try {
|
|
235
|
+
if (![command.arguments objectAtIndex:0] || ![command.arguments objectAtIndex:1] || ![command.arguments objectAtIndex:2]) return;
|
|
236
|
+
[self.commandDelegate runInBackground:^{
|
|
237
|
+
NSString *coResult = [Insider getContentStringWithName:[command.arguments objectAtIndex:0] defaultString:[command.arguments objectAtIndex:1] dataType:[[command.arguments objectAtIndex:2] intValue]];
|
|
238
|
+
[self sendSuccessResultWithString:coResult andCommand:command];
|
|
239
|
+
}];
|
|
240
|
+
} @catch (NSException *e) {
|
|
241
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
- (void)getContentIntWithName:(CDVInvokedUrlCommand *)command {
|
|
246
|
+
@try {
|
|
247
|
+
if (![command.arguments objectAtIndex:0] || ![command.arguments objectAtIndex:1] || ![command.arguments objectAtIndex:2]) return;
|
|
248
|
+
[self.commandDelegate runInBackground:^{
|
|
249
|
+
int coResult = [Insider getContentIntWithName:[command.arguments objectAtIndex:0] defaultInt:[[command.arguments objectAtIndex:1] intValue] dataType:[[command.arguments objectAtIndex:2] intValue]];
|
|
250
|
+
[self sendSuccessResultWithInt:coResult andCommand:command];
|
|
251
|
+
}];
|
|
252
|
+
} @catch (NSException *e) {
|
|
253
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
- (void)getContentBoolWithName:(CDVInvokedUrlCommand *)command {
|
|
258
|
+
@try {
|
|
259
|
+
if (![command.arguments objectAtIndex:0] || ![command.arguments objectAtIndex:1] || ![command.arguments objectAtIndex:2]) return;
|
|
260
|
+
[self.commandDelegate runInBackground:^{
|
|
261
|
+
bool coResult = [Insider getContentBoolWithName:[command.arguments objectAtIndex:0] defaultBool:[[command.arguments objectAtIndex:1] boolValue] dataType:[[command.arguments objectAtIndex:2] intValue]];
|
|
262
|
+
[self sendSuccessResultWithInt:coResult andCommand:command];
|
|
263
|
+
}];
|
|
264
|
+
} @catch (NSException *e) {
|
|
265
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
- (void)visitHomePage:(CDVInvokedUrlCommand *)command {
|
|
270
|
+
@try {
|
|
271
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
272
|
+
[Insider visitHomepage];
|
|
273
|
+
[self sendSuccessResultWithString:@"SUCCESS" andCommand:command];
|
|
274
|
+
});
|
|
275
|
+
} @catch (NSException *e) {
|
|
276
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
- (void)visitListingPage:(CDVInvokedUrlCommand *)command {
|
|
281
|
+
@try {
|
|
282
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
283
|
+
if (![command.arguments objectAtIndex:0]) return;
|
|
284
|
+
[Insider visitListingPageWithTaxonomy:[command.arguments objectAtIndex:0]];
|
|
285
|
+
[self sendSuccessResultWithString:@"SUCCESS" andCommand:command];
|
|
286
|
+
});
|
|
287
|
+
} @catch (NSException *e) {
|
|
288
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
- (void)visitProductDetailPage:(CDVInvokedUrlCommand *)command {
|
|
293
|
+
@try {
|
|
294
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
295
|
+
if (![command.arguments objectAtIndex:0] || ![command.arguments objectAtIndex:1]) return;
|
|
296
|
+
InsiderProduct* product = (InsiderProduct *)[InsiderHybrid createProduct:[command.arguments objectAtIndex:0] productOptMap:[command.arguments objectAtIndex:1]];
|
|
297
|
+
[Insider visitProductDetailPageWithProduct:product];
|
|
298
|
+
[self sendSuccessResultWithString:@"SUCCESS" andCommand:command];
|
|
299
|
+
});
|
|
300
|
+
} @catch (NSException *e) {
|
|
301
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
- (void)visitCartPage:(CDVInvokedUrlCommand *)command {
|
|
306
|
+
@try {
|
|
307
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
308
|
+
if (![command.arguments objectAtIndex:0]) return;
|
|
309
|
+
[InsiderHybrid visitCartPage:[command.arguments objectAtIndex:0]];
|
|
310
|
+
[self sendSuccessResultWithString:@"SUCCESS" andCommand:command];
|
|
311
|
+
});
|
|
312
|
+
} @catch (NSException *e) {
|
|
313
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
- (void)itemPurchased:(CDVInvokedUrlCommand *)command {
|
|
318
|
+
@try {
|
|
319
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
320
|
+
if (![command.arguments objectAtIndex:0] || ![command.arguments objectAtIndex:1] || ![command.arguments objectAtIndex:2]) return;
|
|
321
|
+
InsiderProduct *product = (InsiderProduct *)[InsiderHybrid createProduct:[command.arguments objectAtIndex:1] productOptMap:[command.arguments objectAtIndex:2]];
|
|
322
|
+
[Insider itemPurchasedWithSaleID:[command.arguments objectAtIndex:0] product:product];
|
|
323
|
+
[self sendSuccessResultWithString:@"SUCCESS" andCommand:command];
|
|
324
|
+
});
|
|
325
|
+
} @catch (NSException *e) {
|
|
326
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
- (void)itemAddedToCart:(CDVInvokedUrlCommand *)command {
|
|
331
|
+
@try {
|
|
332
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
333
|
+
if (![command.arguments objectAtIndex:0] || ![command.arguments objectAtIndex:1]) return;
|
|
334
|
+
InsiderProduct *product = (InsiderProduct *)[InsiderHybrid createProduct:[command.arguments objectAtIndex:0] productOptMap:[command.arguments objectAtIndex:1]];
|
|
335
|
+
[Insider itemAddedToCartWithProduct:product];
|
|
336
|
+
[self sendSuccessResultWithString:@"SUCCESS" andCommand:command];
|
|
337
|
+
});
|
|
338
|
+
} @catch (NSException *e) {
|
|
339
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
- (void)itemRemovedFromCart:(CDVInvokedUrlCommand *)command {
|
|
344
|
+
@try {
|
|
345
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
346
|
+
if (![command.arguments objectAtIndex:0]) return;
|
|
347
|
+
[Insider itemRemovedFromCartWithProductID:[command.arguments objectAtIndex:0]];
|
|
348
|
+
[self sendSuccessResultWithString:@"SUCCESS" andCommand:command];
|
|
349
|
+
});
|
|
350
|
+
} @catch (NSException *e) {
|
|
351
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
- (void)cartCleared:(CDVInvokedUrlCommand *)command {
|
|
356
|
+
@try {
|
|
357
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
358
|
+
[Insider cartCleared];
|
|
359
|
+
[self sendSuccessResultWithString:@"SUCCESS" andCommand:command];
|
|
360
|
+
});
|
|
361
|
+
} @catch (NSException *e) {
|
|
362
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
- (void)getSmartRecommendation:(CDVInvokedUrlCommand *)command {
|
|
367
|
+
@try {
|
|
368
|
+
[self.commandDelegate runInBackground:^{
|
|
369
|
+
if (![command.arguments objectAtIndex:0] || ![command.arguments objectAtIndex:1] || ![command.arguments objectAtIndex:2]) return;
|
|
370
|
+
[Insider getSmartRecommendationWithID:[[command.arguments objectAtIndex:0] intValue] locale:[command.arguments objectAtIndex:1] currency:[command.arguments objectAtIndex:2] smartRecommendation:^(NSDictionary *recommendation) {
|
|
371
|
+
[self sendSuccessResultWithDictionary:recommendation andCommand:command];
|
|
372
|
+
}];
|
|
373
|
+
}];
|
|
374
|
+
} @catch (NSException *e) {
|
|
375
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
- (void)getSmartRecommendationWithProduct:(CDVInvokedUrlCommand *)command {
|
|
380
|
+
@try {
|
|
381
|
+
[self.commandDelegate runInBackground:^{
|
|
382
|
+
if (![command.arguments objectAtIndex:0] || ![command.arguments objectAtIndex:1] || ![command.arguments objectAtIndex:2] || ![command.arguments objectAtIndex:3]) return;
|
|
383
|
+
InsiderProduct *product = (InsiderProduct *)[InsiderHybrid createProduct:[command.arguments objectAtIndex:0] productOptMap:[command.arguments objectAtIndex:1]];
|
|
384
|
+
[Insider getSmartRecommendationWithProduct:product recommendationID:[[command.arguments objectAtIndex:2] intValue] locale:[command.arguments objectAtIndex:3] smartRecommendation:^(NSDictionary *recommendation) {
|
|
385
|
+
[self sendSuccessResultWithDictionary:recommendation andCommand:command];
|
|
386
|
+
}];
|
|
387
|
+
}];
|
|
388
|
+
} @catch (NSException *e) {
|
|
389
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
- (void)clickSmartRecommendationProduct:(CDVInvokedUrlCommand *)command {
|
|
394
|
+
@try {
|
|
395
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
396
|
+
if (![command.arguments objectAtIndex:0] || ![command.arguments objectAtIndex:1] || ![command.arguments objectAtIndex:2]) return;
|
|
397
|
+
InsiderProduct *product = (InsiderProduct *)[InsiderHybrid createProduct:[command.arguments objectAtIndex:0] productOptMap:[command.arguments objectAtIndex:1]];
|
|
398
|
+
[Insider clickSmartRecommendationProductWithID:[[command.arguments objectAtIndex:2] intValue] product:product];
|
|
399
|
+
});
|
|
400
|
+
} @catch (NSException *e) {
|
|
401
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
- (void)getMessageCenterData:(CDVInvokedUrlCommand *)command {
|
|
406
|
+
@try {
|
|
407
|
+
[self.commandDelegate runInBackground:^{
|
|
408
|
+
if (![command.arguments objectAtIndex:0] || ![command.arguments objectAtIndex:1] || ![command.arguments objectAtIndex:2]) return;
|
|
409
|
+
[InsiderHybrid getMessageCenterDataWithLimit:[[command.arguments objectAtIndex:0] intValue] startDate:[command.arguments objectAtIndex:1] endDate:[command.arguments objectAtIndex:2] success:^(NSArray *messageCenterData) {
|
|
410
|
+
[self sendSuccessResultWithArray:messageCenterData andCommand:command];
|
|
411
|
+
}];
|
|
412
|
+
}];
|
|
413
|
+
} @catch (NSException *e) {
|
|
414
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
- (void)setGender:(CDVInvokedUrlCommand *)command {
|
|
419
|
+
@try {
|
|
420
|
+
[self.commandDelegate runInBackground:^{
|
|
421
|
+
if (![command.arguments objectAtIndex:0]) return;
|
|
422
|
+
[InsiderHybrid setGender:[[command.arguments objectAtIndex:0] intValue]];
|
|
423
|
+
}];
|
|
424
|
+
} @catch (NSException *e) {
|
|
425
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
- (void)setBirthday:(CDVInvokedUrlCommand *)command {
|
|
430
|
+
@try {
|
|
431
|
+
if (![command.arguments objectAtIndex:0]) return;
|
|
432
|
+
[InsiderHybrid setBirthday:[command.arguments objectAtIndex:0]];
|
|
433
|
+
} @catch (NSException *e) {
|
|
434
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
- (void)setName:(CDVInvokedUrlCommand *)command {
|
|
439
|
+
@try {
|
|
440
|
+
if (![command.arguments objectAtIndex:0]) return;
|
|
441
|
+
[Insider getCurrentUser].setName([command.arguments objectAtIndex:0]);
|
|
442
|
+
} @catch (NSException *e) {
|
|
443
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
- (void)setSurname:(CDVInvokedUrlCommand *)command {
|
|
448
|
+
@try {
|
|
449
|
+
if (![command.arguments objectAtIndex:0]) return;
|
|
450
|
+
[Insider getCurrentUser].setSurname([command.arguments objectAtIndex:0]);
|
|
451
|
+
} @catch (NSException *e) {
|
|
452
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
- (void)setAge:(CDVInvokedUrlCommand *)command {
|
|
457
|
+
@try {
|
|
458
|
+
if (![command.arguments objectAtIndex:0]) return;
|
|
459
|
+
[Insider getCurrentUser].setAge([[command.arguments objectAtIndex:0] intValue]);
|
|
460
|
+
} @catch (NSException *e) {
|
|
461
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
- (void)setSMSOptin:(CDVInvokedUrlCommand *)command {
|
|
466
|
+
@try {
|
|
467
|
+
if (![command.arguments objectAtIndex:0]) return;
|
|
468
|
+
[Insider getCurrentUser].setSMSOptin([[command.arguments objectAtIndex:0] boolValue]);
|
|
469
|
+
} @catch (NSException *e) {
|
|
470
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
- (void)setEmailOptin:(CDVInvokedUrlCommand *)command {
|
|
475
|
+
@try {
|
|
476
|
+
if (![command.arguments objectAtIndex:0]) return;
|
|
477
|
+
[Insider getCurrentUser].setEmailOptin([[command.arguments objectAtIndex:0] boolValue]);
|
|
478
|
+
} @catch (NSException *e) {
|
|
479
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
- (void)setPushOptin:(CDVInvokedUrlCommand *)command {
|
|
484
|
+
@try {
|
|
485
|
+
if (![command.arguments objectAtIndex:0]) return;
|
|
486
|
+
[Insider getCurrentUser].setPushOptin([[command.arguments objectAtIndex:0] boolValue]);
|
|
487
|
+
} @catch (NSException *e) {
|
|
488
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
- (void)setLocationOptin:(CDVInvokedUrlCommand *)command {
|
|
493
|
+
@try {
|
|
494
|
+
if (![command.arguments objectAtIndex:0]) return;
|
|
495
|
+
[Insider getCurrentUser].setLocationOptin([[command.arguments objectAtIndex:0] boolValue]);
|
|
496
|
+
} @catch (NSException *e) {
|
|
497
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
- (void)setWhatsappOptin:(CDVInvokedUrlCommand *)command {
|
|
502
|
+
@try {
|
|
503
|
+
if (![command.arguments objectAtIndex:0]) return;
|
|
504
|
+
[Insider getCurrentUser].setWhatsappOptin([[command.arguments objectAtIndex:0] boolValue]);
|
|
505
|
+
} @catch (NSException *e) {
|
|
506
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
- (void)setLanguage:(CDVInvokedUrlCommand *)command {
|
|
511
|
+
@try {
|
|
512
|
+
if (![command.arguments objectAtIndex:0]) return;
|
|
513
|
+
[Insider getCurrentUser].setLanguage([command.arguments objectAtIndex:0]);
|
|
514
|
+
} @catch (NSException *e) {
|
|
515
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
- (void)setLocale:(CDVInvokedUrlCommand *)command {
|
|
520
|
+
@try {
|
|
521
|
+
if (![command.arguments objectAtIndex:0]) return;
|
|
522
|
+
[Insider getCurrentUser].setLocale([command.arguments objectAtIndex:0]);
|
|
523
|
+
|
|
524
|
+
} @catch (NSException *e) {
|
|
525
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
- (void)setFacebookID:(CDVInvokedUrlCommand *)command {
|
|
530
|
+
@try {
|
|
531
|
+
if (![command.arguments objectAtIndex:0]) return;
|
|
532
|
+
[Insider getCurrentUser].setFacebookID([command.arguments objectAtIndex:0]);
|
|
533
|
+
|
|
534
|
+
} @catch (NSException *e) {
|
|
535
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
- (void)setTwitterID:(CDVInvokedUrlCommand *)command {
|
|
540
|
+
@try {
|
|
541
|
+
if (![command.arguments objectAtIndex:0]) return;
|
|
542
|
+
[Insider getCurrentUser].setTwitterID([command.arguments objectAtIndex:0]);
|
|
543
|
+
|
|
544
|
+
} @catch (NSException *e) {
|
|
545
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
- (void)setCustomAttributeWithString:(CDVInvokedUrlCommand *)command {
|
|
550
|
+
@try {
|
|
551
|
+
if (![command.arguments objectAtIndex:0] || ![command.arguments objectAtIndex:1]) return;
|
|
552
|
+
[Insider getCurrentUser].setCustomAttributeWithString([command.arguments objectAtIndex:0], [command.arguments objectAtIndex:1]);
|
|
553
|
+
|
|
554
|
+
} @catch (NSException *e) {
|
|
555
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
- (void)setCustomAttributeWithInt:(CDVInvokedUrlCommand *)command {
|
|
560
|
+
@try {
|
|
561
|
+
if (![command.arguments objectAtIndex:0] || ![command.arguments objectAtIndex:1]) return;
|
|
562
|
+
[Insider getCurrentUser].setCustomAttributeWithInt([command.arguments objectAtIndex:0], [[command.arguments objectAtIndex:1] intValue]);
|
|
563
|
+
|
|
564
|
+
} @catch (NSException *e) {
|
|
565
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
- (void)setCustomAttributeWithDouble:(CDVInvokedUrlCommand *)command {
|
|
570
|
+
@try {
|
|
571
|
+
if (![command.arguments objectAtIndex:0] || ![command.arguments objectAtIndex:1]) return;
|
|
572
|
+
[Insider getCurrentUser].setCustomAttributeWithDouble([command.arguments objectAtIndex:0], [[command.arguments objectAtIndex:1] doubleValue]);
|
|
573
|
+
|
|
574
|
+
} @catch (NSException *e) {
|
|
575
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
- (void)setCustomAttributeWithBoolean:(CDVInvokedUrlCommand *)command {
|
|
580
|
+
@try {
|
|
581
|
+
if (![command.arguments objectAtIndex:0] || ![command.arguments objectAtIndex:1]) return;
|
|
582
|
+
[Insider getCurrentUser].setCustomAttributeWithBoolean([command.arguments objectAtIndex:0], [[command.arguments objectAtIndex:1] boolValue]);
|
|
583
|
+
|
|
584
|
+
} @catch (NSException *e) {
|
|
585
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
- (void)setCustomAttributeWithDate:(CDVInvokedUrlCommand *)command {
|
|
590
|
+
@try {
|
|
591
|
+
if (![command.arguments objectAtIndex:0] || ![command.arguments objectAtIndex:1]) return;
|
|
592
|
+
[InsiderHybrid setCustomAttributeWithDate:[command.arguments objectAtIndex:0] value:[command.arguments objectAtIndex:1]];
|
|
593
|
+
|
|
594
|
+
} @catch (NSException *e) {
|
|
595
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
- (void)setCustomAttributeWithArray:(CDVInvokedUrlCommand *)command {
|
|
600
|
+
@try {
|
|
601
|
+
if (![command.arguments objectAtIndex:0] || ![command.arguments objectAtIndex:1]) return;
|
|
602
|
+
[Insider getCurrentUser].setCustomAttributeWithArray([command.arguments objectAtIndex:0], [command.arguments objectAtIndex:1]);
|
|
603
|
+
|
|
604
|
+
} @catch (NSException *e) {
|
|
605
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
- (void)unsetCustomAttribute:(CDVInvokedUrlCommand *)command {
|
|
610
|
+
@try {
|
|
611
|
+
if (![command.arguments objectAtIndex:0]) return;
|
|
612
|
+
[Insider getCurrentUser].unsetCustomAttribute([command.arguments objectAtIndex:0]);
|
|
613
|
+
|
|
614
|
+
} @catch (NSException *e) {
|
|
615
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
- (void)login:(CDVInvokedUrlCommand *)command {
|
|
620
|
+
@try {
|
|
621
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
622
|
+
if (![command.arguments objectAtIndex:0]) return;
|
|
623
|
+
NSMutableDictionary *identifiers = [command.arguments objectAtIndex:0];
|
|
624
|
+
InsiderIdentifiers *insiderIdentifiers = [[InsiderIdentifiers alloc] init];
|
|
625
|
+
for (NSString *key in identifiers.allKeys){
|
|
626
|
+
if([key isEqualToString:@"addEmail"]){
|
|
627
|
+
insiderIdentifiers.addEmail([identifiers objectForKey:key]);
|
|
628
|
+
} else if([key isEqualToString:@"addPhoneNumber"]){
|
|
629
|
+
insiderIdentifiers.addPhoneNumber([identifiers objectForKey:key]);
|
|
630
|
+
} else if([key isEqualToString:@"addUserID"]){
|
|
631
|
+
insiderIdentifiers.addUserID([identifiers objectForKey:key]);
|
|
632
|
+
} else {
|
|
633
|
+
insiderIdentifiers.addCustomIdentifier(key, [identifiers objectForKey:key]);
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
if ([command.arguments count] > 1) {
|
|
638
|
+
[[Insider getCurrentUser] login:insiderIdentifiers insiderIDResult:^(NSString *insiderID) {
|
|
639
|
+
[self sendSuccessResultWithString:insiderID andCommand:command];
|
|
640
|
+
}];
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
InsiderUser* currentUser = [Insider getCurrentUser];
|
|
644
|
+
|
|
645
|
+
[currentUser login:insiderIdentifiers];
|
|
646
|
+
|
|
647
|
+
});
|
|
648
|
+
} @catch (NSException *e) {
|
|
649
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
- (void)logout:(CDVInvokedUrlCommand *)command {
|
|
654
|
+
@try {
|
|
655
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
656
|
+
[[Insider getCurrentUser] logout];
|
|
657
|
+
[self sendSuccessResultWithString:@"SUCCESS" andCommand:command];
|
|
658
|
+
});
|
|
659
|
+
|
|
660
|
+
} @catch (NSException *e) {
|
|
661
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
- (void)signUpConfirmation:(CDVInvokedUrlCommand *)command {
|
|
666
|
+
@try {
|
|
667
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
668
|
+
[Insider signUpConfirmation];
|
|
669
|
+
[self sendSuccessResultWithString:@"SUCCESS" andCommand:command];
|
|
670
|
+
});
|
|
671
|
+
} @catch (NSException *exception) {
|
|
672
|
+
[Insider sendError:exception desc:@"Insider.m - signUpConfirmation"];
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
- (void)setActiveForegroundPushView:(CDVInvokedUrlCommand *)command {
|
|
677
|
+
@try {
|
|
678
|
+
[Insider setActiveForegroundPushView];
|
|
679
|
+
[self sendSuccessResultWithString:@"SUCCESS" andCommand:command];
|
|
680
|
+
} @catch (NSException *exception) {
|
|
681
|
+
[Insider sendError:exception desc:@"Insider.m - setActiveForegroundPushView"];
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
- (void)setForegroundPushCallback:(CDVInvokedUrlCommand *)command {
|
|
686
|
+
@try {
|
|
687
|
+
[Insider setForegroundPushCallback:@selector(foregroundPushCallback:) sender:self];
|
|
688
|
+
[self sendSuccessResultWithString:@"SUCCESS" andCommand:command];
|
|
689
|
+
} @catch (NSException *exception) {
|
|
690
|
+
[Insider sendError:exception desc:@"Insider.m - setForegroundPushCallback"];
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
- (void)foregroundPushCallback:(UNNotification *) notification {
|
|
695
|
+
@try {
|
|
696
|
+
NSString *jsCode = [NSString stringWithFormat:@"cordova.fireDocumentEvent('ins_foreground_push_callback',%@);", [InsiderHybrid dictToJson:notification.request.content.userInfo]];
|
|
697
|
+
|
|
698
|
+
[self.commandDelegate evalJs:jsCode];
|
|
699
|
+
} @catch (NSException *exception) {
|
|
700
|
+
[Insider sendError:exception desc:@"Insider.m - foregroundPushCallback"];
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
- (void) handleNotification:(CDVInvokedUrlCommand *) command {
|
|
705
|
+
@try {
|
|
706
|
+
if (![command.arguments objectAtIndex:0]) return;
|
|
707
|
+
|
|
708
|
+
NSMutableDictionary *mutableNotification = [[command.arguments objectAtIndex:0] mutableCopy];
|
|
709
|
+
|
|
710
|
+
mutableNotification[@"aps"] = @"insider";
|
|
711
|
+
|
|
712
|
+
[Insider handlePushLogWithUserInfo:mutableNotification];
|
|
713
|
+
[Insider trackInteractiveLogWithUserInfo:mutableNotification];
|
|
714
|
+
} @catch (NSException *exception){
|
|
715
|
+
[Insider sendError:exception desc:@"Insider.m - handleNotification"];
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
- (void)putException:(CDVInvokedUrlCommand *)command {
|
|
720
|
+
@try {
|
|
721
|
+
if (![command.arguments objectAtIndex:0]) return;
|
|
722
|
+
NSException *e = [NSException exceptionWithName:@"[Insider Cordova Plugin Error]" reason:[command.arguments objectAtIndex:0] userInfo:nil];
|
|
723
|
+
[Insider sendError:e desc:[NSString stringWithFormat:@"%s:%d", __func__, __LINE__]];
|
|
724
|
+
} @catch (NSException *e) {
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
- (void) sendErrorResultWithString:(NSString *)resultMessage andCommand:(CDVInvokedUrlCommand *)command {
|
|
729
|
+
CDVPluginResult *pluginResult = nil;
|
|
730
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:resultMessage];
|
|
731
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
- (void) sendSuccessResultWithString:(NSString *)resultMessage andCommand:(CDVInvokedUrlCommand *)command {
|
|
735
|
+
CDVPluginResult *pluginResult = nil;
|
|
736
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:resultMessage];
|
|
737
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
- (void) sendSuccessResultWithInt:(int)resultMessage andCommand:(CDVInvokedUrlCommand *)command {
|
|
741
|
+
CDVPluginResult *pluginResult = nil;
|
|
742
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:resultMessage];
|
|
743
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
- (void) sendSuccessResultWithArray:(NSArray *)resultMessage andCommand:(CDVInvokedUrlCommand *)command {
|
|
747
|
+
CDVPluginResult *pluginResult = nil;
|
|
748
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:resultMessage];
|
|
749
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
- (void) sendSuccessResultWithDictionary:(NSDictionary *)resultMessage andCommand:(CDVInvokedUrlCommand *)command {
|
|
753
|
+
CDVPluginResult *pluginResult = nil;
|
|
754
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:resultMessage];
|
|
755
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
@end
|