reactnative-plugin-appice 1.5.7 → 1.5.9

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.
@@ -114,10 +114,11 @@ dependencies {
114
114
  annotationProcessor "androidx.lifecycle:lifecycle-compiler:2.3.1"
115
115
 
116
116
  //appice
117
- implementation 'appice.io.android:sdk:2.5.59'
117
+ implementation 'appice.io.android:sdk:2.5.61'
118
118
 
119
119
  //glide
120
- implementation "com.github.bumptech.glide:glide:4.10.0"
120
+ implementation "com.github.bumptech.glide:glide:4.11.0"
121
+ annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
121
122
 
122
123
  }
123
124
 
@@ -5,6 +5,7 @@ import android.content.Intent;
5
5
  import android.content.pm.PackageManager;
6
6
  import android.content.pm.ResolveInfo;
7
7
 
8
+ import com.facebook.react.bridge.Arguments;
8
9
  import com.facebook.react.bridge.Callback;
9
10
  import com.facebook.react.bridge.ReactApplicationContext;
10
11
  import com.facebook.react.bridge.ReactContextBaseJavaModule;
@@ -50,7 +51,8 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
50
51
  private static final String APPICE_USER_IS_EMPLOYED = "is_emp";
51
52
  private static final String APPICE_USER_EMPLOYMENT_TYPE = "et";
52
53
  private static final String APPICE_USER_MARRIED = "m";
53
- private static final String APPICE_PUSH_NOTIFICATION_CLICKED = "AppICEPushNotificationClicked";
54
+ public static final String APPICE_PUSH_NOTIFICATION_CLICKED = "AppICEPushNotificationClicked";
55
+ public static final String APPICE_INAPP_NOTIFICATION_CLICKED = "AppICEInAppClicked";
54
56
 
55
57
  public AppIceReactPluginModule(ReactApplicationContext reactContext) {
56
58
  super(reactContext);
@@ -325,6 +327,7 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
325
327
  constants.put(APPICE_USER_AGE, APPICE_USER_AGE);
326
328
  constants.put(APPICE_USER_GENDER, APPICE_USER_GENDER);
327
329
  constants.put(APPICE_PUSH_NOTIFICATION_CLICKED, APPICE_PUSH_NOTIFICATION_CLICKED);
330
+ constants.put(APPICE_INAPP_NOTIFICATION_CLICKED, APPICE_INAPP_NOTIFICATION_CLICKED);
328
331
  return constants;
329
332
  }
330
333
 
@@ -344,26 +347,7 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
344
347
  ContextSdk.pushNotificationClicked(payload, ctx);
345
348
  }
346
349
 
