diff --git a/android/app/src/main/java/com/bitpay/wallet/MainActivity.kt b/android/app/src/main/java/com/bitpay/wallet/MainActivity.kt index 5bb3b15ace..ca753330d0 100644 --- a/android/app/src/main/java/com/bitpay/wallet/MainActivity.kt +++ b/android/app/src/main/java/com/bitpay/wallet/MainActivity.kt @@ -7,6 +7,7 @@ import android.os.Build import android.os.Bundle import android.view.View import android.view.WindowManager +import com.braze.reactbridge.BrazeReactUtils import com.braze.ui.inappmessage.BrazeInAppMessageManager import com.facebook.react.ReactActivity import com.facebook.react.ReactActivityDelegate @@ -40,6 +41,7 @@ class MainActivity : ReactActivity() { return } + BrazeReactUtils.populateInitialPushPayloadFromIntent(intent) RNBootSplash.init(this, R.style.BootTheme) supportFragmentManager.fragmentFactory = RNScreensFragmentFactory() super.onCreate(savedInstanceState) diff --git a/android/app/src/main/res/values/braze.xml b/android/app/src/main/res/values/braze.xml index 490dcaa8fa..d251bc43b8 100644 --- a/android/app/src/main/res/values/braze.xml +++ b/android/app/src/main/res/values/braze.xml @@ -1,7 +1,6 @@ - BRAZE_API_KEY_REPLACE_ME - sdk.iad-05.braze.com + true true BRAZE_SENDER_ID_REPLACE_ME false diff --git a/declarations.d.ts b/declarations.d.ts index 0ccacc1d42..fc63ee8e4a 100644 --- a/declarations.d.ts +++ b/declarations.d.ts @@ -7,6 +7,8 @@ declare module '*.svg' { declare module '@env' { export const PAYPRO_TRUSTED_KEYS: string; export const BASE_FIATRATES_MARKETSTATS_URL_DEVELOPMENT: string; + export const BRAZE_API_KEY_ANDROID: string; + export const BRAZE_API_KEY_IOS: string; export const BRAZE_EXPORT_API_KEY: string; export const BRAZE_MERGE_AND_DELETE_API_KEY: string; export const BRAZE_REST_API_ENDPOINT: string; diff --git a/ios/BitPayApp/AppDelegate.swift b/ios/BitPayApp/AppDelegate.swift index 52eceb77f9..7335353303 100644 --- a/ios/BitPayApp/AppDelegate.swift +++ b/ios/BitPayApp/AppDelegate.swift @@ -6,6 +6,7 @@ import AppsFlyerLib import RNBootSplash import BrazeKit import BrazeUI +import braze_react_native_sdk import UserNotifications import CryptoKit @@ -172,17 +173,15 @@ class AppDelegate: UIResponder, UIApplicationDelegate, BrazeInAppMessageUIDelega window?.makeKeyAndVisible() // MARK: Braze SDK setup - let config = Braze.Configuration(apiKey: "BRAZE_API_KEY_REPLACE_ME", endpoint: "sdk.iad-05.braze.com") - config.logger.level = .info - config.triggerMinimumTimeInterval = 1 - - // `BrazeReactBridge.initBraze(_:)` is an Objective-C selector; we call it dynamically - if let brazeObj = BrazeReactBridge.perform(#selector(BrazeReactBridge.initBraze(_:)), with: config)?.takeUnretainedValue() as? Braze { - self.braze = brazeObj + BrazeReactInitializer.configure({ config in + config.logger.level = .info + config.triggerMinimumTimeInterval = 1 + }, postInitialization: { [weak self] braze in + self?.braze = braze let inAppUI = BrazeInAppMessageUI() inAppUI.delegate = self - brazeObj.inAppMessagePresenter = inAppUI - } + braze.inAppMessagePresenter = inAppUI + }) // Disable URL caching globally to prevent sensitive data disclosure URLCache.shared.removeAllCachedResponses() diff --git a/ios/Podfile.lock b/ios/Podfile.lock index d5dc0e79ff..aed29e42aa 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -3,11 +3,11 @@ PODS: - AppsFlyerFramework/Main (= 6.17.9) - AppsFlyerFramework/Main (6.17.9) - boost (1.84.0) - - braze-react-native-sdk (16.1.0): + - braze-react-native-sdk (20.0.0): - boost - - BrazeKit (~> 13.2.0) - - BrazeLocation (~> 13.2.0) - - BrazeUI (~> 13.2.0) + - BrazeKit (~> 14.0.4) + - BrazeLocation (~> 14.0.4) + - BrazeUI (~> 14.0.4) - DoubleConversion - fast_float - fmt @@ -34,11 +34,11 @@ PODS: - ReactCommon/turbomodule/core - SocketRocket - Yoga - - BrazeKit (13.2.1) - - BrazeLocation (13.2.1): - - BrazeKit (= 13.2.1) - - BrazeUI (13.2.1): - - BrazeKit (= 13.2.1) + - BrazeKit (14.0.4) + - BrazeLocation (14.0.4): + - BrazeKit (= 14.0.4) + - BrazeUI (14.0.4): + - BrazeKit (= 14.0.4) - BVLinearGradient (2.6.2): - React-Core - CookieManager (6.3.0): @@ -3955,10 +3955,10 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: AppsFlyerFramework: 4f9a8237d40e9093941aef760cd77d606238aedd boost: 7e761d76ca2ce687f7cc98e698152abd03a18f90 - braze-react-native-sdk: b3bd4594310a390c12beb06b02bf0fbbfcbca7e0 - BrazeKit: dc74d3969d42e3f890461fe842e9422480269774 - BrazeLocation: 1919682502f70d3f215215b9ef2b56836dde4a9e - BrazeUI: b49f51ff3eb88657d6a97e6b3688e03a7255cbe1 + braze-react-native-sdk: 4ecf9641a4a748531fc7e074e22da9ee6f4de8be + BrazeKit: ba951d2299c1d16b541cf35cdd7250d03e28a0fb + BrazeLocation: d6938a737f123bb9e6632246d1abea40eeb12768 + BrazeUI: 1d733e1dea4d81f95f261b52cc6e4b91a0eccca8 BVLinearGradient: 34a999fda29036898a09c6a6b728b0b4189e1a44 CookieManager: ae06e97a79ea66832add0c8aa501a7986bdbb72d DoubleConversion: cb417026b2400c8f53ae97020b2be961b59470cb @@ -4099,6 +4099,6 @@ SPEC CHECKSUMS: VisionCamera: 05e4bc4783174689a5878a0797015ab32afae9e4 Yoga: 93bc00d78638987f9ffd928f4a9f895d3e601bc3 -PODFILE CHECKSUM: 91e915b372fe50cffa909299965ad28bb54bc3f7 +PODFILE CHECKSUM: a1c95fa7251801b3773e737bac8e5be40dfa3c65 COCOAPODS: 1.16.2 diff --git a/package.json b/package.json index 8e911febe1..734a243117 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "translation:download": "crowdin download --identity crowdin-credentials.yml" }, "dependencies": { - "@braze/react-native-sdk": "16.1.0", + "@braze/react-native-sdk": "20.0.0", "@ethersproject/shims": "5.7.0", "@freakycoder/react-native-bounceable": "0.2.5", "@gorhom/bottom-sheet": "5.2.6", diff --git a/scripts/braze-config.js b/scripts/braze-config.js index d072dac7a2..43adfce882 100644 --- a/scripts/braze-config.js +++ b/scripts/braze-config.js @@ -15,28 +15,10 @@ const dotenv = require('dotenv'); throw result.error; } - // Configure Braze for iOS - if (process.env.BRAZE_API_KEY_IOS) { - const brazeConfigFileIOS = `${__dirname}/../ios/BitPayApp/AppDelegate.swift`; - let contentiOS = fs.readFileSync(brazeConfigFileIOS, 'utf8'); - contentiOS = contentiOS.replace( - 'BRAZE_API_KEY_REPLACE_ME', - process.env.BRAZE_API_KEY_IOS, - ); - fs.writeFileSync(brazeConfigFileIOS, contentiOS); - } - // Configure Braze for Android const brazeConfigFileAndroid = `${__dirname}/../android/app/src/main/res/values/braze.xml`; let contentAndroid = fs.readFileSync(brazeConfigFileAndroid, 'utf8'); - if (process.env.BRAZE_API_KEY_ANDROID) { - contentAndroid = contentAndroid.replace( - 'BRAZE_API_KEY_REPLACE_ME', - process.env.BRAZE_API_KEY_ANDROID, - ); - } - if (process.env.BRAZE_SENDER_ID) { contentAndroid = contentAndroid.replace( 'BRAZE_SENDER_ID_REPLACE_ME', diff --git a/src/lib/Braze/index.ts b/src/lib/Braze/index.ts index 4854a74948..595174dd38 100644 --- a/src/lib/Braze/index.ts +++ b/src/lib/Braze/index.ts @@ -1,6 +1,12 @@ import Braze from '@braze/react-native-sdk'; import axios from 'axios'; -import {BRAZE_MERGE_AND_DELETE_API_KEY, BRAZE_REST_API_ENDPOINT} from '@env'; +import { + BRAZE_API_ENDPOINT, + BRAZE_API_KEY_ANDROID, + BRAZE_API_KEY_IOS, + BRAZE_MERGE_AND_DELETE_API_KEY, + BRAZE_REST_API_ENDPOINT, +} from '@env'; import {checkNotifications, RESULTS} from 'react-native-permissions'; import {NativeModules, Platform} from 'react-native'; import {logManager} from '../../managers/LogManager'; @@ -296,7 +302,9 @@ class BrazeClientWrapper { } private async initializeSdk(): Promise { - return Promise.resolve(); + const apiKey = + Platform.OS === 'ios' ? BRAZE_API_KEY_IOS : BRAZE_API_KEY_ANDROID; + Braze.initialize(apiKey, BRAZE_API_ENDPOINT); } } diff --git a/src/utils/braze.ts b/src/utils/braze.ts index f1aaff442f..479a2f5229 100644 --- a/src/utils/braze.ts +++ b/src/utils/braze.ts @@ -1,5 +1,4 @@ import { - BannerNewsFeedCard, CaptionedContentCard, ClassicContentCard, ContentCard, @@ -27,12 +26,6 @@ export const DEFAULT_CLASSIC_CONTENT_CARD: ClassicContentCard = { cardDescription: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', }; -export const isBannerContentCard = ( - contentCard: BannerNewsFeedCard, -): contentCard is BannerNewsFeedCard => { - return contentCard.type === 'Banner'; -}; - export const isCaptionedContentCard = ( contentCard: ContentCard, ): contentCard is CaptionedContentCard => { diff --git a/yarn.lock b/yarn.lock index ff7f01f43a..0df7b045a5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1490,10 +1490,10 @@ web3 "4.16.0" xrpl "2.13.0" -"@braze/react-native-sdk@16.1.0": - version "16.1.0" - resolved "https://registry.yarnpkg.com/@braze/react-native-sdk/-/react-native-sdk-16.1.0.tgz#d66c838a4eb38d2c5390d3dc4168767d7808a55a" - integrity sha512-IUoL+36KELKk4w6tlNdYjJ2fi0QBs2HT+yhYsupwfntvbbKPdSqlKrXU0e/xAyDv34qACcIxl2AYxeeD7Vhptg== +"@braze/react-native-sdk@20.0.0": + version "20.0.0" + resolved "https://registry.yarnpkg.com/@braze/react-native-sdk/-/react-native-sdk-20.0.0.tgz#91d1150e087d0011ff5bda4db54157cdd2110984" + integrity sha512-qpDZ6X/KxrvZeNcTcK9K6XOZc51M/SlqdkqMd+ry2C+EyzkYTCvT4LBI25gn5o6lu7DtRNa5oJanISVEPZufQw== "@cbor-extract/cbor-extract-darwin-arm64@2.2.0": version "2.2.0" @@ -16338,7 +16338,16 @@ string-range@~1.2, string-range@~1.2.1: resolved "https://registry.yarnpkg.com/string-range/-/string-range-1.2.2.tgz#a893ed347e72299bc83befbbf2a692a8d239d5dd" integrity sha512-tYft6IFi8SjplJpxCUxyqisD3b+R2CSkomrtJYCkvuf1KuCAWgz7YXt4O0jip7efpfCemwHEzTEAO8EuOYgh3w== -"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: +"string-width-cjs@npm:string-width@^4.2.0": + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + +string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -16443,7 +16452,7 @@ stringify-entities@^3.1.0: character-entities-legacy "^1.0.0" xtend "^4.0.0" -"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1: +"strip-ansi-cjs@npm:strip-ansi@^6.0.1": version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== @@ -16457,6 +16466,13 @@ strip-ansi@^5.0.0: dependencies: ansi-regex "^4.1.0" +strip-ansi@^6.0.0, strip-ansi@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + strip-ansi@^7.0.1: version "7.1.0" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45" @@ -17849,7 +17865,7 @@ word-wrap@^1.2.5: resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.5.tgz#d2c45c6dd4fbce621a66f136cbe328afd0410b34" integrity sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA== -"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== @@ -17867,6 +17883,15 @@ wrap-ansi@^6.2.0: string-width "^4.1.0" strip-ansi "^6.0.0" +wrap-ansi@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + wrap-ansi@^8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"