From ebe1b76075903d3a641a0b30a5a646b924d02890 Mon Sep 17 00:00:00 2001 From: Jeriel Ng Date: Thu, 18 Apr 2024 10:06:04 -0400 Subject: [PATCH] Release version 9.2.0 --- BrazeProject/BrazeProject.tsx | 1 + .../BrazeProject.xcodeproj/project.pbxproj | 22 +- BrazeProject/ios/Podfile | 4 +- BrazeProject/ios/Podfile.lock | 40 +-- CHANGELOG.md | 9 + __tests__/index.test.js | 18 +- .../braze/reactbridge/BrazeReactBridgeImpl.kt | 322 ++++++------------ .../com/braze/reactbridge/BrazeReactBridge.kt | 130 ++++--- .../com/braze/reactbridge/BrazeReactBridge.kt | 130 ++++--- braze-react-native-sdk.podspec | 6 +- package.json | 2 +- src/NativeBrazeReactModule.ts | 2 +- 12 files changed, 308 insertions(+), 378 deletions(-) diff --git a/BrazeProject/BrazeProject.tsx b/BrazeProject/BrazeProject.tsx index 6732a86..74b6652 100644 --- a/BrazeProject/BrazeProject.tsx +++ b/BrazeProject/BrazeProject.tsx @@ -388,6 +388,7 @@ export const BrazeProject = (): ReactElement => { Braze.setCustomUserAttribute('objectAttr', { one: 1, two: 'too' }, false); Braze.setCustomUserAttribute('badArray', ['123', { one: 1, two: 2 }]); Braze.setCustomUserAttribute('badArray2', [true, 1, 'string', { one: 1 }]); + Braze.setCustomUserAttribute('nullValueAttr', null); showToast('Custom attributes set'); }; diff --git a/BrazeProject/ios/BrazeProject.xcodeproj/project.pbxproj b/BrazeProject/ios/BrazeProject.xcodeproj/project.pbxproj index 11e1f66..9e0f13e 100644 --- a/BrazeProject/ios/BrazeProject.xcodeproj/project.pbxproj +++ b/BrazeProject/ios/BrazeProject.xcodeproj/project.pbxproj @@ -343,6 +343,7 @@ EC9B92062B1F762B00C6BD5D /* Sources */, EC9B92072B1F762B00C6BD5D /* Frameworks */, EC9B92082B1F762B00C6BD5D /* Resources */, + 52AFEB2430ADE005545A32A8 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -526,6 +527,23 @@ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-BrazeProject/Pods-BrazeProject-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; + 52AFEB2430ADE005545A32A8 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-BrazeProjectPushStory/Pods-BrazeProjectPushStory-resources-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Copy Pods Resources"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-BrazeProjectPushStory/Pods-BrazeProjectPushStory-resources-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-BrazeProjectPushStory/Pods-BrazeProjectPushStory-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; 74F5EB337C713CD3201C3C4B /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -966,7 +984,6 @@ CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = 5GLZKGNWQ3; - ENABLE_USER_SCRIPT_SANDBOXING = YES; GCC_C_LANGUAGE_STANDARD = gnu17; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = BrazeProjectRichPush/Info.plist; @@ -1009,7 +1026,6 @@ CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = 5GLZKGNWQ3; - ENABLE_USER_SCRIPT_SANDBOXING = YES; GCC_C_LANGUAGE_STANDARD = gnu17; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = BrazeProjectRichPush/Info.plist; @@ -1050,7 +1066,6 @@ CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = 5GLZKGNWQ3; - ENABLE_USER_SCRIPT_SANDBOXING = YES; GCC_C_LANGUAGE_STANDARD = gnu17; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = BrazeProjectPushStory/Info.plist; @@ -1094,7 +1109,6 @@ CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = 5GLZKGNWQ3; - ENABLE_USER_SCRIPT_SANDBOXING = YES; GCC_C_LANGUAGE_STANDARD = gnu17; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = BrazeProjectPushStory/Info.plist; diff --git a/BrazeProject/ios/Podfile b/BrazeProject/ios/Podfile index 71381d8..ea08ddd 100644 --- a/BrazeProject/ios/Podfile +++ b/BrazeProject/ios/Podfile @@ -60,9 +60,9 @@ target 'BrazeProject' do end target 'BrazeProjectRichPush' do - pod 'BrazeNotificationService', '~> 8.1.0' + pod 'BrazeNotificationService', '~> 8.4.0' end target 'BrazeProjectPushStory' do - pod 'BrazePushStory', '~> 8.1.0' + pod 'BrazePushStory', '~> 8.4.0' end diff --git a/BrazeProject/ios/Podfile.lock b/BrazeProject/ios/Podfile.lock index c898b9b..bb63fd5 100644 --- a/BrazeProject/ios/Podfile.lock +++ b/BrazeProject/ios/Podfile.lock @@ -1,9 +1,9 @@ PODS: - boost (1.83.0) - - braze-react-native-sdk (9.1.0): - - BrazeKit (~> 8.2.1) - - BrazeLocation (~> 8.2.1) - - BrazeUI (~> 8.2.1) + - braze-react-native-sdk (9.2.0): + - BrazeKit (~> 8.4.0) + - BrazeLocation (~> 8.4.0) + - BrazeUI (~> 8.4.0) - glog - hermes-engine - RCT-Folly (= 2022.05.16.00) @@ -22,13 +22,13 @@ PODS: - ReactCommon/turbomodule/bridging - ReactCommon/turbomodule/core - Yoga - - BrazeKit (8.2.1) - - BrazeLocation (8.2.1): - - BrazeKit (= 8.2.1) - - BrazeNotificationService (8.1.0) - - BrazePushStory (8.1.0) - - BrazeUI (8.2.1): - - BrazeKit (= 8.2.1) + - BrazeKit (8.4.0) + - BrazeLocation (8.4.0): + - BrazeKit (= 8.4.0) + - BrazeNotificationService (8.4.0) + - BrazePushStory (8.4.0) + - BrazeUI (8.4.0): + - BrazeKit (= 8.4.0) - CocoaAsyncSocket (7.6.5) - DoubleConversion (1.1.6) - FBLazyVector (0.73.1) @@ -1187,8 +1187,8 @@ PODS: DEPENDENCIES: - boost (from `../node_modules/react-native/third-party-podspecs/boost.podspec`) - "braze-react-native-sdk (from `../node_modules/@braze/react-native-sdk`)" - - BrazeNotificationService (~> 8.1.0) - - BrazePushStory (~> 8.1.0) + - BrazeNotificationService (~> 8.4.0) + - BrazePushStory (~> 8.4.0) - DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`) - FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`) - Flipper (= 0.201.0) @@ -1395,12 +1395,12 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: boost: 26fad476bfa736552bbfa698a06cc530475c1505 - braze-react-native-sdk: 2f996f07959f2bb97604c1a2ca3b5b876a6f2e2f - BrazeKit: 45370af59da16595839b6229b82f974a6bdb3909 - BrazeLocation: aae9d0aac79d76f9cbe253de2cec1055b3119567 - BrazeNotificationService: a0dc917d52102b9387b24e4135cb3bf0305316c7 - BrazePushStory: b8a1ef9e28618cbd58658a93d603175a2cf5dbfd - BrazeUI: 49647ff0b180dcb7df3bc23206c02b2cb1629ec9 + braze-react-native-sdk: e48cd115d0015c452c56d8f65cbdc659e326edb7 + BrazeKit: 7aa946734211e8371c6525447db98406ded44402 + BrazeLocation: cb2a1befb02fc7ef180fdfd1287f985bf0e87b0d + BrazeNotificationService: 53534bdab87853b3304452440104e53a31c2fde8 + BrazePushStory: 29921e1bc55ed087af593506986782a88ca7e083 + BrazeUI: 794a1c0bb387f40763673af7da5cb076ec0e413b CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99 DoubleConversion: fea03f2699887d960129cc54bba7e52542b6f953 FBLazyVector: 2296bacb2fa157a43991048b0a9d71c1c8b65083 @@ -1465,6 +1465,6 @@ SPEC CHECKSUMS: SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 Yoga: 4f53dc50008d626fa679c7a1cb4bed898f8c0bde -PODFILE CHECKSUM: d9b32babc56dce83b08e09f4d22425f720e2c26d +PODFILE CHECKSUM: 57c34903a98d806716eae011f73869b42657e15e COCOAPODS: 1.15.2 diff --git a/CHANGELOG.md b/CHANGELOG.md index bfe48a0..1b53551 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +## 9.2.0 + +##### Added +- Updates the native iOS version bindings [from Braze Swift SDK 8.2.1 to 8.4.0](https://github.com/braze-inc/braze-swift-sdk/compare/8.2.1...8.4.0#diff-06572a96a58dc510037d5efa622f9bec8519bc1beab13c9f251e97e657a9d4ed). + +##### Fixed +- Fixes the Android implementation of `Braze.setCustomUserAttribute()` to correctly handle null values. + - Thanks @owonie for your contribution! + ## 9.1.0 ##### Added diff --git a/__tests__/index.test.js b/__tests__/index.test.js index c03d32c..8ebcb4a 100644 --- a/__tests__/index.test.js +++ b/__tests__/index.test.js @@ -336,8 +336,8 @@ test('it calls BrazeReactBridge.setCustomUserAttributeObjectArray', () => { test('it calls BrazeReactBridge.setCustomUserAttributeObject 4 parameters', () => { const key = "some_key"; - const hash = {'do': 're', 'mi': 'fa'} - const merge = true + const hash = {'do': 're', 'mi': 'fa'}; + const merge = true; Braze.setCustomUserAttribute(key, hash, merge, testCallback); expect(NativeBrazeReactModule.setCustomUserAttributeObject).toBeCalledWith(key, hash, merge, testCallback); @@ -345,9 +345,19 @@ test('it calls BrazeReactBridge.setCustomUserAttributeObject 4 parameters', () = test('it calls BrazeReactBridge.setCustomUserAttributeObject 3 parameters', () => { const key = "some_key"; - const hash = {'do': 're', 'mi': 'fa'} + const hash = {'do': 're', 'mi': 'fa'}; // When not given, merge defaults to 'false' - const merge = false + const merge = false; + Braze.setCustomUserAttribute(key, hash, testCallback); + + expect(NativeBrazeReactModule.setCustomUserAttributeObject).toBeCalledWith(key, hash, merge, testCallback); +}); + +test('it calls BrazeReactBridge.setCustomUserAttributeObject with null value', () => { + const key = "some_key"; + const hash = null; + // When not given, merge defaults to 'false' + const merge = false; Braze.setCustomUserAttribute(key, hash, testCallback); expect(NativeBrazeReactModule.setCustomUserAttributeObject).toBeCalledWith(key, hash, merge, testCallback); diff --git a/android/src/main/java/com/braze/reactbridge/BrazeReactBridgeImpl.kt b/android/src/main/java/com/braze/reactbridge/BrazeReactBridgeImpl.kt index d641b17..c5323f2 100644 --- a/android/src/main/java/com/braze/reactbridge/BrazeReactBridgeImpl.kt +++ b/android/src/main/java/com/braze/reactbridge/BrazeReactBridgeImpl.kt @@ -82,11 +82,11 @@ class BrazeReactBridgeImpl( fun requestImmediateDataFlush() = braze.requestImmediateDataFlush() - fun changeUser(userName: String?, sdkAuthToken: String?) = braze.changeUser(userName, sdkAuthToken) + fun changeUser(userName: String, sdkAuthToken: String?) = braze.changeUser(userName, sdkAuthToken) - fun getUserId(callback: Callback?) { + fun getUserId(callback: Callback) { runOnUser { - if (it.userId.isNullOrBlank()) { + if (it.userId.isBlank()) { callback.reportResult(null, "User ID not found.") } else { callback.reportResult(it.userId) @@ -94,17 +94,17 @@ class BrazeReactBridgeImpl( } } - fun addAlias(aliasName: String?, aliasLabel: String?) { - if (aliasName.isNullOrBlank()) { + fun addAlias(aliasName: String, aliasLabel: String) { + if (aliasName.isBlank()) { brazelog(W) { - "Invalid alias parameter: alias is required to be non-null and non-empty. " + + "Invalid alias parameter: alias is required to be non-empty. " + "Not adding alias." } return } - if (aliasLabel.isNullOrBlank()) { + if (aliasLabel.isBlank()) { brazelog(W) { - "Invalid label parameter: label is required to be non-null and non-empty. " + + "Invalid label parameter: label is required to be non-empty. " + "Not adding alias." } return @@ -114,17 +114,17 @@ class BrazeReactBridgeImpl( } } - fun registerPushToken(token: String?) { + fun registerPushToken(token: String) { braze.registeredPushToken = token } - fun logCustomEvent(eventName: String?, eventProperties: ReadableMap?) = + fun logCustomEvent(eventName: String, eventProperties: ReadableMap?) = braze.logCustomEvent(eventName, populateEventPropertiesFromReadableMap(eventProperties)) fun logPurchase( - productIdentifier: String?, - price: String?, - currencyCode: String?, + productIdentifier: String, + price: String, + currencyCode: String, quantity: Int, eventProperties: ReadableMap? ) = @@ -136,100 +136,56 @@ class BrazeReactBridgeImpl( populateEventPropertiesFromReadableMap(eventProperties) ) - fun setStringCustomUserAttribute(key: String?, value: String?, callback: Callback?) { - if (key == null || value == null) { - brazelog { "Key or value was null. Not logging custom user attribute." } - return - } + fun setStringCustomUserAttribute(key: String, value: String, callback: Callback?) { runOnUser { callback.reportResult(it.setCustomUserAttribute(key, value)) } } - fun setBoolCustomUserAttribute(key: String?, value: Boolean?, callback: Callback?) { - if (key == null || value == null) { - brazelog { "Key or value was null. Not logging custom user attribute." } - return - } + fun setBoolCustomUserAttribute(key: String, value: Boolean, callback: Callback?) { runOnUser { callback.reportResult(it.setCustomUserAttribute(key, value)) } } - fun setIntCustomUserAttribute(key: String?, value: Int, callback: Callback?) { - if (key == null) { - brazelog { "Key or value was null. Not logging custom user attribute." } - return - } + fun setIntCustomUserAttribute(key: String, value: Int, callback: Callback?) { runOnUser { callback.reportResult(it.setCustomUserAttribute(key, value)) } } - fun setDoubleCustomUserAttribute(key: String?, value: Float, callback: Callback?) { - if (key == null) { - brazelog { "Key or value was null. Not logging custom user attribute." } - return - } + fun setDoubleCustomUserAttribute(key: String, value: Float, callback: Callback?) { runOnUser { callback.reportResult(it.setCustomUserAttribute(key, value)) } } - fun setDateCustomUserAttribute(key: String?, timeStamp: Int, callback: Callback?) { - if (key == null) { - brazelog { "Key or value was null. Not logging custom user attribute." } - return - } + fun setDateCustomUserAttribute(key: String, timeStamp: Int, callback: Callback?) { runOnUser { callback.reportResult(it.setCustomUserAttributeToSecondsFromEpoch(key, timeStamp.toLong())) } } - fun incrementCustomUserAttribute(key: String?, incrementValue: Int, callback: Callback?) { - if (key == null) { - brazelog { "Key or value was null. Not logging incrementCustomUserAttribute." } - return - } + fun incrementCustomUserAttribute(key: String, incrementValue: Int, callback: Callback?) { runOnUser { callback.reportResult(it.incrementCustomUserAttribute(key, incrementValue)) } } - fun unsetCustomUserAttribute(key: String?, callback: Callback?) { - if (key == null) { - brazelog { "Key or value was null. Not logging unsetCustomUserAttribute." } - return - } + fun unsetCustomUserAttribute(key: String, callback: Callback?) { runOnUser { callback.reportResult(it.unsetCustomUserAttribute(key)) } } - fun setCustomUserAttributeObjectArray(key: String?, value: ReadableArray?, callback: Callback?) { - if (key == null) { - brazelog { "Key was null. Not logging setCustomUserAttributeObjectArray." } - return - } - if (value == null) { - brazelog { "Value was null. Not logging setCustomUserAttributeObjectArray." } - return - } + fun setCustomUserAttributeObjectArray(key: String, value: ReadableArray, callback: Callback?) { val attributeArray = JSONArray(parseReadableArray(value)) runOnUser { callback.reportResult(it.setCustomUserAttribute(key, attributeArray)) } } - fun setCustomUserAttributeArray(key: String?, value: ReadableArray?, callback: Callback?) { - if (key == null) { - brazelog { "Key was null. Not logging setCustomUserAttributeArray." } - return - } - if (value == null) { - brazelog { "Value was null. Not logging setCustomUserAttributeArray." } - return - } + fun setCustomUserAttributeArray(key: String, value: ReadableArray, callback: Callback?) { val size = value.size() val attributeArray = arrayOfNulls(size) for (i in 0 until size) { @@ -240,45 +196,41 @@ class BrazeReactBridgeImpl( } } - fun setCustomUserAttributeObject(key: String?, value: ReadableMap, merge: Boolean, callback: Callback?) { + fun setCustomUserAttributeObject(key: String?, value: ReadableMap?, merge: Boolean, callback: Callback?) { if (key == null) { brazelog { "Key was null. Not logging setCustomUserAttributeObject." } return } + if (value == null) { + brazelog { "Value was null. Not logging setCustomUserAttributeObject." } + return + } val json = JSONObject(parseReadableMap(value)) runOnUser { callback.reportResult(it.setCustomAttribute(key, json, merge)) } } - fun addToCustomAttributeArray(key: String?, value: String?, callback: Callback?) { - if (key == null || value == null) { - brazelog { "Key or value was null. Not logging custom user attribute." } - return - } + fun addToCustomAttributeArray(key: String, value: String, callback: Callback?) { runOnUser { callback.reportResult(it.addToCustomAttributeArray(key, value)) } } - fun removeFromCustomAttributeArray(key: String?, value: String?, callback: Callback?) { - if (key == null || value == null) { - brazelog { "Key or value was null. Not logging removeFromCustomAttributeArray" } - return - } + fun removeFromCustomAttributeArray(key: String, value: String, callback: Callback?) { runOnUser { callback.reportResult(it.removeFromCustomAttributeArray(key, value)) } } - fun setFirstName(firstName: String?) = runOnUser { it.setFirstName(firstName) } + fun setFirstName(firstName: String) = runOnUser { it.setFirstName(firstName) } - fun setLastName(lastName: String?) = runOnUser { it.setLastName(lastName) } + fun setLastName(lastName: String) = runOnUser { it.setLastName(lastName) } - fun setEmail(email: String?) = runOnUser { it.setEmail(email) } + fun setEmail(email: String) = runOnUser { it.setEmail(email) } - fun setGender(gender: String?, callback: Callback?) { - val genderValue = Gender.getGender(gender?.lowercase(Locale.US) ?: "") + fun setGender(gender: String, callback: Callback?) { + val genderValue = Gender.getGender(gender.lowercase(Locale.US)) if (genderValue == null) { callback.reportResult(error = "Invalid input $gender. Gender not set.") return @@ -293,40 +245,32 @@ class BrazeReactBridgeImpl( } } - fun setCountry(country: String?) = runOnUser { it.setCountry(country) } + fun setCountry(country: String) = runOnUser { it.setCountry(country) } - fun setHomeCity(homeCity: String?) = runOnUser { it.setHomeCity(homeCity) } + fun setHomeCity(homeCity: String) = runOnUser { it.setHomeCity(homeCity) } - fun setPhoneNumber(phoneNumber: String?) = runOnUser { it.setPhoneNumber(phoneNumber) } + fun setPhoneNumber(phoneNumber: String) = runOnUser { it.setPhoneNumber(phoneNumber) } - fun setLanguage(language: String?) = runOnUser { it.setLanguage(language) } + fun setLanguage(language: String) = runOnUser { it.setLanguage(language) } - fun addToSubscriptionGroup(groupId: String?, callback: Callback?) { - if (groupId == null) { - brazelog { "groupId was null. Not logging addToSubscriptionGroup." } - return - } + fun addToSubscriptionGroup(groupId: String, callback: Callback?) { runOnUser { callback.reportResult(it.addToSubscriptionGroup(groupId)) } } - fun removeFromSubscriptionGroup(groupId: String?, callback: Callback?) { - if (groupId == null) { - brazelog { "groupId was null. Not logging removeFromSubscriptionGroup." } - return - } + fun removeFromSubscriptionGroup(groupId: String, callback: Callback?) { runOnUser { callback.reportResult(it.removeFromSubscriptionGroup(groupId)) } } - fun setPushNotificationSubscriptionType(subscriptionType: String?, callback: Callback?) { + fun setPushNotificationSubscriptionType(subscriptionType: String, callback: Callback?) { val subscriptionValue = subscriptionType.parseNotificationSubscriptionType() if (subscriptionValue == null) { callback.reportResult( error = "Invalid subscription type $subscriptionType." + - " Push notification subscription type not set." + " Push notification subscription type not set." ) return } @@ -335,12 +279,12 @@ class BrazeReactBridgeImpl( } } - fun setEmailNotificationSubscriptionType(subscriptionType: String?, callback: Callback?) { + fun setEmailNotificationSubscriptionType(subscriptionType: String, callback: Callback?) { val subscriptionValue = subscriptionType.parseNotificationSubscriptionType() if (subscriptionValue == null) { callback.reportResult( error = "Invalid subscription type $subscriptionType." + - " Email notification subscription type not set." + " Email notification subscription type not set." ) return } @@ -359,24 +303,20 @@ class BrazeReactBridgeImpl( braze.requestFeedRefresh() } - fun getNewsFeedCards(promise: Promise?) { + fun getNewsFeedCards(promise: Promise) { braze.subscribeToFeedUpdates(IFireOnceEventSubscriber { - promise?.resolve(mapContentCards(it.feedCards)) + promise.resolve(mapContentCards(it.feedCards)) updateNewsFeedCardsIfNeeded(it) }) braze.requestFeedRefresh() } - fun logNewsFeedCardClicked(id: String?) { - id?.let { - getNewsFeedCardById(it)?.logClick() - } + fun logNewsFeedCardClicked(id: String) { + getNewsFeedCardById(id)?.logClick() } - fun logNewsFeedCardImpression(id: String?) { - id?.let { - getNewsFeedCardById(it)?.logImpression() - } + fun logNewsFeedCardImpression(id: String) { + getNewsFeedCardById(id)?.logImpression() } fun launchContentCards() { @@ -389,24 +329,22 @@ class BrazeReactBridgeImpl( braze.requestContentCardsRefresh() } - fun getContentCards(promise: Promise?) { + fun getContentCards(promise: Promise) { braze.subscribeToContentCardsUpdates(IFireOnceEventSubscriber { message -> - promise?.resolve(mapContentCards(message.allCards)) + promise.resolve(mapContentCards(message.allCards)) updateContentCardsIfNeeded(message) }) braze.requestContentCardsRefresh() } - fun getCachedContentCards(promise: Promise?) { + fun getCachedContentCards(promise: Promise) { contentCardsLock.withLock { - promise?.resolve(mapContentCards(contentCards)) + promise.resolve(mapContentCards(contentCards)) } } - fun setSdkAuthenticationSignature(token: String?) { - if (token != null) { - braze.setSdkAuthenticationSignature(token) - } + fun setSdkAuthenticationSignature(token: String) { + braze.setSdkAuthenticationSignature(token) } @Suppress("UnusedPrivateMember") @@ -572,51 +510,38 @@ class BrazeReactBridgeImpl( braze.subscribeToPushNotificationEvents(pushNotificationEventSubscriber) } - fun logContentCardDismissed(id: String?) { - id?.let { - getContentCardById(it)?.isDismissed = true - } + fun logContentCardDismissed(id: String) { + getContentCardById(id)?.isDismissed = true } - fun logContentCardClicked(id: String?) { - id?.let { - getContentCardById(it)?.logClick() - } + fun logContentCardClicked(id: String) { + getContentCardById(id)?.logClick() } - fun logContentCardImpression(id: String?) { - id?.let { - getContentCardById(it)?.logImpression() - } + fun logContentCardImpression(id: String) { + getContentCardById(id)?.logImpression() } - fun processContentCardClickAction(id: String?) { + fun processContentCardClickAction(id: String) { brazelog(V) { "Processing content card action $id" } - id?.let { - val card = getContentCardById(it) - if (card == null) { - return - } - val extras = Bundle() - for (key in card.extras.keys) { - extras.putString(key, card.extras[key]) - } - val url = card.url - if (url == null) { - brazelog(V) { "Card URL is null, returning null for getUriActionForCard" } - return - } - - val action = BrazeDeeplinkHandler.getInstance().createUriActionFromUrlString( - url, - extras, - card.openUriInWebView, - card.channel - ) - - if (action != null) { - BrazeDeeplinkHandler.getInstance().gotoUri(reactApplicationContext, action) - } + val card = getContentCardById(id) ?: return + val extras = Bundle() + for (key in card.extras.keys) { + extras.putString(key, card.extras[key]) + } + val url = card.url + if (url == null) { + brazelog(V) { "Card URL is null, returning null for getUriActionForCard" } + return + } + val action = BrazeDeeplinkHandler.getInstance().createUriActionFromUrlString( + url, + extras, + card.openUriInWebView, + card.channel + ) + if (action != null) { + BrazeDeeplinkHandler.getInstance().gotoUri(reactApplicationContext, action) } } @@ -635,7 +560,7 @@ class BrazeReactBridgeImpl( if (category == null || cardCategory == null && category != "all") { callback.reportResult( error = "Invalid card category $category," + - " could not retrieve$cardCountTag" + " could not retrieve$cardCountTag" ) return } @@ -693,10 +618,10 @@ class BrazeReactBridgeImpl( } } - fun getCardCountForCategories(category: String?, callback: Callback?) = + fun getCardCountForCategories(category: String, callback: Callback?) = getCardCountForTag(category, callback, CARD_COUNT_TAG) - fun getUnreadCardCountForCategories(category: String?, callback: Callback?) = + fun getUnreadCardCountForCategories(category: String, callback: Callback?) = getCardCountForTag(category, callback, UNREAD_CARD_COUNT_TAG) fun wipeData() = Braze.wipeData(reactApplicationContext) @@ -707,24 +632,9 @@ class BrazeReactBridgeImpl( fun requestLocationInitialization() = braze.requestLocationInitialization() - fun requestGeofences(latitude: Double?, longitude: Double?) { - if (latitude == null || - longitude == null - ) { - brazelog { "requestGeofences arguments were null. Not requesting." } - return - } - braze.requestGeofences(latitude, longitude) - } + fun requestGeofences(latitude: Double, longitude: Double) = braze.requestGeofences(latitude, longitude) - fun setLocationCustomAttribute(key: String?, latitude: Double?, longitude: Double?, callback: Callback?) { - if (key == null || - latitude == null || - longitude == null - ) { - brazelog { "setLocationCustomAttribute arguments were null. Not logging." } - return - } + fun setLocationCustomAttribute(key: String, latitude: Double, longitude: Double, callback: Callback?) { runOnUser { it.setLocationCustomAttribute(key, latitude, longitude) // Always return true as Android doesn't support @@ -753,13 +663,13 @@ class BrazeReactBridgeImpl( fun hideCurrentInAppMessage() = BrazeInAppMessageManager.getInstance().hideCurrentlyDisplayingInAppMessage(true) - fun logInAppMessageClicked(inAppMessageString: String?) { + fun logInAppMessageClicked(inAppMessageString: String) { braze.deserializeInAppMessageString(inAppMessageString)?.logClick() } - fun logInAppMessageImpression(inAppMessageString: String?) = braze.deserializeInAppMessageString(inAppMessageString)?.logImpression() + fun logInAppMessageImpression(inAppMessageString: String) = braze.deserializeInAppMessageString(inAppMessageString)?.logImpression() - fun logInAppMessageButtonClicked(inAppMessageString: String?, buttonId: Int) { + fun logInAppMessageButtonClicked(inAppMessageString: String, buttonId: Int) { val inAppMessage = braze.deserializeInAppMessageString(inAppMessageString) if (inAppMessage is IInAppMessageImmersive) { inAppMessage.messageButtons @@ -768,7 +678,7 @@ class BrazeReactBridgeImpl( } } - fun performInAppMessageAction(inAppMessageString: String?, buttonId: Int) { + fun performInAppMessageAction(inAppMessageString: String, buttonId: Int) { brazelog(V) { "Processing in-app message action $inAppMessageString" } braze.deserializeInAppMessageString(inAppMessageString)?.let { inAppMessage -> val activity = currentActivity @@ -782,8 +692,8 @@ class BrazeReactBridgeImpl( if (inAppMessage is InAppMessageImmersiveBase) { button = inAppMessage.messageButtons.firstOrNull { it.id == buttonId } } else { - brazelog { "Cannot perform IAM action because button was not null but message is not InAppMessageImmersiveBase" } - return + brazelog { "Cannot perform IAM action because button was not null but message is not InAppMessageImmersiveBase" } + return } } @@ -826,8 +736,8 @@ class BrazeReactBridgeImpl( openUriInWebView, Channel.INAPP_MESSAGE ) - if (reactApplicationContext == null) { - brazelog { "reactApplicationContext is null, not performing click action" } + if (!reactApplicationContext.hasActiveReactInstance()) { + brazelog { "reactApplicationContext instance not active, not performing click action" } return } else { brazelog(W) { "Performing gotoUri $clickUri $openUriInWebView" } @@ -857,7 +767,7 @@ class BrazeReactBridgeImpl( } } - fun getDeviceId(callback: Callback?) = braze.getDeviceIdAsync { callback.reportResult(it) } + fun getDeviceId(callback: Callback) = braze.getDeviceIdAsync { callback.reportResult(it) } private fun runOnUser(block: (user: BrazeUser) -> Unit) { braze.getCurrentUser { @@ -916,23 +826,21 @@ class BrazeReactBridgeImpl( contentCards.firstOrNull { it.id == id } } - fun getAllFeatureFlags(promise: Promise?) { + fun getAllFeatureFlags(promise: Promise) { val ffs = braze.getAllFeatureFlags() val data = Arguments.createArray() ffs.forEach { data.pushMap(convertFeatureFlag(it)) } - promise?.resolve(data) + promise.resolve(data) } - fun getFeatureFlag(id: String?, promise: Promise?) { - if (id != null && promise != null) { - val ff = braze.getFeatureFlag(id) - if (ff == null) { - promise.resolve(null) - } else { - promise.resolve(convertFeatureFlag(ff)) - } + fun getFeatureFlag(id: String, promise: Promise) { + val ff = braze.getFeatureFlag(id) + if (ff == null) { + promise.resolve(null) + } else { + promise.resolve(convertFeatureFlag(ff)) } } @@ -944,28 +852,20 @@ class BrazeReactBridgeImpl( braze.logFeatureFlagImpression(id) } - fun getFeatureFlagBooleanProperty(id: String?, key: String?, promise: Promise?) { - if (id != null && key != null && promise != null) { - promise.resolve(braze.getFeatureFlag(id)?.getBooleanProperty(key)) - } + fun getFeatureFlagBooleanProperty(id: String, key: String, promise: Promise) { + promise.resolve(braze.getFeatureFlag(id)?.getBooleanProperty(key)) } - fun getFeatureFlagStringProperty(id: String?, key: String?, promise: Promise?) { - if (id != null && key != null && promise != null) { - promise.resolve(braze.getFeatureFlag(id)?.getStringProperty(key)) - } + fun getFeatureFlagStringProperty(id: String, key: String, promise: Promise) { + promise.resolve(braze.getFeatureFlag(id)?.getStringProperty(key)) } - fun getFeatureFlagNumberProperty(id: String?, key: String?, promise: Promise?) { - if (id != null && key != null && promise != null) { - promise.resolve(braze.getFeatureFlag(id)?.getNumberProperty(key)) - } + fun getFeatureFlagNumberProperty(id: String, key: String, promise: Promise) { + promise.resolve(braze.getFeatureFlag(id)?.getNumberProperty(key)) } - fun setAdTrackingEnabled(adTrackingEnabled: Boolean?, googleAdvertisingId: String?) { - if (googleAdvertisingId != null && adTrackingEnabled != null) { - braze.setGoogleAdvertisingId(googleAdvertisingId, adTrackingEnabled) - } + fun setAdTrackingEnabled(adTrackingEnabled: Boolean, googleAdvertisingId: String) { + braze.setGoogleAdvertisingId(googleAdvertisingId, adTrackingEnabled) } private fun setDefaultInAppMessageListener() { diff --git a/android/src/newarch/com/braze/reactbridge/BrazeReactBridge.kt b/android/src/newarch/com/braze/reactbridge/BrazeReactBridge.kt index fc18fcf..edb70ad 100644 --- a/android/src/newarch/com/braze/reactbridge/BrazeReactBridge.kt +++ b/android/src/newarch/com/braze/reactbridge/BrazeReactBridge.kt @@ -9,59 +9,59 @@ class BrazeReactBridge(reactContext: ReactApplicationContext): NativeBrazeReactM return BrazeReactBridgeImpl.NAME } - override fun getInitialURL(callback: Callback?) { + override fun getInitialURL(callback: Callback) { // iOS only } - override fun getDeviceId(callback: Callback?) { + override fun getDeviceId(callback: Callback) { return brazeImpl.getDeviceId(callback) } - override fun changeUser(userId: String?, signature: String?) { + override fun changeUser(userId: String, signature: String?) { brazeImpl.changeUser(userId, signature) } - override fun getUserId(callback: Callback?) { + override fun getUserId(callback: Callback) { return brazeImpl.getUserId(callback) } - - override fun setSdkAuthenticationSignature(signature: String?) { + + override fun setSdkAuthenticationSignature(signature: String) { brazeImpl.setSdkAuthenticationSignature(signature) } - override fun addAlias(aliasName: String?, aliasLabel: String?) { + override fun addAlias(aliasName: String, aliasLabel: String) { brazeImpl.addAlias(aliasName, aliasLabel) } - override fun setFirstName(firstName: String?) { + override fun setFirstName(firstName: String) { brazeImpl.setFirstName(firstName) } - override fun setLastName(lastName: String?) { + override fun setLastName(lastName: String) { brazeImpl.setLastName(lastName) } - override fun setEmail(email: String?) { + override fun setEmail(email: String) { brazeImpl.setEmail(email) } - override fun setGender(gender: String?, callback: Callback?) { + override fun setGender(gender: String, callback: Callback?) { brazeImpl.setGender(gender, callback) } - override fun setLanguage(language: String?) { + override fun setLanguage(language: String) { brazeImpl.setLanguage(language) } - override fun setCountry(country: String?) { + override fun setCountry(country: String) { brazeImpl.setCountry(country) } - override fun setHomeCity(homeCity: String?) { + override fun setHomeCity(homeCity: String) { brazeImpl.setHomeCity(homeCity) } - override fun setPhoneNumber(phoneNumber: String?) { + override fun setPhoneNumber(phoneNumber: String) { brazeImpl.setPhoneNumber(phoneNumber) } @@ -69,103 +69,103 @@ class BrazeReactBridge(reactContext: ReactApplicationContext): NativeBrazeReactM brazeImpl.setDateOfBirth(year.toInt(), month.toInt(), day.toInt()) } - override fun registerPushToken(token: String?) { + override fun registerPushToken(token: String) { brazeImpl.registerPushToken(token) } - override fun addToSubscriptionGroup(groupId: String?, callback: Callback?) { + override fun addToSubscriptionGroup(groupId: String, callback: Callback?) { brazeImpl.addToSubscriptionGroup(groupId, callback) } - override fun removeFromSubscriptionGroup(groupId: String?, callback: Callback?) { + override fun removeFromSubscriptionGroup(groupId: String, callback: Callback?) { brazeImpl.removeFromSubscriptionGroup(groupId, callback) } override fun setPushNotificationSubscriptionType( - notificationSubscriptionType: String?, + notificationSubscriptionType: String, callback: Callback? ) { brazeImpl.setPushNotificationSubscriptionType(notificationSubscriptionType, callback) } override fun setEmailNotificationSubscriptionType( - notificationSubscriptionType: String?, + notificationSubscriptionType: String, callback: Callback? ) { brazeImpl.setEmailNotificationSubscriptionType(notificationSubscriptionType, callback) } - override fun logCustomEvent(eventName: String?, eventProperties: ReadableMap?) { + override fun logCustomEvent(eventName: String, eventProperties: ReadableMap?) { brazeImpl.logCustomEvent(eventName, eventProperties) } override fun logPurchase( - productId: String?, - price: String?, - currencyCode: String?, + productId: String, + price: String, + currencyCode: String, quantity: Double, purchaseProperties: ReadableMap? ) { brazeImpl.logPurchase(productId, price, currencyCode, quantity.toInt(), purchaseProperties) } - override fun setIntCustomUserAttribute(key: String?, value: Double, callback: Callback?) { + override fun setIntCustomUserAttribute(key: String, value: Double, callback: Callback?) { brazeImpl.setIntCustomUserAttribute(key, value.toInt(), callback) } - override fun setDoubleCustomUserAttribute(key: String?, value: Double, callback: Callback?) { + override fun setDoubleCustomUserAttribute(key: String, value: Double, callback: Callback?) { brazeImpl.setDoubleCustomUserAttribute(key, value.toFloat(), callback) } - override fun setBoolCustomUserAttribute(key: String?, value: Boolean, callback: Callback?) { + override fun setBoolCustomUserAttribute(key: String, value: Boolean, callback: Callback?) { brazeImpl.setBoolCustomUserAttribute(key, value, callback) } - override fun setStringCustomUserAttribute(key: String?, value: String?, callback: Callback?) { + override fun setStringCustomUserAttribute(key: String, value: String, callback: Callback?) { brazeImpl.setStringCustomUserAttribute(key, value, callback) } override fun setCustomUserAttributeArray( - key: String?, - value: ReadableArray?, + key: String, + value: ReadableArray, callback: Callback? ) { brazeImpl.setCustomUserAttributeArray(key, value, callback) } override fun setCustomUserAttributeObjectArray( - key: String?, - value: ReadableArray?, + key: String, + value: ReadableArray, callback: Callback? ) { brazeImpl.setCustomUserAttributeObjectArray(key, value, callback) } - override fun setDateCustomUserAttribute(key: String?, value: Double, callback: Callback?) { + override fun setDateCustomUserAttribute(key: String, value: Double, callback: Callback?) { brazeImpl.setDateCustomUserAttribute(key, value.toInt(), callback) } - override fun setCustomUserAttributeObject(key: String?, value: ReadableMap, merge: Boolean, callback: Callback?) { + override fun setCustomUserAttributeObject(key: String?, value: ReadableMap?, merge: Boolean, callback: Callback?) { brazeImpl.setCustomUserAttributeObject(key, value, merge, callback) } - override fun addToCustomUserAttributeArray(key: String?, value: String?, callback: Callback?) { + override fun addToCustomUserAttributeArray(key: String, value: String, callback: Callback?) { brazeImpl.addToCustomAttributeArray(key, value, callback) } override fun removeFromCustomUserAttributeArray( - key: String?, - value: String?, + key: String, + value: String, callback: Callback? ) { brazeImpl.removeFromCustomAttributeArray(key, value, callback) } - override fun unsetCustomUserAttribute(key: String?, callback: Callback?) { + override fun unsetCustomUserAttribute(key: String, callback: Callback?) { brazeImpl.unsetCustomUserAttribute(key, callback) } - override fun incrementCustomUserAttribute(key: String?, value: Double, callback: Callback?) { + override fun incrementCustomUserAttribute(key: String, value: Double, callback: Callback?) { brazeImpl.incrementCustomUserAttribute(key, value.toInt(), callback) } @@ -182,15 +182,15 @@ class BrazeReactBridge(reactContext: ReactApplicationContext): NativeBrazeReactM brazeImpl.launchNewsFeed() } - override fun logNewsFeedCardClicked(cardId: String?) { + override fun logNewsFeedCardClicked(cardId: String) { brazeImpl.logNewsFeedCardClicked(cardId) } - override fun logNewsFeedCardImpression(cardId: String?) { + override fun logNewsFeedCardImpression(cardId: String) { brazeImpl.logNewsFeedCardImpression(cardId) } - override fun getNewsFeedCards(promise: Promise?) { + override fun getNewsFeedCards(promise: Promise) { brazeImpl.getNewsFeedCards(promise) } @@ -202,35 +202,35 @@ class BrazeReactBridge(reactContext: ReactApplicationContext): NativeBrazeReactM brazeImpl.requestContentCardsRefresh() } - override fun logContentCardClicked(cardId: String?) { + override fun logContentCardClicked(cardId: String) { brazeImpl.logContentCardClicked(cardId) } - override fun logContentCardDismissed(cardId: String?) { + override fun logContentCardDismissed(cardId: String) { brazeImpl.logContentCardDismissed(cardId) } - override fun logContentCardImpression(cardId: String?) { + override fun logContentCardImpression(cardId: String) { brazeImpl.logContentCardImpression(cardId) } - override fun processContentCardClickAction(cardId: String?) { + override fun processContentCardClickAction(cardId: String) { brazeImpl.processContentCardClickAction(cardId) } - override fun getContentCards(promise: Promise?) { + override fun getContentCards(promise: Promise) { brazeImpl.getContentCards(promise) } - override fun getCachedContentCards(promise: Promise?) { + override fun getCachedContentCards(promise: Promise) { brazeImpl.getCachedContentCards(promise) } - override fun getCardCountForCategories(category: String?, callback: Callback?) { + override fun getCardCountForCategories(category: String, callback: Callback?) { brazeImpl.getCardCountForCategories(category, callback) } - override fun getUnreadCardCountForCategories(category: String?, callback: Callback?) { + override fun getUnreadCardCountForCategories(category: String, callback: Callback?) { brazeImpl.getUnreadCardCountForCategories(category, callback) } @@ -263,7 +263,7 @@ class BrazeReactBridge(reactContext: ReactApplicationContext): NativeBrazeReactM } override fun setLocationCustomAttribute( - key: String?, + key: String, latitude: Double, longitude: Double, callback: Callback? @@ -289,19 +289,19 @@ class BrazeReactBridge(reactContext: ReactApplicationContext): NativeBrazeReactM brazeImpl.hideCurrentInAppMessage() } - override fun logInAppMessageClicked(inAppMessageString: String?) { + override fun logInAppMessageClicked(inAppMessageString: String) { brazeImpl.logInAppMessageClicked(inAppMessageString) } - override fun logInAppMessageImpression(inAppMessageString: String?) { + override fun logInAppMessageImpression(inAppMessageString: String) { brazeImpl.logInAppMessageImpression(inAppMessageString) } - override fun logInAppMessageButtonClicked(inAppMessageString: String?, buttonId: Double) { + override fun logInAppMessageButtonClicked(inAppMessageString: String, buttonId: Double) { brazeImpl.logInAppMessageButtonClicked(inAppMessageString, buttonId.toInt()) } - override fun performInAppMessageAction(inAppMessageString: String?, buttonId: Double) { + override fun performInAppMessageAction(inAppMessageString: String, buttonId: Double) { brazeImpl.performInAppMessageAction(inAppMessageString, buttonId.toInt()) } @@ -309,23 +309,23 @@ class BrazeReactBridge(reactContext: ReactApplicationContext): NativeBrazeReactM brazeImpl.requestPushPermission(permissionOptions) } - override fun getAllFeatureFlags(promise: Promise?) { + override fun getAllFeatureFlags(promise: Promise) { brazeImpl.getAllFeatureFlags(promise) } - override fun getFeatureFlag(flagId: String?, promise: Promise?) { + override fun getFeatureFlag(flagId: String, promise: Promise) { brazeImpl.getFeatureFlag(flagId, promise) } - override fun getFeatureFlagBooleanProperty(flagId: String?, key: String?, promise: Promise?) { + override fun getFeatureFlagBooleanProperty(flagId: String, key: String, promise: Promise) { brazeImpl.getFeatureFlagBooleanProperty(flagId, key, promise) } - override fun getFeatureFlagStringProperty(flagId: String?, key: String?, promise: Promise?) { + override fun getFeatureFlagStringProperty(flagId: String, key: String, promise: Promise) { brazeImpl.getFeatureFlagStringProperty(flagId, key, promise) } - override fun getFeatureFlagNumberProperty(flagId: String?, key: String?, promise: Promise?) { + override fun getFeatureFlagNumberProperty(flagId: String, key: String, promise: Promise) { brazeImpl.getFeatureFlagNumberProperty(flagId, key, promise) } @@ -337,18 +337,16 @@ class BrazeReactBridge(reactContext: ReactApplicationContext): NativeBrazeReactM brazeImpl.logFeatureFlagImpression(id) } - override fun setAdTrackingEnabled(adTrackingEnabled: Boolean, googleAdvertisingId: String?) { + override fun setAdTrackingEnabled(adTrackingEnabled: Boolean, googleAdvertisingId: String) { brazeImpl.setAdTrackingEnabled(adTrackingEnabled, googleAdvertisingId) } - override fun updateTrackingPropertyAllowList(allowList: ReadableMap?) { + override fun updateTrackingPropertyAllowList(allowList: ReadableMap) { // iOS only } - override fun addListener(eventType: String?) { - eventType?.let { - brazeImpl.addListener(it) - } + override fun addListener(eventType: String) { + brazeImpl.addListener(eventType) } override fun removeListeners(count: Double) { diff --git a/android/src/oldarch/com/braze/reactbridge/BrazeReactBridge.kt b/android/src/oldarch/com/braze/reactbridge/BrazeReactBridge.kt index 8862a65..9b6cffd 100644 --- a/android/src/oldarch/com/braze/reactbridge/BrazeReactBridge.kt +++ b/android/src/oldarch/com/braze/reactbridge/BrazeReactBridge.kt @@ -9,72 +9,72 @@ class BrazeReactBridge(reactContext: ReactApplicationContext?) : ReactContextBas override fun getName() = BrazeReactBridgeImpl.NAME @ReactMethod - fun getInitialURL(callback: Callback?) { + fun getInitialURL(callback: Callback) { // iOS only } @ReactMethod - fun getDeviceId(callback: Callback?) { + fun getDeviceId(callback: Callback) { return brazeImpl.getDeviceId(callback) } @ReactMethod - fun changeUser(userId: String?, signature: String?) { + fun changeUser(userId: String, signature: String?) { brazeImpl.changeUser(userId, signature) } - + @ReactMethod - fun getUserId(callback: Callback?) { + fun getUserId(callback: Callback) { return brazeImpl.getUserId(callback) } @ReactMethod - fun setSdkAuthenticationSignature(signature: String?) { + fun setSdkAuthenticationSignature(signature: String) { brazeImpl.setSdkAuthenticationSignature(signature) } @ReactMethod - fun addAlias(aliasName: String?, aliasLabel: String?) { + fun addAlias(aliasName: String, aliasLabel: String) { brazeImpl.addAlias(aliasName, aliasLabel) } @ReactMethod - fun setFirstName(firstName: String?) { + fun setFirstName(firstName: String) { brazeImpl.setFirstName(firstName) } @ReactMethod - fun setLastName(lastName: String?) { + fun setLastName(lastName: String) { brazeImpl.setLastName(lastName) } @ReactMethod - fun setEmail(email: String?) { + fun setEmail(email: String) { brazeImpl.setEmail(email) } @ReactMethod - fun setGender(gender: String?, callback: Callback?) { + fun setGender(gender: String, callback: Callback?) { brazeImpl.setGender(gender, callback) } @ReactMethod - fun setLanguage(language: String?) { + fun setLanguage(language: String) { brazeImpl.setLanguage(language) } @ReactMethod - fun setCountry(country: String?) { + fun setCountry(country: String) { brazeImpl.setCountry(country) } @ReactMethod - fun setHomeCity(homeCity: String?) { + fun setHomeCity(homeCity: String) { brazeImpl.setHomeCity(homeCity) } @ReactMethod - fun setPhoneNumber(phoneNumber: String?) { + fun setPhoneNumber(phoneNumber: String) { brazeImpl.setPhoneNumber(phoneNumber) } @@ -84,23 +84,23 @@ class BrazeReactBridge(reactContext: ReactApplicationContext?) : ReactContextBas } @ReactMethod - fun registerPushToken(token: String?) { + fun registerPushToken(token: String) { brazeImpl.registerPushToken(token) } @ReactMethod - fun addToSubscriptionGroup(groupId: String?, callback: Callback?) { + fun addToSubscriptionGroup(groupId: String, callback: Callback?) { brazeImpl.addToSubscriptionGroup(groupId, callback) } @ReactMethod - fun removeFromSubscriptionGroup(groupId: String?, callback: Callback?) { + fun removeFromSubscriptionGroup(groupId: String, callback: Callback?) { brazeImpl.removeFromSubscriptionGroup(groupId, callback) } @ReactMethod fun setPushNotificationSubscriptionType( - notificationSubscriptionType: String?, + notificationSubscriptionType: String, callback: Callback? ) { brazeImpl.setPushNotificationSubscriptionType(notificationSubscriptionType, callback) @@ -108,22 +108,22 @@ class BrazeReactBridge(reactContext: ReactApplicationContext?) : ReactContextBas @ReactMethod fun setEmailNotificationSubscriptionType( - notificationSubscriptionType: String?, + notificationSubscriptionType: String, callback: Callback? ) { brazeImpl.setEmailNotificationSubscriptionType(notificationSubscriptionType, callback) } @ReactMethod - fun logCustomEvent(eventName: String?, eventProperties: ReadableMap?) { + fun logCustomEvent(eventName: String, eventProperties: ReadableMap?) { brazeImpl.logCustomEvent(eventName, eventProperties) } @ReactMethod fun logPurchase( - productId: String?, - price: String?, - currencyCode: String?, + productId: String, + price: String, + currencyCode: String, quantity: Double, purchaseProperties: ReadableMap? ) { @@ -131,29 +131,29 @@ class BrazeReactBridge(reactContext: ReactApplicationContext?) : ReactContextBas } @ReactMethod - fun setIntCustomUserAttribute(key: String?, value: Double, callback: Callback?) { + fun setIntCustomUserAttribute(key: String, value: Double, callback: Callback?) { brazeImpl.setIntCustomUserAttribute(key, value.toInt(), callback) } @ReactMethod - fun setDoubleCustomUserAttribute(key: String?, value: Double, callback: Callback?) { + fun setDoubleCustomUserAttribute(key: String, value: Double, callback: Callback?) { brazeImpl.setDoubleCustomUserAttribute(key, value.toFloat(), callback) } @ReactMethod - fun setBoolCustomUserAttribute(key: String?, value: Boolean, callback: Callback?) { + fun setBoolCustomUserAttribute(key: String, value: Boolean, callback: Callback?) { brazeImpl.setBoolCustomUserAttribute(key, value, callback) } @ReactMethod - fun setStringCustomUserAttribute(key: String?, value: String?, callback: Callback?) { + fun setStringCustomUserAttribute(key: String, value: String, callback: Callback?) { brazeImpl.setStringCustomUserAttribute(key, value, callback) } @ReactMethod fun setCustomUserAttributeArray( - key: String?, - value: ReadableArray?, + key: String, + value: ReadableArray, callback: Callback? ) { brazeImpl.setCustomUserAttributeArray(key, value, callback) @@ -161,44 +161,44 @@ class BrazeReactBridge(reactContext: ReactApplicationContext?) : ReactContextBas @ReactMethod fun setCustomUserAttributeObjectArray( - key: String?, - value: ReadableArray?, + key: String, + value: ReadableArray, callback: Callback? ) { brazeImpl.setCustomUserAttributeObjectArray(key, value, callback) } @ReactMethod - fun setDateCustomUserAttribute(key: String?, value: Double, callback: Callback?) { + fun setDateCustomUserAttribute(key: String, value: Double, callback: Callback?) { brazeImpl.setDateCustomUserAttribute(key, value.toInt(), callback) } @ReactMethod - fun setCustomUserAttributeObject(key: String?, value: ReadableMap, merge: Boolean, callback: Callback?) { + fun setCustomUserAttributeObject(key: String?, value: ReadableMap?, merge: Boolean, callback: Callback?) { brazeImpl.setCustomUserAttributeObject(key, value, merge, callback) } @ReactMethod - fun addToCustomUserAttributeArray(key: String?, value: String?, callback: Callback?) { + fun addToCustomUserAttributeArray(key: String, value: String, callback: Callback?) { brazeImpl.addToCustomAttributeArray(key, value, callback) } @ReactMethod fun removeFromCustomUserAttributeArray( - key: String?, - value: String?, + key: String, + value: String, callback: Callback? ) { brazeImpl.removeFromCustomAttributeArray(key, value, callback) } @ReactMethod - fun unsetCustomUserAttribute(key: String?, callback: Callback?) { + fun unsetCustomUserAttribute(key: String, callback: Callback?) { brazeImpl.unsetCustomUserAttribute(key, callback) } @ReactMethod - fun incrementCustomUserAttribute(key: String?, value: Double, callback: Callback?) { + fun incrementCustomUserAttribute(key: String, value: Double, callback: Callback?) { brazeImpl.incrementCustomUserAttribute(key, value.toInt(), callback) } @@ -218,17 +218,17 @@ class BrazeReactBridge(reactContext: ReactApplicationContext?) : ReactContextBas } @ReactMethod - fun logNewsFeedCardClicked(cardId: String?) { + fun logNewsFeedCardClicked(cardId: String) { brazeImpl.logNewsFeedCardClicked(cardId) } @ReactMethod - fun logNewsFeedCardImpression(cardId: String?) { + fun logNewsFeedCardImpression(cardId: String) { brazeImpl.logNewsFeedCardImpression(cardId) } @ReactMethod - fun getNewsFeedCards(promise: Promise?) { + fun getNewsFeedCards(promise: Promise) { brazeImpl.getNewsFeedCards(promise) } @@ -243,42 +243,42 @@ class BrazeReactBridge(reactContext: ReactApplicationContext?) : ReactContextBas } @ReactMethod - fun logContentCardClicked(cardId: String?) { + fun logContentCardClicked(cardId: String) { brazeImpl.logContentCardClicked(cardId) } @ReactMethod - fun logContentCardDismissed(cardId: String?) { + fun logContentCardDismissed(cardId: String) { brazeImpl.logContentCardDismissed(cardId) } @ReactMethod - fun logContentCardImpression(cardId: String?) { + fun logContentCardImpression(cardId: String) { brazeImpl.logContentCardImpression(cardId) } @ReactMethod - fun processContentCardClickAction(cardId: String?) { + fun processContentCardClickAction(cardId: String) { brazeImpl.processContentCardClickAction(cardId) } @ReactMethod - fun getContentCards(promise: Promise?) { + fun getContentCards(promise: Promise) { brazeImpl.getContentCards(promise) } @ReactMethod - fun getCachedContentCards(promise: Promise?) { + fun getCachedContentCards(promise: Promise) { brazeImpl.getCachedContentCards(promise) } @ReactMethod - fun getCardCountForCategories(category: String?, callback: Callback?) { + fun getCardCountForCategories(category: String, callback: Callback?) { brazeImpl.getCardCountForCategories(category, callback) } @ReactMethod - fun getUnreadCardCountForCategories(category: String?, callback: Callback?) { + fun getUnreadCardCountForCategories(category: String, callback: Callback?) { brazeImpl.getUnreadCardCountForCategories(category, callback) } @@ -319,7 +319,7 @@ class BrazeReactBridge(reactContext: ReactApplicationContext?) : ReactContextBas @ReactMethod fun setLocationCustomAttribute( - key: String?, + key: String, latitude: Double, longitude: Double, callback: Callback? @@ -349,22 +349,22 @@ class BrazeReactBridge(reactContext: ReactApplicationContext?) : ReactContextBas } @ReactMethod - fun logInAppMessageClicked(inAppMessageString: String?) { + fun logInAppMessageClicked(inAppMessageString: String) { brazeImpl.logInAppMessageClicked(inAppMessageString) } @ReactMethod - fun logInAppMessageImpression(inAppMessageString: String?) { + fun logInAppMessageImpression(inAppMessageString: String) { brazeImpl.logInAppMessageImpression(inAppMessageString) } @ReactMethod - fun logInAppMessageButtonClicked(inAppMessageString: String?, buttonId: Double) { + fun logInAppMessageButtonClicked(inAppMessageString: String, buttonId: Double) { brazeImpl.logInAppMessageButtonClicked(inAppMessageString, buttonId.toInt()) } @ReactMethod - fun performInAppMessageAction(inAppMessageString: String?, buttonId: Double) { + fun performInAppMessageAction(inAppMessageString: String, buttonId: Double) { brazeImpl.performInAppMessageAction(inAppMessageString, buttonId.toInt()) } @@ -374,27 +374,27 @@ class BrazeReactBridge(reactContext: ReactApplicationContext?) : ReactContextBas } @ReactMethod - fun getAllFeatureFlags(promise: Promise?) { + fun getAllFeatureFlags(promise: Promise) { brazeImpl.getAllFeatureFlags(promise) } @ReactMethod - fun getFeatureFlag(flagId: String?, promise: Promise?) { + fun getFeatureFlag(flagId: String, promise: Promise) { brazeImpl.getFeatureFlag(flagId, promise) } @ReactMethod - fun getFeatureFlagBooleanProperty(flagId: String?, key: String?, promise: Promise?) { + fun getFeatureFlagBooleanProperty(flagId: String, key: String, promise: Promise) { brazeImpl.getFeatureFlagBooleanProperty(flagId, key, promise) } @ReactMethod - fun getFeatureFlagStringProperty(flagId: String?, key: String?, promise: Promise?) { + fun getFeatureFlagStringProperty(flagId: String, key: String, promise: Promise) { brazeImpl.getFeatureFlagStringProperty(flagId, key, promise) } @ReactMethod - fun getFeatureFlagNumberProperty(flagId: String?, key: String?, promise: Promise?) { + fun getFeatureFlagNumberProperty(flagId: String, key: String, promise: Promise) { brazeImpl.getFeatureFlagNumberProperty(flagId, key, promise) } @@ -409,20 +409,18 @@ class BrazeReactBridge(reactContext: ReactApplicationContext?) : ReactContextBas } @ReactMethod - fun setAdTrackingEnabled(adTrackingEnabled: Boolean, googleAdvertisingId: String?) { + fun setAdTrackingEnabled(adTrackingEnabled: Boolean, googleAdvertisingId: String) { brazeImpl.setAdTrackingEnabled(adTrackingEnabled, googleAdvertisingId) } @ReactMethod - fun updateTrackingPropertyAllowList(allowList: ReadableMap?) { + fun updateTrackingPropertyAllowList(allowList: ReadableMap) { // iOS only } @ReactMethod - fun addListener(eventType: String?) { - eventType?.let { - brazeImpl.addListener(it) - } + fun addListener(eventType: String) { + brazeImpl.addListener(eventType) } @ReactMethod diff --git a/braze-react-native-sdk.podspec b/braze-react-native-sdk.podspec index 5781887..776a069 100644 --- a/braze-react-native-sdk.podspec +++ b/braze-react-native-sdk.podspec @@ -20,9 +20,9 @@ Pod::Spec.new do |s| install_modules_dependencies(s) - s.dependency 'BrazeKit', '~> 8.2.1' - s.dependency 'BrazeLocation', '~> 8.2.1' - s.dependency 'BrazeUI', '~> 8.2.1' + s.dependency 'BrazeKit', '~> 8.4.0' + s.dependency 'BrazeLocation', '~> 8.4.0' + s.dependency 'BrazeUI', '~> 8.4.0' # Swift/Objective-C compatibility s.pod_target_xcconfig = { diff --git a/package.json b/package.json index 5d0c618..6d55e34 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@braze/react-native-sdk", - "version": "9.1.0", + "version": "9.2.0", "description": "Braze SDK for React Native.", "main": "src/index.js", "types": "src/index.d.ts", diff --git a/src/NativeBrazeReactModule.ts b/src/NativeBrazeReactModule.ts index cfd1bdd..8a4f1f3 100644 --- a/src/NativeBrazeReactModule.ts +++ b/src/NativeBrazeReactModule.ts @@ -78,7 +78,7 @@ export interface Spec extends TurboModule { // `merge` indicates whether to override the existing value (false) or combine its fields (true). setCustomUserAttributeObject( key: string, - value: Object, + value: Object | null, merge: boolean, callback?: ((error?: Object, result?: boolean) => void) | null ): void;