@customerglu/react-native-customerglu 1.0.7 → 1.0.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.
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ Supports API 21 and above. Please ensure the minSDKVersion in the app's build.gr
|
|
|
16
16
|
### Option 1
|
|
17
17
|
Add the CustomerGlu React Native plugin in package.json file
|
|
18
18
|
```
|
|
19
|
-
"@customerglu/react-native-customerglu": "^1.0.
|
|
19
|
+
"@customerglu/react-native-customerglu": "^1.0.9"
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
### Option 2
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
package com.reactnativerncustomerglu;
|
|
2
2
|
|
|
3
|
+
import static com.customerglu.sdk.Utils.Comman.printDebugLogs;
|
|
3
4
|
import static com.facebook.react.bridge.UiThreadUtil.runOnUiThread;
|
|
4
5
|
|
|
5
6
|
import android.content.BroadcastReceiver;
|
|
@@ -9,13 +10,14 @@ import android.content.IntentFilter;
|
|
|
9
10
|
import android.content.pm.ApplicationInfo;
|
|
10
11
|
import android.content.pm.PackageManager;
|
|
11
12
|
import android.net.Uri;
|
|
13
|
+
import android.os.Bundle;
|
|
12
14
|
import android.util.Log;
|
|
13
15
|
|
|
14
16
|
import androidx.annotation.NonNull;
|
|
15
17
|
|
|
16
18
|
import com.customerglu.sdk.Modal.NudgeConfiguration;
|
|
19
|
+
import com.customerglu.sdk.Utils.Comman;
|
|
17
20
|
import com.facebook.react.bridge.LifecycleEventListener;
|
|
18
|
-
import com.facebook.react.bridge.NativeMap;
|
|
19
21
|
import com.facebook.react.bridge.WritableArray;
|
|
20
22
|
import com.facebook.react.bridge.WritableNativeArray;
|
|
21
23
|
import com.facebook.react.bridge.WritableNativeMap;
|
|
@@ -396,10 +398,37 @@ public class RncustomergluModule extends ReactContextBaseJavaModule implements L
|
|
|
396
398
|
@ReactMethod
|
|
397
399
|
public void DisplayCGNotification(ReadableMap data,Boolean autoclosewebview) {
|
|
398
400
|
JSONObject jsonObject=convertMapToJson(data);
|
|
399
|
-
|
|
400
|
-
|
|
401
|
+
if(getAppIcon(getReactApplicationContext())!=0) {
|
|
402
|
+
CustomerGlu.getInstance().displayCustomerGluNotification(getReactApplicationContext(), jsonObject, getAppIcon(getReactApplicationContext()), 0.5, autoclosewebview);
|
|
403
|
+
}else{
|
|
404
|
+
CustomerGlu.getInstance().displayCustomerGluNotification(getReactApplicationContext(), jsonObject, R.drawable.notification, 0.5, autoclosewebview);
|
|
401
405
|
|
|
406
|
+
}
|
|
402
407
|
}
|
|
408
|
+
|
|
409
|
+
private static int getAppIcon(Context context) {
|
|
410
|
+
|
|
411
|
+
try {
|
|
412
|
+
ApplicationInfo ai = context.getPackageManager().getApplicationInfo(
|
|
413
|
+
context.getPackageName(), PackageManager.GET_META_DATA);
|
|
414
|
+
Bundle bundle = ai.metaData;
|
|
415
|
+
int myAPIKey = bundle.getInt("CUSTOMERGLU_NOTIFICATION_ICON");
|
|
416
|
+
printDebugLogs("API KEY : " + myAPIKey);
|
|
417
|
+
return myAPIKey;
|
|
418
|
+
} catch (Exception e) {
|
|
419
|
+
Comman.printErrorLogs(e.toString());
|
|
420
|
+
return 0;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
|
|
403
432
|
@ReactMethod
|
|
404
433
|
public void DisplayCGBackgroundNotification(ReadableMap data,Boolean autoclosewebview) {
|
|
405
434
|
JSONObject jsonObject=convertMapToJson(data);
|
|
@@ -407,19 +436,8 @@ public class RncustomergluModule extends ReactContextBaseJavaModule implements L
|
|
|
407
436
|
CustomerGlu.getInstance().displayCustomerGluBackgroundNotification(getReactApplicationContext(),jsonObject,autoclosewebview);
|
|
408
437
|
|
|
409
438
|
}
|
|
410
|
-
public int getMyAppIcon(Context context) {
|
|
411
|
-
final PackageManager packageManager = context.getPackageManager();
|
|
412
|
-
final ApplicationInfo applicationInfo;
|
|
413
|
-
int appIconResId = 0;
|
|
414
|
-
try {
|
|
415
|
-
applicationInfo = packageManager.getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);
|
|
416
|
-
appIconResId = applicationInfo.icon;
|
|
417
439
|
|
|
418
|
-
|
|
419
|
-
e.printStackTrace();
|
|
420
|
-
}
|
|
421
|
-
return appIconResId;
|
|
422
|
-
}
|
|
440
|
+
|
|
423
441
|
|
|
424
442
|
|
|
425
443
|
@ReactMethod
|
|
Binary file
|