diff --git a/CHANGELOG.md b/CHANGELOG.md index c2e35b4d..21242a2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,33 @@ Change Log ========== +Version 2.0.0 *(15 February 2024)* +------------------------------------------- +**What's new** +* **[Android Platform]** + * Supports [CleverTap Android SDK v6.0.0](https://github.com/CleverTap/clevertap-android-sdk/blob/master/docs/CTCORECHANGELOG.md#version-600-january-15-2024). + +* **[iOS Platform]** + * Supports [CleverTap iOS SDK v6.0.0](https://github.com/CleverTap/clevertap-ios-sdk/releases/tag/6.0.0). + +* **[Android and iOS Platform]** + * Adds support for client-side in-apps. + * Adds new API `clearInAppResources(boolean)` to delete images and gifs which are preloaded for inapps in cs mode + * Adds new API `fetchInApps()` to explicitly fetch InApps from the server + +**Bug Fixes** +* **[Android Platform]** + * Fixes a bug where JavaScript was not working for custom-html InApp header/footer templates. + * Fixes an NPE related to AppInbox APIs. + * Fixes a ClassCastException in defineVariable API of Product Experiences. + * Fixes a resource name conflict with the firebase library in fcm_fallback_notification_channel_label + * Fixes a StrictMode Violation spawning from ctVariables.init(). + * Removes use of lossy conversions leading to an issue in PushTemplates. + * Handles an edge case related to migration of encryption level when local db is out of memory + +* **[iOS Platform]** + * Fixes a bug where some in-apps were not being dismissed. + Version 1.2.1 *(25 October 2023)* ------------------------------------------- **What's new** diff --git a/Example/App.js b/Example/App.js index 452c48d9..48601d26 100644 --- a/Example/App.js +++ b/Example/App.js @@ -480,6 +480,17 @@ class Expandable_ListView extends Component { console.log('onValueChanged: ', variable); }); break; + case 87: + CleverTap.fetchInApps((err, success) => { + console.log('fetchInApps result: ', success); + }); + break; + case 88: + CleverTap.clearInAppResources(false); + break; + case 89: + CleverTap.clearInAppResources(true); + break; } } @@ -597,6 +608,15 @@ export default class App extends Component { } ], }, + { + expanded: false, + category_Name: 'Client Side InApps', + sub_Category: [ + {id: 87, name: 'Fetch Client Side InApps'}, + {id: 88, name: 'Clear All InApp Resources'}, + {id: 89, name: 'Clear Expired Only InApp Resources'} + ], + }, { expanded: false, category_Name: 'User Properties', diff --git a/Example/android/app/build.gradle b/Example/android/app/build.gradle index 1474dd01..87f6f26b 100644 --- a/Example/android/app/build.gradle +++ b/Example/android/app/build.gradle @@ -211,15 +211,15 @@ dependencies { implementation 'com.google.android.gms:play-services-base:18.2.0' implementation 'com.google.firebase:firebase-messaging:23.0.6' implementation 'com.google.android.material:material:1.4.0' //Mandatory for App Inbox - implementation 'com.google.android.exoplayer:exoplayer:2.17.1' //Optional for Audio/Video - implementation 'com.google.android.exoplayer:exoplayer-hls:2.17.1' //Optional for Audio/Video - implementation 'com.google.android.exoplayer:exoplayer-ui:2.17.1' //Optional for Audio/Video + implementation 'com.google.android.exoplayer:exoplayer:2.19.1' //Optional for Audio/Video + implementation 'com.google.android.exoplayer:exoplayer-hls:2.19.1' //Optional for Audio/Video + implementation 'com.google.android.exoplayer:exoplayer-ui:2.19.1' //Optional for Audio/Video //implementation 'com.google.android.gms:play-services-ads:19.0.1' //clevertap - implementation 'com.clevertap.android:clevertap-android-sdk:5.2.1' - implementation "com.clevertap.android:push-templates:1.0.9" + implementation 'com.clevertap.android:clevertap-android-sdk:6.0.0' + implementation "com.clevertap.android:push-templates:1.2.2" implementation project(':clevertap-react-native') diff --git a/Example/ios/Example.xcodeproj/project.pbxproj b/Example/ios/Example.xcodeproj/project.pbxproj index bd6cceff..dc029414 100644 --- a/Example/ios/Example.xcodeproj/project.pbxproj +++ b/Example/ios/Example.xcodeproj/project.pbxproj @@ -498,7 +498,7 @@ /* Begin PBXShellScriptBuildPhase section */ 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */ = { isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; + buildActionMask = 12; files = ( ); inputPaths = ( @@ -508,7 +508,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "if [[ -s \"$HOME/.nvm/nvm.sh\" ]]; then\n. \"$HOME/.nvm/nvm.sh\"\nelif [[ -x \"$(command -v brew)\" && -s \"$(brew --prefix nvm)/nvm.sh\" ]]; then\n. \"$(brew --prefix nvm)/nvm.sh\"\nfi\n\nexport NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh\n"; + shellScript = "if [[ -s \"$HOME/.nvm/nvm.sh\" ]]; then\n. \"$HOME/.nvm/nvm.sh\"\nelif [[ -x \"$(command -v brew)\" && -s \"$(brew --prefix nvm)/nvm.sh\" ]]; then\n. \"$(brew --prefix nvm)/nvm.sh\"\nfi\n\nexport NODE_BINARY=/Users/aishwarya.nanna/.nvm/versions/node/v18.0.0/bin/node\n../node_modules/react-native/scripts/react-native-xcode.sh\n"; }; 0EFB3D8FAA2BBF06F665EFA1 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; diff --git a/Example/ios/Example.xcworkspace/contents.xcworkspacedata b/Example/ios/Example.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..a37cf193 --- /dev/null +++ b/Example/ios/Example.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/Example/ios/Example.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Example/ios/Example.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/Example/ios/Example.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/android/build.gradle b/android/build.gradle index 0ca0109c..ecd2ca98 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -21,8 +21,8 @@ android { defaultConfig { minSdkVersion 19 targetSdkVersion 33 - versionCode 121 - versionName "1.2.1" + versionCode 200 + versionName "2.0.0" } buildTypes { release { @@ -39,7 +39,7 @@ dependencies { maven { url "$rootDir/../node_modules/react-native/android" } } - api 'com.clevertap.android:clevertap-android-sdk:5.2.1' + api 'com.clevertap.android:clevertap-android-sdk:6.0.0' implementation 'com.android.installreferrer:installreferrer:2.2' //compile 'com.android.support:appcompat-v7:28.0.0' implementation 'com.facebook.react:react-native:+' diff --git a/android/src/main/java/com/clevertap/react/CleverTapModule.java b/android/src/main/java/com/clevertap/react/CleverTapModule.java index eca44a33..680a05e7 100644 --- a/android/src/main/java/com/clevertap/react/CleverTapModule.java +++ b/android/src/main/java/com/clevertap/react/CleverTapModule.java @@ -41,6 +41,7 @@ import com.clevertap.android.sdk.variables.callbacks.FetchVariablesCallback; import com.clevertap.android.sdk.variables.callbacks.VariableCallback; import com.clevertap.android.sdk.variables.callbacks.VariablesChangedCallback; +import com.clevertap.android.sdk.inapp.callbacks.FetchInAppsCallback; import com.facebook.react.bridge.Arguments; import com.facebook.react.bridge.Callback; import com.facebook.react.bridge.ReactApplicationContext; @@ -1547,6 +1548,30 @@ public void variablesChanged() { } } + @ReactMethod + public void clearInAppResources(final boolean expiredOnly) { + CleverTapAPI cleverTap = getCleverTapAPI(); + if (cleverTap != null) { + cleverTap.clearInAppResources(expiredOnly); + } + } + + @ReactMethod + public void fetchInApps(final Callback callback) { + CleverTapAPI cleverTap = getCleverTapAPI(); + if (cleverTap != null) { + cleverTap.fetchInApps(new FetchInAppsCallback() { + @Override + public void onInAppsFetched(final boolean isSuccess) { + callbackWithErrorAndResult(callback, null, isSuccess); + } + }); + } else { + String error = ErrorMessages.CLEVERTAP_NOT_INITIALIZED.getErrorMessage(); + callbackWithErrorAndResult(callback, error, null); + } + } + /************************************************ * Product Experience Remote Config methods ends ************************************************/ diff --git a/clevertap-react-native.podspec b/clevertap-react-native.podspec index 63e8d83f..e911284f 100644 --- a/clevertap-react-native.podspec +++ b/clevertap-react-native.podspec @@ -18,6 +18,6 @@ Pod::Spec.new do |s| s.preserve_paths = 'LICENSE.md', 'README.md', 'package.json', 'index.js' s.source_files = 'ios/CleverTapReact/*.{h,m}' - s.dependency 'CleverTap-iOS-SDK', '5.2.1' + s.dependency 'CleverTap-iOS-SDK', '6.0.0' s.dependency 'React-Core' end diff --git a/index.d.ts b/index.d.ts index 1f94b781..00fd84b9 100644 --- a/index.d.ts +++ b/index.d.ts @@ -756,6 +756,21 @@ export function isPushPermissionGranted(callback: CallbackString): void; */ export function onValueChanged(name: string, handler: Function): void; + + /** + * Fetches In Apps from server. + * + * @param {function(err, res)} callback a callback with a boolean flag whether the fetching was successful + */ + export function fetchInApps(callback: Callback): void; + + /** + * Deletes all images and gifs which are preloaded for inapps in cs mode + * + * @param {boolean} expiredOnly to clear only assets which will not be needed further for inapps + */ + export function clearInAppResources(expiredOnly: boolean): void; + /******************* * Developer Options ******************/ diff --git a/index.js b/index.js index 995a79ad..01c30312 100644 --- a/index.js +++ b/index.js @@ -9,7 +9,7 @@ const EventEmitter = NativeModules.CleverTapReactEventEmitter ? new NativeEventE * @param {int} libVersion - The updated library version. If current version is 1.1.0 then pass as 10100 */ const libName = 'React-Native'; -const libVersion = 10201; +const libVersion = 20000; CleverTapReact.setLibrary(libName,libVersion); function defaultCallback(method, err, res) { @@ -949,6 +949,24 @@ var CleverTap = { onValueChanged: function (name, handler) { CleverTapReact.onValueChanged(name); this.addListener(CleverTapReact.CleverTapOnValueChanged, handler); + }, + + /** + * Fetches In Apps from server. + * + * @param callback {function(err, res)} a callback with a boolean flag whether the update was successful + */ + fetchInApps: function (callback) { + callWithCallback('fetchInApps', null, callback); + }, + + /** + * Deletes all images and gifs which are preloaded for inapps in cs mode + * + * @param {boolean} expiredOnly to clear only assets which will not be needed further for inapps + */ + clearInAppResources: function(expiredOnly) { + CleverTapReact.clearInAppResources(expiredOnly); } }; diff --git a/install.js b/install.js deleted file mode 100644 index 8f507e40..00000000 --- a/install.js +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env node - -const fs = require('fs') -const path = require('path') -const extract = require('extract-zip') - -const sdkPath = path.join(__dirname, 'ios/CleverTapReact/'); -const zipFile = sdkPath+'CleverTapSDK.framework.zip'; -const errMsg = "error unzipping CleverTapSDK.framework.zip in " + sdkPath + " please unzip manually"; - -fs.access(zipFile, (err) => { - if (!err) { - extract(zipFile, {dir: sdkPath}, function (err) { - if (!err) { - fs.unlinkSync(zipFile); - } else { - console.log(err); - console.error(errMsg); - } - }); - } else { - console.error(err); - } -}); diff --git a/ios/CleverTapReact/CleverTapReact.m b/ios/CleverTapReact/CleverTapReact.m index 7f5862ab..e151c652 100644 --- a/ios/CleverTapReact/CleverTapReact.m +++ b/ios/CleverTapReact/CleverTapReact.m @@ -634,11 +634,16 @@ - (NSMutableDictionary *)getVariableValues { RCT_EXPORT_METHOD(showInbox:(NSDictionary*)styleConfig) { RCTLogInfo(@"[CleverTap Show Inbox]"); + UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow]; + UIViewController *mainViewController = keyWindow.rootViewController; + if (mainViewController.presentedViewController) { + RCTLogInfo(@"CleverTap : Could not present App Inbox because a view controller is already being presented."); + return; + } + CleverTapInboxViewController *inboxController = [[self cleverTapInstance] newInboxViewControllerWithConfig:[self _dictToInboxStyleConfig:styleConfig? styleConfig : nil] andDelegate:(id )self]; if (inboxController) { UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:inboxController]; - UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow]; - UIViewController *mainViewController = keyWindow.rootViewController; [mainViewController presentViewController:navigationController animated:YES completion:nil]; } } @@ -852,6 +857,20 @@ - (void)messageDidSelect:(CleverTapInboxMessage *_Nonnull)message atIndex:(int)i [[self cleverTapInstance] resumeInAppNotifications]; } +#pragma mark - InApp Controls + +RCT_EXPORT_METHOD(fetchInApps:(RCTResponseSenderBlock)callback) { + RCTLogInfo(@"[CleverTap fetchInApps]"); + [[self cleverTapInstance]fetchInApps:^(BOOL success) { + [self returnResult:@(success) withCallback:callback andError:nil]; + }]; +} + +RCT_EXPORT_METHOD(clearInAppResources:(BOOL)expiredOnly) { + RCTLogInfo(@"[CleverTap clearInAppResources"); + [[self cleverTapInstance] clearInAppResources: expiredOnly]; +} + #pragma mark - Push Permission - (CTLocalInApp*)_localInAppConfigFromReadableMap: (NSDictionary *)json { diff --git a/package.json b/package.json index d11520f3..6c5a8825 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,11 @@ { "name": "clevertap-react-native", - "version": "1.2.1", + "version": "2.0.0", "description": "CleverTap React Native SDK.", "main": "index.js", "types": "index.d.ts", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "postinstall": "node install.js", "lint": "./node_modules/.bin/eslint index.js */**.js", "lint-fix": "./node_modules/.bin/eslint --fix index.js */**.js" }, @@ -32,9 +31,6 @@ "react-native", "segmentation" ], - "dependencies": { - "extract-zip": "^1.6.6" - }, "peerDependencies": { "react-native": ">=0.63.3" },