347
-
348
- @ReactMethod
349
- public void sendClickCallback(final Callback callback) {
350
- ClickCallback clickCallback = new ClickCallback() {
351
- @Override
352
- public void clickPayload(String obj) {
353
- if (obj != null && obj.length() > 0) {
354
- try {
355
- System.out.println("AppICEPlugin : sendClickCallback : "+obj);
356
- callback.invoke(obj);
357
- } catch (Throwable e) {
358
- System.out.println("AppICEPlugin : sendClickCallback : exception "+e);
359
- }
360
- }
361
- }
362
- };
363
- CampaignCampsReceiver campaignCampsReceiver = new CampaignCampsReceiver(clickCallback);
364
- }
365
-
366
- static void sendEvent(String eventName, @Nullable WritableMap params) {
350
+ public static void sendEvent(String eventName, @Nullable WritableMap params) {
367
351
  try {
368
352
  context.
369
353
  getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
@@ -50,11 +50,9 @@ public class CampaignCampsReceiver extends BroadcastReceiver {
50
50
 
51
51
  if (category) {
52
52
  if (cdata != null && cdata.length() > 0) {
53
- if (clickCallback != null) {
54
- clickCallback.clickPayload(cdata);
55
- System.out.println("CampaignRec : clickCallback "+cdata);
56
- } else
57
- System.out.println("callback is null");
53
+ WritableMap params = Arguments.createMap();
54
+ params.putString(AppIceReactPluginModule.APPICE_INAPP_NOTIFICATION_CLICKED, cdata);
55
+ AppIceReactPluginModule.sendEvent(AppIceReactPluginModule.APPICE_INAPP_NOTIFICATION_CLICKED, params);
58
56
  }
59
57
  }
60
58
 
@@ -63,8 +61,8 @@ public class CampaignCampsReceiver extends BroadcastReceiver {
63
61
  if (pushContent != null){
64
62
  WritableMap params = Arguments.createMap();
65
63
  if (pushContent != null){
66
- params.putString("AppICEPushNotificationClicked", pushContent.toString());
67
- AppIceReactPluginModule.sendEvent("AppICEPushNotificationClicked", params);
64
+ params.putString(AppIceReactPluginModule.APPICE_PUSH_NOTIFICATION_CLICKED, pushContent.toString());
65
+ AppIceReactPluginModule.sendEvent(AppIceReactPluginModule.APPICE_PUSH_NOTIFICATION_CLICKED, params);
68
66
  }
69
67
  }
70
68
  }
@@ -17,7 +17,7 @@ import java.util.concurrent.atomic.AtomicReference;
17
17
  public class NotificationEventService extends JobService {
18
18
 
19
19
  @Override
20
- public boolean onStartJob(JobParameters params) {
20
+ public boolean onStartJob(final JobParameters params) {
21
21
  if (params != null) {
22
22
  PersistableBundle bundle = params.getExtras();
23
23
  if (bundle != null) {
@@ -31,7 +31,7 @@ public class NotificationEventService extends JobService {
31
31
  rc.sendCallback(bundle1, getApplicationContext());
32
32
  jobFinished(params,false);
33
33
  }
34
- }, 2 * 1000);
34
+ }, 1 * 1000);
35
35
  }
36
36
  }
37
37
  }
package/example/App.js CHANGED
@@ -101,6 +101,13 @@ console.log('handleAppICETapEvent');
101
101
  console.log(data);
102
102
  }
103
103
  });
104
+
105
+ AppICE.addListener(AppICE.AppICEInAppClicked, (event) => {
106
+ if (typeof event !== 'undefined'){
107
+ console.log('handleAppICETapEvent', AppICE.AppICEInAppClicked, event.AppICEInAppClicked);
108
+ // AppICE.pushNotificationClicked(event.AppICEInAppClicked);
109
+ }
110
+ });
104
111
  }
