clevertap-react-native 0.6.0 → 0.8.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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  Change Log
2
2
  ==========
3
+ Version 0.8.1 *(7th March 2022)*
4
+ -------------------------------------------
5
+ - Supports CleverTap iOS SDK `v4.0.0`
6
+ - Abstract out notification click callback logic for killed state in Android.
7
+
8
+ Version 0.8.0 *(17th January 2022)*
9
+ -------------------------------------------
10
+ - Supports [CleverTap Android SDK v4.4.0](https://github.com/CleverTap/clevertap-android-sdk/releases/tag/core-v4.4.0)
11
+
12
+ Version 0.7.0 *(30th November 2021)*
13
+ -------------------------------------------
14
+ - Supports CleverTap Android SDK `v4.3.1` backing Android 12
3
15
 
4
16
  Version 0.6.0 *(3rd September 2021)*
5
17
  -------------------------------------------
@@ -15,14 +15,14 @@ buildscript {
15
15
  }
16
16
 
17
17
  android {
18
- compileSdkVersion 30
18
+ compileSdkVersion 31
19
19
  buildToolsVersion '30.0.3'
20
20
 
21
21
  defaultConfig {
22
22
  minSdkVersion 16
23
- targetSdkVersion 30
24
- versionCode 60
25
- versionName "0.6.0"
23
+ targetSdkVersion 31
24
+ versionCode 80
25
+ versionName "0.8.0"
26
26
  }
27
27
  buildTypes {
28
28
  release {
@@ -39,11 +39,11 @@ dependencies {
39
39
  maven { url "$rootDir/../node_modules/react-native/android" }
40
40
  }
41
41
 
42
- api 'com.clevertap.android:clevertap-android-sdk:4.2.0'
43
- implementation 'com.android.installreferrer:installreferrer:2.1'
42
+ api 'com.clevertap.android:clevertap-android-sdk:4.4.0'
43
+ implementation 'com.android.installreferrer:installreferrer:2.2'
44
44
  //compile 'com.android.support:appcompat-v7:28.0.0'
45
45
  implementation 'com.facebook.react:react-native:+'
46
- compileOnly 'androidx.annotation:annotation:1.1.0'
46
+ compileOnly 'androidx.annotation:annotation:1.2.0'
47
47
  }
48
48
 
49
49
  repositories {
@@ -0,0 +1,79 @@
1
+ package com.clevertap.react;
2
+
3
+ import static com.clevertap.react.CleverTapUtils.getWritableMapFromMap;
4
+
5
+ import android.os.Handler;
6
+ import android.os.Looper;
7
+ import android.util.Log;
8
+ import com.clevertap.android.sdk.Application;
9
+ import com.clevertap.android.sdk.CleverTapAPI;
10
+ import com.clevertap.android.sdk.pushnotification.CTPushNotificationListener;
11
+ import com.facebook.react.ReactApplication;
12
+ import com.facebook.react.ReactInstanceManager;
13
+ import com.facebook.react.bridge.Arguments;
14
+ import com.facebook.react.bridge.ReactContext;
15
+ import com.facebook.react.bridge.WritableMap;
16
+ import com.facebook.react.modules.core.DeviceEventManagerModule;
17
+ import java.util.HashMap;
18
+ import java.util.Iterator;
19
+ import java.util.Map;
20
+ import org.json.JSONObject;
21
+
22
+ public class CleverTapApplication extends Application implements CTPushNotificationListener {
23
+ private static final String TAG = "CleverTapApplication";
24
+ @Override
25
+ public void onCreate() {
26
+ super.onCreate();
27
+ CleverTapAPI.getDefaultInstance(this)
28
+ .setCTPushNotificationListener(this);// Workaround when app is in killed state
29
+ }
30
+
31
+ //Push Notification Clicked callback workaround when app is in killed state
32
+ @Override
33
+ public void onNotificationClickedPayloadReceived(final HashMap<String, Object> payload) {
34
+ Log.e(TAG, "onNotificationClickedPayloadReceived called");
35
+ final String CLEVERTAP_PUSH_NOTIFICATION_CLICKED = "CleverTapPushNotificationClicked";
36
+
37
+ Handler handler = new Handler(Looper.getMainLooper());
38
+ handler.post(new Runnable() {
39
+ public void run() {
40
+
41
+ // Construct and load our normal React JS code bundle
42
+ final ReactInstanceManager mReactInstanceManager = ((ReactApplication) getApplicationContext())
43
+ .getReactNativeHost().getReactInstanceManager();
44
+ ReactContext context = mReactInstanceManager.getCurrentReactContext();
45
+ // If it's constructed, send a notification
46
+ if (context != null) {
47
+ sendEvent(CLEVERTAP_PUSH_NOTIFICATION_CLICKED, getWritableMapFromMap(payload), context);
48
+ } else {
49
+ // Otherwise wait for construction, then send the notification
50
+ mReactInstanceManager
51
+ .addReactInstanceEventListener(new ReactInstanceManager.ReactInstanceEventListener() {
52
+ public void onReactContextInitialized(ReactContext context) {
53
+ sendEvent(CLEVERTAP_PUSH_NOTIFICATION_CLICKED, getWritableMapFromMap(payload),
54
+ context);
55
+ mReactInstanceManager.removeReactInstanceEventListener(this);
56
+ }
57
+ });
58
+ if (!mReactInstanceManager.hasStartedCreatingInitialContext()) {
59
+ // Construct it in the background
60
+ mReactInstanceManager.createReactContextInBackground();
61
+ }
62
+ }
63
+
64
+ }
65
+ });
66
+
67
+ }
68
+
69
+ private void sendEvent(String eventName, Object params, ReactContext context) {
70
+ try {
71
+ context.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
72
+ .emit(eventName, params);
73
+ Log.e(TAG, "Sending event "+eventName);
74
+ } catch (Throwable t) {
75
+ Log.e(TAG, t.getLocalizedMessage());
76
+ }
77
+ }
78
+
79
+ }
@@ -1,5 +1,7 @@
1
1
  package com.clevertap.react;
2
2
 
3
+ import static com.clevertap.react.CleverTapUtils.getWritableMapFromMap;
4
+
3
5
  import android.location.Location;
4
6
  import android.net.Uri;
5
7
  import android.os.Build.VERSION;
@@ -1406,28 +1408,6 @@ public class CleverTapModule extends ReactContextBaseJavaModule implements SyncL
1406
1408
  return writableArray;
1407
1409
  }
1408
1410
 
1409
- @SuppressWarnings({"TypeParameterExplicitlyExtendsObject", "rawtypes"})
1410
- private WritableMap getWritableMapFromMap(Map<String, ? extends Object> var1) {
1411
- JSONObject extras = var1 != null ? new JSONObject(var1) : new JSONObject();
1412
- WritableMap extrasParams = Arguments.createMap();
1413
- Iterator extrasKeys = extras.keys();
1414
- while (extrasKeys.hasNext()) {
1415
- String key = null;
1416
- String value = null;
1417
- try {
1418
- key = extrasKeys.next().toString();
1419
- value = extras.get(key).toString();
1420
- } catch (Throwable t) {
1421
- Log.e(TAG, t.getLocalizedMessage());
1422
- }
1423
-
1424
- if (key != null && value != null) {
1425
- extrasParams.putString(key, value);
1426
- }
1427
- }
1428
- return extrasParams;
1429
- }
1430
-
1431
1411
  private HashMap<String, Object> profileFromReadableMap(ReadableMap profileMap) {
1432
1412
  if (profileMap == null) {
1433
1413
  return null;
@@ -0,0 +1,36 @@
1
+ package com.clevertap.react;
2
+
3
+ import android.util.Log;
4
+ import com.facebook.react.bridge.Arguments;
5
+ import com.facebook.react.bridge.WritableMap;
6
+ import java.util.Iterator;
7
+ import java.util.Map;
8
+ import org.json.JSONObject;
9
+
10
+ public class CleverTapUtils {
11
+
12
+ private static final String TAG = "CleverTapUtils";
13
+
14
+ @SuppressWarnings({"TypeParameterExplicitlyExtendsObject", "rawtypes"})
15
+ public static WritableMap getWritableMapFromMap(Map<String, ? extends Object> var1) {
16
+ JSONObject extras = var1 != null ? new JSONObject(var1) : new JSONObject();
17
+ WritableMap extrasParams = Arguments.createMap();
18
+ Iterator extrasKeys = extras.keys();
19
+ while (extrasKeys.hasNext()) {
20
+ String key = null;
21
+ String value = null;
22
+ try {
23
+ key = extrasKeys.next().toString();
24
+ value = extras.get(key).toString();
25
+ } catch (Throwable t) {
26
+ Log.e(TAG, t.getLocalizedMessage());
27
+ }
28
+
29
+ if (key != null && value != null) {
30
+ extrasParams.putString(key, value);
31
+ }
32
+ }
33
+ return extrasParams;
34
+ }
35
+
36
+ }
@@ -18,6 +18,6 @@ Pod::Spec.new do |s|
18
18
  s.preserve_paths = 'LICENSE.md', 'README.md', 'package.json', 'index.js'
19
19
  s.source_files = 'ios/CleverTapReact/*.{h,m}'
20
20
 
21
- s.dependency 'CleverTap-iOS-SDK', '3.10.0'
22
- s.dependency 'React'
21
+ s.dependency 'CleverTap-iOS-SDK', '4.0.0'
22
+ s.dependency 'React-Core'
23
23
  end
package/docs/install.md CHANGED
@@ -60,21 +60,21 @@ If you're on RN 0.60 or your project configuration doesn't allow to add `use_fra
60
60
  ```gradle
61
61
  dependencies {
62
62
  ...
63
- implementation 'com.clevertap.android:clevertap-android-sdk:4.2.0'
64
- implementation 'com.google.android.gms:play-services-base:17.4.0'
65
- implementation 'com.google.firebase:firebase-messaging:20.2.4'
66
- implementation 'com.google.android.exoplayer:exoplayer:2.11.5' //Optional for Audio/Video
67
- implementation 'com.google.android.exoplayer:exoplayer-hls:2.11.5' //Optional for Audio/Video
68
- implementation 'com.google.android.exoplayer:exoplayer-ui:2.11.5' //Optional for Audio/Video
69
- implementation 'com.github.bumptech.glide:glide:4.11.0' //Mandatory for App Inbox
70
- implementation 'androidx.recyclerview:recyclerview:1.1.0' //Mandatory for App Inbox
63
+ implementation 'com.clevertap.android:clevertap-android-sdk:4.4.0'
64
+ implementation 'com.google.android.gms:play-services-base:17.6.0'
65
+ implementation 'com.google.firebase:firebase-messaging:21.0.0'
66
+ implementation 'com.google.android.exoplayer:exoplayer:2.15.1' //Optional for Audio/Video
67
+ implementation 'com.google.android.exoplayer:exoplayer-hls:2.15.1' //Optional for Audio/Video
68
+ implementation 'com.google.android.exoplayer:exoplayer-ui:2.15.1' //Optional for Audio/Video
69
+ implementation 'com.github.bumptech.glide:glide:4.12.0' //Mandatory for App Inbox
70
+ implementation 'androidx.recyclerview:recyclerview:1.2.1' //Mandatory for App Inbox
71
71
  implementation 'androidx.viewpager:viewpager:1.0.0' //Mandatory for App Inbox
72
- implementation 'com.google.android.material:material:1.2.1' //Mandatory for App Inbox
73
- implementation 'androidx.appcompat:appcompat:1.2.0' //Mandatory for App Inbox
72
+ implementation 'com.google.android.material:material:1.4.0' //Mandatory for App Inbox
73
+ implementation 'androidx.appcompat:appcompat:1.3.1' //Mandatory for App Inbox
74
74
  implementation 'androidx.core:core:1.3.0'
75
- implementation 'androidx.fragment:fragment:1.1.0' // InApp
75
+ implementation 'androidx.fragment:fragment:1.3.6' // InApp
76
76
  //Mandatory for React Native SDK v0.3.9 and above add the following -
77
- implementation 'com.android.installreferrer:installreferrer:2.1'
77
+ implementation 'com.android.installreferrer:installreferrer:2.2'
78
78
 
79
79
  //Note - ExoPlayer dependencies are optional but all 3 are required for Audio/Video Inbox and InApp Messages
80
80
  }
@@ -17,7 +17,7 @@ NOTE: Don't forget to add the CleverTap imports at the top of the file.
17
17
 
18
18
  Note: Need to use **@import CleverTapSDK;** instead of **#import <CleverTapSDK/CleverTap.h>** and **@import CleverTapReact;** instead of **#import <CleverTapReact/CleverTapReactManager.h>** in the AppDelegate class in case if using ```use_modular_headers!``` in the podfile.
19
19
 
20
- [See the Example Project](https://github.com/CleverTap/clevertap-react-native/blob/master/ExampleProject/ios/ExampleProject/AppDelegate.m).
20
+ [See the Example Project](/Example/ios/Example/AppDelegate.m).
21
21
 
22
22
  ### Android
23
23
  1. Follow the integration instructions [starting with Step 2 here](https://support.clevertap.com/docs/android/getting-started.html).
@@ -71,5 +71,17 @@ Note: Need to use **@import CleverTapSDK;** instead of **#import <CleverTapSDK/C
71
71
  // ...
72
72
  }
73
73
  ```
74
+ 4. From clevertap-react-native **v0.8.1** onwards developers can make their `Application` class extend `CleverTapApplication` to support Push Notification click callback out of the box and to register activity lifecycle events. Before v0.8.1 developers were forced to write logic for push click callback and register activity lifecycle to their `Application` class manually which is being abstract out in `CleverTapApplication` class.
75
+
76
+ ```
77
+ import com.clevertap.react.CleverTapApplication;
78
+ // other imports
79
+
80
+ public class MainApplication extends CleverTapApplication
81
+ implements ActivityLifecycleCallbacks, ReactApplication
82
+ {
83
+ // ...
84
+ }
85
+ ```
74
86
  [see the included Example Project](/Example/App.js)
75
87
 
package/docs/usage.md CHANGED
@@ -352,6 +352,12 @@ CleverTap.profileGetProperty('Name', (err, res) => {
352
352
 
353
353
  -----------
354
354
 
355
+ ## Debugging
356
+
357
+ ```javascript
358
+ CleverTap.setDebugLevel(3);
359
+ ```
360
+
355
361
  ## Attributions
356
362
 
357
363
  #### Get CleverTap Attribution Identifier
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clevertap-react-native",
3
- "version": "0.6.0",
3
+ "version": "0.8.1",
4
4
  "description": "CleverTap React Native SDK.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -36,7 +36,7 @@
36
36
  "extract-zip": "^1.6.6"
37
37
  },
38
38
  "peerDependencies": {
39
- "react-native": ">=0.47.0"
39
+ "react-native": ">=0.63.3"
40
40
  },
41
41
  "devDependencies": {
42
42
  "eslint": "^4.18.2",
@@ -47,7 +47,7 @@
47
47
  "eslint-plugin-react": "^6.2.0",
48
48
  "eslint-plugin-standard": "^2.0.0",
49
49
  "i": "^0.3.6",
50
- "react": "^16.3.2",
50
+ "react": "^17.0.2",
51
51
  "react-native": "^0.49.5"
52
52
  }
53
53
  }