diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c68c82d..857b4e00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,28 @@ Change Log ========== +Version 2.2.1 *(12 April 2024)* +------------------------------------------- +**What's new** + +* **[Android Platform]** + * Supports [CleverTap Android SDK v6.2.1](https://github.com/CleverTap/clevertap-android-sdk/blob/master/docs/CTCORECHANGELOG.md#version-621-april-11-2024). + +* **[iOS Platform]** + * Supports [CleverTap iOS SDK v6.2.1](https://github.com/CleverTap/clevertap-ios-sdk/blob/master/CHANGELOG.md#version-621-april-12-2024). + +**Bug Fixes** +* **[Android Platform]** + * Fixes a crash due to `IllegalArgumentException` caused by allowedPushType `XPS` enum. + +* **[iOS Platform]** + * Fixes a build error related to privacy manifests when statically linking the SDK using Cocoapods. + + Version 2.2.0 *(5 April 2024)* ------------------------------------------- +> ⚠️ **NOTE** +2.2.0 produces a crash, please update to 2.2.1 and above. + **What's new** * **[Android Platform]** diff --git a/Example/android/app/build.gradle b/Example/android/app/build.gradle index 8ec8f2c8..513f6659 100644 --- a/Example/android/app/build.gradle +++ b/Example/android/app/build.gradle @@ -218,7 +218,7 @@ dependencies { //clevertap - implementation 'com.clevertap.android:clevertap-android-sdk:6.2.0' + implementation 'com.clevertap.android:clevertap-android-sdk:6.2.1' implementation "com.clevertap.android:push-templates:1.2.3" implementation project(':clevertap-react-native') diff --git a/android/build.gradle b/android/build.gradle index 265d42a5..91f87e3b 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -20,8 +20,8 @@ android { defaultConfig { minSdkVersion 19 targetSdkVersion 34 - versionCode 220 - versionName "2.2.0" + versionCode 221 + versionName "2.2.1" } namespace 'com.clevertap.react' @@ -40,7 +40,7 @@ dependencies { maven { url "$rootDir/../node_modules/react-native/android" } } - api 'com.clevertap.android:clevertap-android-sdk:6.2.0' + api 'com.clevertap.android:clevertap-android-sdk:6.2.1' 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/clevertap-react-native.podspec b/clevertap-react-native.podspec index 46e6c81f..e50dbe91 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', '6.2.0' + s.dependency 'CleverTap-iOS-SDK', '6.2.1' s.dependency 'React-Core' end diff --git a/index.js b/index.js index d22a2b02..f85cc5a6 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 = 20200; +const libVersion = 20201; CleverTapReact.setLibrary(libName,libVersion); function defaultCallback(method, err, res) { diff --git a/ios/CleverTapReact.xcodeproj/project.pbxproj b/ios/CleverTapReact.xcodeproj/project.pbxproj index 83b94f5c..61043965 100644 --- a/ios/CleverTapReact.xcodeproj/project.pbxproj +++ b/ios/CleverTapReact.xcodeproj/project.pbxproj @@ -17,6 +17,8 @@ 5266DAB91E4B9C16000008F5 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5266DAB61E4B9B8C000008F5 /* UIKit.framework */; }; 5266DABA1E4B9C20000008F5 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 52DFC6831E4B990A00EDC368 /* SystemConfiguration.framework */; }; 5266DADB1E4BB5BD000008F5 /* CleverTapSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5266DAD91E4BB598000008F5 /* CleverTapSDK.framework */; }; + 6B587A032BC02ECD0077493E /* CleverTapReactPendingEvent.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B587A022BC02ECD0077493E /* CleverTapReactPendingEvent.m */; }; + 6B587A042BC02ECD0077493E /* CleverTapReactPendingEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B587A012BC02ECD0077493E /* CleverTapReactPendingEvent.h */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -45,6 +47,8 @@ 52DFC6831E4B990A00EDC368 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; 52DFC6851E4B991000EDC368 /* CoreTelephony.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreTelephony.framework; path = System/Library/Frameworks/CoreTelephony.framework; sourceTree = SDKROOT; }; 5D72D2E81C16249000E22EC1 /* libCleverTapReact.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libCleverTapReact.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 6B587A012BC02ECD0077493E /* CleverTapReactPendingEvent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CleverTapReactPendingEvent.h; sourceTree = ""; }; + 6B587A022BC02ECD0077493E /* CleverTapReactPendingEvent.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CleverTapReactPendingEvent.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -71,6 +75,8 @@ 52344FBC1E4CE7F000661762 /* CleverTapReactManager.m */, 52344FDE1E4D0F3700661762 /* CleverTapReactEventEmitter.h */, 52344FDF1E4D0F3700661762 /* CleverTapReactEventEmitter.m */, + 6B587A012BC02ECD0077493E /* CleverTapReactPendingEvent.h */, + 6B587A022BC02ECD0077493E /* CleverTapReactPendingEvent.m */, ); path = CleverTapReact; sourceTree = ""; @@ -111,6 +117,7 @@ buildActionMask = 2147483647; files = ( 52344FC21E4CEC3200661762 /* CleverTapReactManager.h in Headers */, + 6B587A042BC02ECD0077493E /* CleverTapReactPendingEvent.h in Headers */, 52344FE01E4D0F3700661762 /* CleverTapReactEventEmitter.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; @@ -176,6 +183,7 @@ 52344FBF1E4CE7F000661762 /* CleverTapReactManager.m in Sources */, 52344FE11E4D0F3700661762 /* CleverTapReactEventEmitter.m in Sources */, 52344FBE1E4CE7F000661762 /* CleverTapReact.m in Sources */, + 6B587A032BC02ECD0077493E /* CleverTapReactPendingEvent.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/ios/CleverTapReact/CleverTapReactEventEmitter.h b/ios/CleverTapReact/CleverTapReactEventEmitter.h index c51caeec..b61dc8f6 100644 --- a/ios/CleverTapReact/CleverTapReactEventEmitter.h +++ b/ios/CleverTapReact/CleverTapReactEventEmitter.h @@ -2,4 +2,6 @@ @interface CleverTapReactEventEmitter : RCTEventEmitter ++ (void)sendEventOnObserving:(NSString *)name body:(id)body; + @end diff --git a/ios/CleverTapReact/CleverTapReactEventEmitter.m b/ios/CleverTapReact/CleverTapReactEventEmitter.m index ba968827..b06931eb 100644 --- a/ios/CleverTapReact/CleverTapReactEventEmitter.m +++ b/ios/CleverTapReact/CleverTapReactEventEmitter.m @@ -1,102 +1,46 @@ #import "CleverTapReactEventEmitter.h" +#import "CleverTapReactPendingEvent.h" #import "CleverTapReact.h" - #import +static NSMutableArray *pendingEvents; +static BOOL isObserving; + @implementation CleverTapReactEventEmitter RCT_EXPORT_MODULE(); ++ (void)sendEventOnObserving:(NSString *)name body:(id)body { + if (isObserving) { + [[NSNotificationCenter defaultCenter] postNotificationName:name object:nil userInfo:body]; + return; + } + + if (!pendingEvents) { + pendingEvents = [NSMutableArray array]; + } + + CleverTapReactPendingEvent *event = [[CleverTapReactPendingEvent alloc] initWithName:name body:body]; + [pendingEvents addObject:event]; +} + - (NSArray *)supportedEvents { return @[kCleverTapProfileDidInitialize, kCleverTapProfileSync, kCleverTapInAppNotificationDismissed, kCleverTapInboxDidInitialize, kCleverTapInboxMessagesDidUpdate, kCleverTapInAppNotificationButtonTapped, kCleverTapInboxMessageButtonTapped, kCleverTapInboxMessageTapped, kCleverTapDisplayUnitsLoaded, kCleverTapFeatureFlagsDidUpdate, kCleverTapProductConfigDidFetch, kCleverTapProductConfigDidActivate, kCleverTapProductConfigDidInitialize, kCleverTapPushNotificationClicked, kCleverTapPushPermissionResponseReceived, kCleverTapInAppNotificationShowed, kCleverTapOnVariablesChanged, kCleverTapOnValueChanged]; } - - (void)startObserving { - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(emitEventInternal:) - name:kCleverTapProfileDidInitialize - object:nil]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(emitEventInternal:) - name:kCleverTapProfileSync - object:nil]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(emitEventInternal:) - name:kCleverTapInAppNotificationDismissed - object:nil]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(emitEventInternal:) - name:kCleverTapInboxDidInitialize - object:nil]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(emitEventInternal:) - name:kCleverTapInboxMessagesDidUpdate - object:nil]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(emitEventInternal:) - name:kCleverTapDisplayUnitsLoaded - object:nil]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(emitEventInternal:) - name:kCleverTapInAppNotificationButtonTapped - object:nil]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(emitEventInternal:) - name:kCleverTapInboxMessageButtonTapped - object:nil]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(emitEventInternal:) - name:kCleverTapInboxMessageTapped - object:nil]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(emitEventInternal:) - name:kCleverTapFeatureFlagsDidUpdate - object:nil]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(emitEventInternal:) - name:kCleverTapProductConfigDidFetch - object:nil]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(emitEventInternal:) - name:kCleverTapProductConfigDidActivate - object:nil]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(emitEventInternal:) - name:kCleverTapProductConfigDidInitialize - object:nil]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(emitEventInternal:) - name:kCleverTapPushNotificationClicked - object:nil]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(emitEventInternal:) - name:kCleverTapPushPermissionResponseReceived - object:nil]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(emitEventInternal:) - name:kCleverTapOnVariablesChanged - object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(emitEventInternal:) - name:kCleverTapOnValueChanged - object:nil]; + NSArray *eventNames = [self supportedEvents]; + for (NSString *eventName in eventNames) { + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(emitEventInternal:) + name:eventName + object:nil]; + } + + isObserving = YES; + for (CleverTapReactPendingEvent *ev in pendingEvents) { + [[NSNotificationCenter defaultCenter] postNotificationName:ev.name object:nil userInfo:ev.body]; + } } - (void)stopObserving { diff --git a/ios/CleverTapReact/CleverTapReactManager.m b/ios/CleverTapReact/CleverTapReactManager.m index d9212b1b..04de3383 100644 --- a/ios/CleverTapReact/CleverTapReactManager.m +++ b/ios/CleverTapReact/CleverTapReactManager.m @@ -17,7 +17,7 @@ #import "CleverTapPushNotificationDelegate.h" #import "CleverTapInAppNotificationDelegate.h" #import "CleverTap+PushPermission.h" - +#import "CleverTapReactEventEmitter.h" @interface CleverTapReactManager() { } @@ -75,7 +75,7 @@ - (void)applicationDidLaunchWithOptions:(NSDictionary *)options { #pragma mark - Private - (void)postNotificationWithName:(NSString *)name andBody:(NSDictionary *)body { - [[NSNotificationCenter defaultCenter] postNotificationName:name object:nil userInfo:body]; + [CleverTapReactEventEmitter sendEventOnObserving:name body:body]; } diff --git a/ios/CleverTapReact/CleverTapReactPendingEvent.h b/ios/CleverTapReact/CleverTapReactPendingEvent.h new file mode 100644 index 00000000..0cabb612 --- /dev/null +++ b/ios/CleverTapReact/CleverTapReactPendingEvent.h @@ -0,0 +1,14 @@ +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface CleverTapReactPendingEvent : NSObject + +@property (nonatomic, strong) NSString *name; +@property (nonatomic, strong) id body; + +- (instancetype)initWithName:(NSString *)name body:(id)body; + +@end + +NS_ASSUME_NONNULL_END diff --git a/ios/CleverTapReact/CleverTapReactPendingEvent.m b/ios/CleverTapReact/CleverTapReactPendingEvent.m new file mode 100644 index 00000000..635d869b --- /dev/null +++ b/ios/CleverTapReact/CleverTapReactPendingEvent.m @@ -0,0 +1,14 @@ +#import "CleverTapReactPendingEvent.h" + +@implementation CleverTapReactPendingEvent + +- (instancetype)initWithName:(NSString *)name body:(id)body { + self = [super init]; + if (self) { + _name = name; + _body = body; + } + return self; +} + +@end diff --git a/package.json b/package.json index d9469332..0f575783 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "clevertap-react-native", - "version": "2.2.0", + "version": "2.2.1", "description": "CleverTap React Native SDK.", "main": "index.js", "types": "index.d.ts",