105
112
  const sendEvent = () => {
106
113
  console.log("inside sendEvent");
@@ -128,6 +135,11 @@ const setSampleUserID = () => {
128
135
  const setLanguage = () => {
129
136
  AppICE.setCustomVariable("_lang", "ar-AE");
130
137
 
138
+
139
+ AppICE.sendClickCallback((value) => {
140
+ console.log(`INAPP callback`, value);
141
+ });
142
+
131
143
  };
132
144
  const sendView = () => {
133
145
  AppICE.tagEvent("HomeScreen", {});
package/index.js CHANGED
@@ -13,6 +13,7 @@ else
13
13
  }
14
14
  var AppICEReact = {
15
15
  AppICEPushNotificationClicked: AppIceReactPlugin.AppICEPushNotificationClicked,
16
+ AppICEInAppClicked: AppIceReactPlugin.AppICEInAppClicked,
16
17
  name: AppIceReactPlugin.n,
17
18
  email: AppIceReactPlugin.em,
18
19
  phone: AppIceReactPlugin.ph,
@@ -117,14 +118,6 @@ var AppICEReact = {
117
118
 
118
119
  return map;
119
120
  },
120
-
121
- /**
122
- * to send inapp callback to app
123
- * @param {callback} callback - inapp callbcak send back to app
124
- */
125
- sendClickCallback: function (callback) {
126
- AppIceReactPlugin.sendClickCallback(callback);
127
- },
128
121
  };
129
122
 
130
123
 
@@ -16,6 +16,7 @@ NS_ASSUME_NONNULL_BEGIN
16
16
  @interface AppICEReactEvent : RCTEventEmitter <RCTBridgeModule, UNUserNotificationCenterDelegate>
17
17
  -(void)didReceiveNotificationResponse:(NSNotification *)event;
18
18
  + (id)allocWithZone:(NSZone *)zone;
19
+ -(void)InAppCallback:(NSNotification *)event;
19
20
 
20
21
  @end
21
22
 
@@ -18,7 +18,7 @@ RCT_EXPORT_MODULE();
18
18
  static dispatch_once_t onceToken;
19
19
  dispatch_once(&onceToken, ^{
20
20
  sharedInstance = [super allocWithZone:zone];
21
- [sharedInstance startObserving];
21
+ // [sharedInstance startObserving];
22
22
  });
23
23
  return sharedInstance;
24
24
  }
@@ -26,16 +26,16 @@ RCT_EXPORT_MODULE();
26
26
 
27
27
  - (instancetype)init
28
28
  {
29
- if ((self = [super init]))
30
- {
31
- [self startObserving];
32
- }
29
+ // if ((self = [super init]))
30
+ // {
31
+ // [self startObserving];
32
+ // }
33
33
  return self;
34
34
  }
35
35
 
36
36
  - (NSArray<NSString *> *)supportedEvents
37
37
  {
38
- return @[kAppICEPushNotificationClicked];
38
+ return @[kAppICEPushNotificationClicked, kAppICEInAppClicked];
39
39
  }
40
40
 
41
41
 
@@ -44,6 +44,12 @@ RCT_EXPORT_MODULE();
44
44
  selector:@selector(didReceiveNotificationResponse:)
45
45
  name:kAppICEPushNotificationClicked
46
46
  object:nil];
47
+
48
+ [[NSNotificationCenter defaultCenter] addObserver:self
49
+ selector:@selector(InAppCallback:)
50
+ name:kAppICEInAppClicked
51
+ object:nil];
52
+
47
53
 
48
54
 
49
55
  }
@@ -60,6 +66,12 @@ RCT_EXPORT_MODULE();
60
66
  [self sendEventWithName:kAppICEPushNotificationClicked body:event.userInfo];
61
67
  }
62
68
 
69
+ -(void)InAppCallback:(NSNotification *)event{
70
+ NSLog(@"from InAppCallback %@",event);
71
+ NSMutableDictionary * eventDict = [[NSMutableDictionary alloc]init];
72
+ [eventDict setObject:event.userInfo forKey:kAppICEInAppClicked];
73
+ [self sendEventWithName:kAppICEInAppClicked body:eventDict];
74
+ }
63
75
 
64
76
  @end
65
77
 
@@ -1,6 +1,8 @@
1
1
  #import <React/RCTBridgeModule.h>
2
2
  #import <UserNotifications/UserNotifications.h>
3
3
  static NSString *const kAppICEPushNotificationClicked = @"AppICEPushNotificationClicked";
4
+ static NSString *const kAppICEInAppClicked = @"AppICEInAppClicked";
5
+
4
6
  static NSString *const kn = @"n";
5
7
  static NSString *const kem = @"em";
6
8
  static NSString *const kph = @"ph";
@@ -14,15 +14,16 @@ RCT_EXPORT_MODULE()
14
14
  - (NSDictionary *)constantsToExport {
15
15
  return @{
16
16
  kAppICEPushNotificationClicked : kAppICEPushNotificationClicked,
17
+ kAppICEInAppClicked : kAppICEInAppClicked,
17
18
  kn : kn,
18
- kem : "e",
19
- kph : "p",
19
+ kem : @"e",
20
+ kph : @"p",
20
21
  ka : ka,
21
22
  kg : kg,
22
- ked : "edt",
23
- ket : "emt",
23
+ ked : @"edt",
24
+ ket : @"emt",
24
25
  km : km,
25
- kis_emp : "em"
26
+ kis_emp : @"em"
26
27
  };
27
28
  }
