reactnative-plugin-appice 1.7.17 → 1.7.19
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/android/build.gradle +1 -1
- package/android/src/main/java/com/reactlibrary/AppICEUtils.java +37 -0
- package/android/src/main/java/com/reactlibrary/AppIceReactPluginModule.java +30 -1
- package/android/src/main/java/com/reactlibrary/EnumConstants.java +24 -1
- package/example/App.js +43 -6
- package/example/android/.gradle/7.3.3/checksums/checksums.lock +0 -0
- package/example/android/.gradle/7.3.3/fileChanges/last-build.bin +0 -0
- package/example/android/.gradle/7.3.3/fileHashes/fileHashes.lock +0 -0
- package/example/android/.gradle/vcs-1/gc.properties +0 -0
- package/example/package.json +1 -1
- package/example/yarn.lock +6199 -6736
- package/index.js +62 -1
- package/ios/AppIceReactPlugin.h +6 -0
- package/ios/AppIceReactPlugin.m +48 -6
- package/package.json +1 -1
- package/example/android/local.properties +0 -8
- /package/{android/src/main/test → example/android/.gradle/7.3.3/gc.properties} +0 -0
package/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import { DeviceEventEmitter, NativeEventEmitter, NativeModules } from 'react-nat
|
|
|
2
2
|
import { Platform, Component } from 'react-native';
|
|
3
3
|
// import { MMKV } from 'react-native-mmkv'
|
|
4
4
|
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
5
|
+
import Campaign from './campaign';
|
|
5
6
|
|
|
6
7
|
const AppIceReactPlugin = NativeModules.AppIceReactPlugin;
|
|
7
8
|
var eventEmitter;
|
|
@@ -19,6 +20,17 @@ else {
|
|
|
19
20
|
const EVENT_KEY = "lastEvent"
|
|
20
21
|
const LAST_EVENT_KEY = "event_"
|
|
21
22
|
|
|
23
|
+
export const CAMP_ID = AppIceReactPlugin.CAMP_ID;
|
|
24
|
+
export const ACTION_URL = AppIceReactPlugin.ACTION_URL;
|
|
25
|
+
export const ACTION_TYPE = AppIceReactPlugin.ACTION_TYPE;
|
|
26
|
+
export const CUSTOMDATA = AppIceReactPlugin.CUSTOMDATA;
|
|
27
|
+
|
|
28
|
+
const CampaignType = {
|
|
29
|
+
NATIVE: 'NATIVE',
|
|
30
|
+
INAPP: 'INAPP',
|
|
31
|
+
PUSH: 'PUSH',
|
|
32
|
+
};
|
|
33
|
+
|
|
22
34
|
|
|
23
35
|
var AppICEReact = {
|
|
24
36
|
|
|
@@ -89,6 +101,7 @@ var AppICEReact = {
|
|
|
89
101
|
AVERAGE_TRANSACTION_AMOUNT: AppIceReactPlugin.AVERAGE_TRANSACTION_AMOUNT,
|
|
90
102
|
FREQUENCY_OF_TRANSACTION: AppIceReactPlugin.FREQUENCY_OF_TRANSACTION,
|
|
91
103
|
TYPE_OF_TRANSACTION: AppIceReactPlugin.TYPE_OF_TRANSACTION,
|
|
104
|
+
|
|
92
105
|
|
|
93
106
|
//======================
|
|
94
107
|
// LISTENER
|
|
@@ -224,7 +237,6 @@ var AppICEReact = {
|
|
|
224
237
|
AppIceReactPlugin.setCustomVariable(eventName, props);
|
|
225
238
|
},
|
|
226
239
|
|
|
227
|
-
|
|
228
240
|
//===========================
|
|
229
241
|
// CAMPAIGN SETTING
|
|
230
242
|
//===========================
|
|
@@ -428,7 +440,56 @@ var AppICEReact = {
|
|
|
428
440
|
getUserForIds: function (userIds, callback) {
|
|
429
441
|
callWithCallback('getUserForIds', [userIds], callback);
|
|
430
442
|
},
|
|
443
|
+
|
|
444
|
+
/*===================
|
|
445
|
+
GetCampaign
|
|
446
|
+
=====================*/
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* getCampaigns
|
|
450
|
+
* @param campType - string
|
|
451
|
+
* @callback - Return array of Campaign objects
|
|
452
|
+
*/
|
|
453
|
+
|
|
454
|
+
getCampaigns: function (campType, callback) {
|
|
455
|
+
AppIceReactPlugin.getCampaigns(campType, (campaignArray) => {
|
|
456
|
+
const campaigns = campaignArray.map(
|
|
457
|
+
(campaignData) =>
|
|
458
|
+
new Campaign(
|
|
459
|
+
campaignData[CAMP_ID],
|
|
460
|
+
campaignData[ACTION_URL],
|
|
461
|
+
campaignData[ACTION_TYPE],
|
|
462
|
+
campaignData[CUSTOMDATA]
|
|
463
|
+
)
|
|
464
|
+
);
|
|
465
|
+
callback(campaigns);
|
|
466
|
+
});
|
|
467
|
+
},
|
|
468
|
+
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* getCampaignById
|
|
473
|
+
* @param campId - string
|
|
474
|
+
* @callback -Return a single Campaign object
|
|
475
|
+
*/
|
|
476
|
+
|
|
477
|
+
getCampaignById: function (campId, callback) {
|
|
478
|
+
AppIceReactPlugin.getCampaignById(campId, (campaignData) => {
|
|
479
|
+
const getCampaign = new Campaign(
|
|
480
|
+
campaignData[CAMP_ID],
|
|
481
|
+
campaignData[ACTION_URL],
|
|
482
|
+
campaignData[ACTION_TYPE],
|
|
483
|
+
campaignData[CUSTOMDATA]
|
|
484
|
+
);
|
|
485
|
+
callback(getCampaign);
|
|
486
|
+
});
|
|
487
|
+
},
|
|
488
|
+
|
|
489
|
+
//campaign enum
|
|
490
|
+
CampaignType,
|
|
431
491
|
};
|
|
492
|
+
|
|
432
493
|
|
|
433
494
|
|
|
434
495
|
//================================
|
package/ios/AppIceReactPlugin.h
CHANGED
|
@@ -29,6 +29,12 @@ static NSString *const INBOX_MESSAGE_ICON = @"INBOX_MESSAGE_ICON";
|
|
|
29
29
|
static NSString *const INBOX_CUSTOM_DATA = @"INBOX_CUSTOM_DATA";
|
|
30
30
|
static NSString *const INBOX_MESSAGE_EXPANDED_IMAGE = @"INBOX_MESSAGE_EXPANDED_IMAGE";
|
|
31
31
|
|
|
32
|
+
//CAMPAIGN
|
|
33
|
+
static NSString *const CAMP_ID = @"CAMP_ID";
|
|
34
|
+
static NSString *const ACTION_URL = @"ACTION_URL";
|
|
35
|
+
static NSString *const ACTION_TYPE = @"ACTION_TYPE";
|
|
36
|
+
static NSString *const CUSTOMDATA = @"CUSTOMDATA";
|
|
37
|
+
|
|
32
38
|
// Custom data
|
|
33
39
|
static NSString *const DEMOGRAPHIC_INFO = @"DEMOGRAPHIC_INFO";
|
|
34
40
|
static NSString *TOP_N_PRODUCTS_VIEWED;
|
package/ios/AppIceReactPlugin.m
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
#import "appICEUserDetails.h"
|
|
6
6
|
#import "AppICEInboxMessage.h"
|
|
7
7
|
#import <UserNotifications/UserNotifications.h>
|
|
8
|
+
#import "Campaign.h"
|
|
8
9
|
@implementation AppIceReactPlugin
|
|
9
10
|
|
|
10
11
|
static BOOL isAppInitialized = NO;
|
|
@@ -74,7 +75,11 @@ RCT_EXPORT_MODULE()
|
|
|
74
75
|
@"CHECKING_BALANCE" : CHECKING_BALANCE,
|
|
75
76
|
@"AVERAGE_TRANSACTION_AMOUNT" : AVERAGE_TRANSACTION_AMOUNT,
|
|
76
77
|
@"FREQUENCY_OF_TRANSACTION": FREQUENCY_OF_TRANSACTION,
|
|
77
|
-
@"TYPE_OF_TRANSACTION" : TYPE_OF_TRANSACTION
|
|
78
|
+
@"TYPE_OF_TRANSACTION" : TYPE_OF_TRANSACTION,
|
|
79
|
+
CAMP_ID : @"campId",
|
|
80
|
+
ACTION_URL : @"actionUrl",
|
|
81
|
+
ACTION_TYPE: @"actionType",
|
|
82
|
+
CUSTOMDATA : @"customData"
|
|
78
83
|
};
|
|
79
84
|
}
|
|
80
85
|
- (dispatch_queue_t)methodQueue {
|
|
@@ -167,11 +172,13 @@ RCT_EXPORT_METHOD(getUserId:(RCTResponseSenderBlock)callback)
|
|
|
167
172
|
RCTLog(@"getUserIdArray %@", getUserIdArray);
|
|
168
173
|
|
|
169
174
|
if (getUserIdArray && getUserIdArray.count > 0 && callback) {
|
|
170
|
-
|
|
175
|
+
NSError *error = nil;
|
|
176
|
+
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:getUserIdArray options:0 error:&error];
|
|
177
|
+
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
|
178
|
+
[self returnResult:jsonString withCallback:callback andError:nil];
|
|
179
|
+
|
|
171
180
|
} else {
|
|
172
|
-
|
|
173
|
-
callback(@[[NSNull null]]);
|
|
174
|
-
}
|
|
181
|
+
[self returnResult:nil withCallback:callback andError:nil];
|
|
175
182
|
}
|
|
176
183
|
|
|
177
184
|
}
|
|
@@ -605,7 +612,7 @@ RCT_EXPORT_METHOD(synchronizeData:(int)timeout callback:(RCTResponseSenderBlock)
|
|
|
605
612
|
/*--------------------------------------------
|
|
606
613
|
* getUserForIds with UserId
|
|
607
614
|
* userIds - NSArray
|
|
608
|
-
* @callback will have the
|
|
615
|
+
* @callback will have the NSMutableArray
|
|
609
616
|
---------------------------------------------*/
|
|
610
617
|
|
|
611
618
|
RCT_EXPORT_METHOD(getUserForIds:(NSArray*)userIds callback:(RCTResponseSenderBlock)callback)
|
|
@@ -623,6 +630,41 @@ RCT_EXPORT_METHOD(getUserForIds:(NSArray*)userIds callback:(RCTResponseSenderBlo
|
|
|
623
630
|
|
|
624
631
|
}
|
|
625
632
|
|
|
633
|
+
/*--------------------------------------------
|
|
634
|
+
* getCampaigns with CampignType
|
|
635
|
+
* type - NSString
|
|
636
|
+
* @callback will have the Array
|
|
637
|
+
---------------------------------------------*/
|
|
638
|
+
|
|
639
|
+
RCT_EXPORT_METHOD(getCampaigns:(NSString *)type callback:(RCTResponseSenderBlock)callback)
|
|
640
|
+
{
|
|
641
|
+
NSMutableArray<Campaign *> *campaigns = [[appICE sharedInstance] getCampaigns:type];
|
|
642
|
+
|
|
643
|
+
NSMutableArray *formattedCampaigns = [NSMutableArray array];
|
|
644
|
+
|
|
645
|
+
for (Campaign *campaign in campaigns) {
|
|
646
|
+
NSDictionary *formatedCampaign = [Campaign formatcampaign:campaign];
|
|
647
|
+
NSLog(@"Campaign: Formatted getCampaigns: %@", formatedCampaign);
|
|
648
|
+
[formattedCampaigns addObject:formatedCampaign];
|
|
649
|
+
}
|
|
650
|
+
[self returnResult:formattedCampaigns withCallback:callback andError:nil];
|
|
651
|
+
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
/*--------------------------------------------
|
|
655
|
+
* getCampaignById with campID
|
|
656
|
+
* campID - NSString
|
|
657
|
+
* @callback will have the Dictionary
|
|
658
|
+
---------------------------------------------*/
|
|
659
|
+
|
|
660
|
+
RCT_EXPORT_METHOD(getCampaignById:(NSString *)campID callback:(RCTResponseSenderBlock)callback)
|
|
661
|
+
{
|
|
662
|
+
|
|
663
|
+
Campaign *campaign = [[appICE sharedInstance] getCampaignById:campID];
|
|
664
|
+
|
|
665
|
+
NSDictionary *formatedCampaign = [Campaign formatcampaign:campaign];
|
|
666
|
+
[self returnResult:formatedCampaign withCallback:callback andError:nil];
|
|
667
|
+
}
|
|
626
668
|
|
|
627
669
|
|
|
628
670
|
- (void)returnResult:(id)result withCallback:(RCTResponseSenderBlock)callback andError:(NSString *)error {
|
package/package.json
CHANGED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
## This file must *NOT* be checked into Version Control Systems,
|
|
2
|
-
# as it contains information specific to your local configuration.
|
|
3
|
-
#
|
|
4
|
-
# Location of the SDK. This is only used by Gradle.
|
|
5
|
-
# For customization when using a Version Control System, please read the
|
|
6
|
-
# header note.
|
|
7
|
-
#Thu Jul 11 15:09:32 IST 2024
|
|
8
|
-
sdk.dir=/Users/amit/Library/Android/sdk
|
|
File without changes
|