28
29
  - (dispatch_queue_t)methodQueue {
@@ -54,7 +55,9 @@ RCT_EXPORT_METHOD(startContext:(NSString *)appID
54
55
  [appICE setTokenInPushNotification:[[NSUserDefaults standardUserDefaults]objectForKey:kappICEToken]];
55
56
  [[NSUserDefaults standardUserDefaults] removeObjectForKey:kappICEToken];
56
57
  }
58
+ [self setClickCallback];
57
59
  }
60
+
58
61
  /**
59
62
  * didRegisterForRemoteNotificationsWithDeviceToken sets the device token in sdk or userdefaults depends upon sdk initalise.
60
63
  * @param deviceToken token in form of NSData
@@ -107,7 +110,7 @@ RCT_EXPORT_METHOD(pushNotificationClicked:(NSDictionary*)userInfo)
107
110
  RCT_EXPORT_METHOD(setUser:(NSDictionary*)userProfile)
108
111
  {
109
112
  NSArray *items = [NSArray arrayWithObjects:kAIUserName,kAIUserEmail,kAIUserPhone,kAIUserGender,kAIUserBirthYear,kAIUserAge,kAIUserIsUserEmployed,kAIUserEmploymentType,kAIUserEducationType,kAIUserIsUserMarried, nil];
110
-
113
+ appICEUserDetails *app=[appICEUserDetails new];
111
114
  for(int i= 0; i< items.count ;i++)
112
115
  {
113
116
 
@@ -160,38 +163,26 @@ RCT_EXPORT_METHOD(setUser:(NSDictionary*)userProfile)
160
163
  [[NSNotificationCenter defaultCenter] postNotificationName:kAppICEPushNotificationClicked object:nil userInfo:event];
161
164
  }
162
165
 
166
+ RCT_EXPORT_METHOD(inAppClicked:(NSDictionary*)userInfo)
167
+ {
168
+ RCTLog(@"from inAppClicked method = %@",userInfo);
169
+ }
170
+
163
171
  + (void)pushNotificationReceived:(NSDictionary *)userInfo {
164
172
  [[appICE sharedInstance]pushNotificationReceived:userInfo];
165
173
  }
166
174
 
167
175
  //InApp Deeplink Callback
168
- RCT_EXPORT_METHOD(sendClickCallback:(RCTResponseSenderBlock)successCallback)
176
+ - (void)setClickCallback
169
177
  {
170
-
171
178
  [[appICE sharedInstance] setClickCallback:^(NSDictionary * _Nonnull cData) {
172
179
  // Convert cData to JSON string
173
- NSError *error;
174
- NSData *jsonData = [NSJSONSerialization dataWithJSONObject:cData options:NSJSONWritingPrettyPrinted error:&error];
175
-
176
- NSString *jsonString;
177
- if (!error) {
178
- if (jsonData != nil || [jsonData length] != 0) {
179
- jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
180
- RCTLog(@"***** INapp success *** %@", jsonString);
181
- }
182
- else {
183
- jsonString = @"{}";
180
+ if (cData != nil || cData.count > 0) {
181
+ RCTLog(@"***** INapp success *** %@", cData);
182
+ [[NSNotificationCenter defaultCenter] postNotificationName:kAppICEInAppClicked object:nil userInfo:cData];
183
+
184
184
  }
185
- } else {
186
- jsonString = @"{}"; // Handle error case
187
- }
188
- // Check again if successCallback is not nil
189
- if(successCallback != nil)
190
- {
191
- // Invoke successCallback with JSON string
192
- successCallback(@[jsonString]);
193
- }
194
-
185
+
195
186
  }];
196
187
 
197
188
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reactnative-plugin-appice",
3
- "version": "1.5.7",
3
+ "version": "1.5.9",
4
4
  "description": "appICE React Native SDK",
5
5
  "main": "index.js",
6
6
  "files": [