@braze/react-native-sdk
Advanced tools
Comparing version 5.2.0 to 6.0.0
@@ -1,3 +0,3 @@ | ||
const NativeModules = require('react-native').NativeModules; | ||
const NativeEventEmitter = require('react-native').NativeEventEmitter; | ||
const NativeBrazeReactModule = require('../src/NativeBrazeReactModule').default; | ||
@@ -18,3 +18,4 @@ import Braze from '../src/index'; | ||
Braze.registerAndroidPushToken(token); | ||
expect(NativeModules.BrazeReactBridge.registerAndroidPushToken).toBeCalledWith(token); | ||
expect(NativeBrazeReactModule.registerAndroidPushToken).toBeCalledWith(token); | ||
expect(NativeBrazeReactModule.registerAndroidPushToken).toBeCalledWith(token); | ||
}); | ||
@@ -26,3 +27,3 @@ | ||
Braze.setGoogleAdvertisingId(googleAdvertisingId, adTrackingEnabled); | ||
expect(NativeModules.BrazeReactBridge.setGoogleAdvertisingId).toBeCalledWith(googleAdvertisingId, adTrackingEnabled); | ||
expect(NativeBrazeReactModule.setGoogleAdvertisingId).toBeCalledWith(googleAdvertisingId, adTrackingEnabled); | ||
}); | ||
@@ -33,3 +34,3 @@ | ||
Braze.setFirstName(first_name); | ||
expect(NativeModules.BrazeReactBridge.setFirstName).toBeCalledWith(first_name); | ||
expect(NativeBrazeReactModule.setFirstName).toBeCalledWith(first_name); | ||
}); | ||
@@ -40,3 +41,3 @@ | ||
Braze.setLastName(last_name); | ||
expect(NativeModules.BrazeReactBridge.setLastName).toBeCalledWith(last_name); | ||
expect(NativeBrazeReactModule.setLastName).toBeCalledWith(last_name); | ||
}); | ||
@@ -47,3 +48,3 @@ | ||
Braze.setLanguage(language); | ||
expect(NativeModules.BrazeReactBridge.setLanguage).toBeCalledWith(language); | ||
expect(NativeBrazeReactModule.setLanguage).toBeCalledWith(language); | ||
}); | ||
@@ -54,3 +55,3 @@ | ||
Braze.setEmail(email); | ||
expect(NativeModules.BrazeReactBridge.setEmail).toBeCalledWith(email); | ||
expect(NativeBrazeReactModule.setEmail).toBeCalledWith(email); | ||
}); | ||
@@ -61,3 +62,3 @@ | ||
Braze.setCountry(country); | ||
expect(NativeModules.BrazeReactBridge.setCountry).toBeCalledWith(country); | ||
expect(NativeBrazeReactModule.setCountry).toBeCalledWith(country); | ||
}); | ||
@@ -68,3 +69,3 @@ | ||
Braze.setHomeCity(city); | ||
expect(NativeModules.BrazeReactBridge.setHomeCity).toBeCalledWith(city); | ||
expect(NativeBrazeReactModule.setHomeCity).toBeCalledWith(city); | ||
}); | ||
@@ -75,3 +76,3 @@ | ||
Braze.setPhoneNumber(number); | ||
expect(NativeModules.BrazeReactBridge.setPhoneNumber).toBeCalledWith(number); | ||
expect(NativeBrazeReactModule.setPhoneNumber).toBeCalledWith(number); | ||
}); | ||
@@ -81,3 +82,3 @@ | ||
Braze.requestFeedRefresh(); | ||
expect(NativeModules.BrazeReactBridge.requestFeedRefresh).toBeCalled(); | ||
expect(NativeBrazeReactModule.requestFeedRefresh).toBeCalled(); | ||
}); | ||
@@ -87,3 +88,3 @@ | ||
Braze.launchNewsFeed(); | ||
expect(NativeModules.BrazeReactBridge.launchNewsFeed).toBeCalled(); | ||
expect(NativeBrazeReactModule.launchNewsFeed).toBeCalled(); | ||
}); | ||
@@ -93,3 +94,3 @@ | ||
Braze.getNewsFeedCards(); | ||
expect(NativeModules.BrazeReactBridge.getNewsFeedCards).toBeCalled(); | ||
expect(NativeBrazeReactModule.getNewsFeedCards).toBeCalled(); | ||
}); | ||
@@ -100,3 +101,3 @@ | ||
Braze.logNewsFeedCardClicked(id); | ||
expect(NativeModules.BrazeReactBridge.logNewsFeedCardClicked).toBeCalledWith(id); | ||
expect(NativeBrazeReactModule.logNewsFeedCardClicked).toBeCalledWith(id); | ||
}); | ||
@@ -107,3 +108,3 @@ | ||
Braze.logNewsFeedCardImpression(id); | ||
expect(NativeModules.BrazeReactBridge.logNewsFeedCardImpression).toBeCalledWith(id); | ||
expect(NativeBrazeReactModule.logNewsFeedCardImpression).toBeCalledWith(id); | ||
}); | ||
@@ -113,3 +114,3 @@ | ||
Braze.launchContentCards(); | ||
expect(NativeModules.BrazeReactBridge.launchContentCards).toBeCalled(); | ||
expect(NativeBrazeReactModule.launchContentCards).toBeCalled(); | ||
}); | ||
@@ -119,3 +120,3 @@ | ||
Braze.getContentCards(); | ||
expect(NativeModules.BrazeReactBridge.getContentCards).toBeCalled(); | ||
expect(NativeBrazeReactModule.getContentCards).toBeCalled(); | ||
}); | ||
@@ -126,3 +127,3 @@ | ||
Braze.logContentCardClicked(id); | ||
expect(NativeModules.BrazeReactBridge.logContentCardClicked).toBeCalledWith(id); | ||
expect(NativeBrazeReactModule.logContentCardClicked).toBeCalledWith(id); | ||
}); | ||
@@ -133,3 +134,3 @@ | ||
Braze.logContentCardDismissed(id); | ||
expect(NativeModules.BrazeReactBridge.logContentCardDismissed).toBeCalledWith(id); | ||
expect(NativeBrazeReactModule.logContentCardDismissed).toBeCalledWith(id); | ||
}); | ||
@@ -140,3 +141,3 @@ | ||
Braze.logContentCardImpression(id); | ||
expect(NativeModules.BrazeReactBridge.logContentCardImpression).toBeCalledWith(id); | ||
expect(NativeBrazeReactModule.logContentCardImpression).toBeCalledWith(id); | ||
}); | ||
@@ -146,3 +147,3 @@ | ||
Braze.requestImmediateDataFlush(); | ||
expect(NativeModules.BrazeReactBridge.requestImmediateDataFlush).toBeCalled(); | ||
expect(NativeBrazeReactModule.requestImmediateDataFlush).toBeCalled(); | ||
}); | ||
@@ -152,3 +153,3 @@ | ||
Braze.wipeData(); | ||
expect(NativeModules.BrazeReactBridge.wipeData).toBeCalled(); | ||
expect(NativeBrazeReactModule.wipeData).toBeCalled(); | ||
}); | ||
@@ -158,3 +159,3 @@ | ||
Braze.disableSDK(); | ||
expect(NativeModules.BrazeReactBridge.disableSDK).toBeCalled(); | ||
expect(NativeBrazeReactModule.disableSDK).toBeCalled(); | ||
}); | ||
@@ -164,3 +165,3 @@ | ||
Braze.enableSDK(); | ||
expect(NativeModules.BrazeReactBridge.enableSDK).toBeCalled(); | ||
expect(NativeBrazeReactModule.enableSDK).toBeCalled(); | ||
}); | ||
@@ -170,3 +171,3 @@ | ||
Braze.requestLocationInitialization(); | ||
expect(NativeModules.BrazeReactBridge.requestLocationInitialization).toBeCalled(); | ||
expect(NativeBrazeReactModule.requestLocationInitialization).toBeCalled(); | ||
}); | ||
@@ -178,3 +179,3 @@ | ||
Braze.requestGeofences(latitude, longitude); | ||
expect(NativeModules.BrazeReactBridge.requestGeofences).toBeCalledWith(latitude, longitude); | ||
expect(NativeBrazeReactModule.requestGeofences).toBeCalledWith(latitude, longitude); | ||
}); | ||
@@ -187,3 +188,3 @@ | ||
Braze.setLocationCustomAttribute(key, latitude, longitude, testCallback); | ||
expect(NativeModules.BrazeReactBridge.setLocationCustomAttribute).toBeCalledWith(key, latitude, longitude, testCallback); | ||
expect(NativeBrazeReactModule.setLocationCustomAttribute).toBeCalledWith(key, latitude, longitude, testCallback); | ||
}); | ||
@@ -193,3 +194,3 @@ | ||
Braze.requestContentCardsRefresh(); | ||
expect(NativeModules.BrazeReactBridge.requestContentCardsRefresh).toBeCalled(); | ||
expect(NativeBrazeReactModule.requestContentCardsRefresh).toBeCalled(); | ||
}); | ||
@@ -202,3 +203,3 @@ | ||
Braze.setDateOfBirth(year, month, day); | ||
expect(NativeModules.BrazeReactBridge.setDateOfBirth).toBeCalledWith(year, month, day); | ||
expect(NativeBrazeReactModule.setDateOfBirth).toBeCalledWith(year, month, day); | ||
}); | ||
@@ -209,3 +210,3 @@ | ||
Braze.changeUser(user_id); | ||
expect(NativeModules.BrazeReactBridge.changeUser).toBeCalledWith(user_id, null); | ||
expect(NativeBrazeReactModule.changeUser).toBeCalledWith(user_id, null); | ||
}); | ||
@@ -216,3 +217,3 @@ | ||
Braze.setSdkAuthenticationSignature(signature); | ||
expect(NativeModules.BrazeReactBridge.setSdkAuthenticationSignature).toBeCalledWith(signature); | ||
expect(NativeBrazeReactModule.setSdkAuthenticationSignature).toBeCalledWith(signature); | ||
}); | ||
@@ -224,3 +225,3 @@ | ||
Braze.addAlias(aliasName, aliasLabel); | ||
expect(NativeModules.BrazeReactBridge.addAlias).toBeCalledWith(aliasName, aliasLabel); | ||
expect(NativeBrazeReactModule.addAlias).toBeCalledWith(aliasName, aliasLabel); | ||
}); | ||
@@ -232,3 +233,3 @@ | ||
Braze.logCustomEvent(event_name, event_properties); | ||
expect(NativeModules.BrazeReactBridge.logCustomEvent).toBeCalledWith(event_name, event_properties); | ||
expect(NativeBrazeReactModule.logCustomEvent).toBeCalledWith(event_name, event_properties); | ||
}); | ||
@@ -243,3 +244,3 @@ | ||
Braze.logPurchase(product_id, price, currency_code, quantity, purchase_properties); | ||
expect(NativeModules.BrazeReactBridge.logPurchase).toBeCalledWith(product_id, price, currency_code, quantity, purchase_properties); | ||
expect(NativeBrazeReactModule.logPurchase).toBeCalledWith(product_id, price, currency_code, quantity, purchase_properties); | ||
}); | ||
@@ -253,3 +254,3 @@ | ||
Braze.setAttributionData(network, campaign, adGroup, creative); | ||
expect(NativeModules.BrazeReactBridge.setAttributionData).toBeCalledWith(network, campaign, adGroup, creative); | ||
expect(NativeBrazeReactModule.setAttributionData).toBeCalledWith(network, campaign, adGroup, creative); | ||
}); | ||
@@ -261,3 +262,3 @@ | ||
Braze.setCustomUserAttribute(key, date, testCallback); | ||
expect(NativeModules.BrazeReactBridge.setDateCustomUserAttribute).toBeCalledWith(key, Math.floor(date.getTime() / 1000), testCallback); | ||
expect(NativeBrazeReactModule.setDateCustomUserAttribute).toBeCalledWith(key, Math.floor(date.getTime() / 1000), testCallback); | ||
}); | ||
@@ -269,3 +270,3 @@ | ||
Braze.setCustomUserAttribute(key, array, testCallback); | ||
expect(NativeModules.BrazeReactBridge.setCustomUserAttributeArray).toBeCalledWith(key, array, testCallback); | ||
expect(NativeBrazeReactModule.setCustomUserAttributeArray).toBeCalledWith(key, array, testCallback); | ||
}); | ||
@@ -277,3 +278,3 @@ | ||
Braze.setCustomUserAttribute(key, bool_value, testCallback); | ||
expect(NativeModules.BrazeReactBridge.setBoolCustomUserAttribute).toBeCalledWith(key, bool_value, testCallback); | ||
expect(NativeBrazeReactModule.setBoolCustomUserAttribute).toBeCalledWith(key, bool_value, testCallback); | ||
}); | ||
@@ -285,3 +286,3 @@ | ||
Braze.setCustomUserAttribute(key, string_value, testCallback); | ||
expect(NativeModules.BrazeReactBridge.setStringCustomUserAttribute).toBeCalledWith(key, string_value, testCallback); | ||
expect(NativeBrazeReactModule.setStringCustomUserAttribute).toBeCalledWith(key, string_value, testCallback); | ||
}); | ||
@@ -293,3 +294,3 @@ | ||
Braze.setCustomUserAttribute(key, int_value, testCallback); | ||
expect(NativeModules.BrazeReactBridge.setIntCustomUserAttribute).toBeCalledWith(key, int_value, testCallback); | ||
expect(NativeBrazeReactModule.setIntCustomUserAttribute).toBeCalledWith(key, int_value, testCallback); | ||
}); | ||
@@ -301,3 +302,3 @@ | ||
Braze.setCustomUserAttribute(key, double_value, testCallback); | ||
expect(NativeModules.BrazeReactBridge.setDoubleCustomUserAttribute).toBeCalledWith(key, double_value, testCallback); | ||
expect(NativeBrazeReactModule.setDoubleCustomUserAttribute).toBeCalledWith(key, double_value, testCallback); | ||
}); | ||
@@ -309,3 +310,3 @@ | ||
Braze.incrementCustomUserAttribute(key, value, testCallback); | ||
expect(NativeModules.BrazeReactBridge.incrementCustomUserAttribute).toBeCalledWith(key, value, testCallback); | ||
expect(NativeBrazeReactModule.incrementCustomUserAttribute).toBeCalledWith(key, value, testCallback); | ||
}); | ||
@@ -316,3 +317,3 @@ | ||
Braze.setGender(gender, testCallback); | ||
expect(NativeModules.BrazeReactBridge.setGender).toBeCalledWith(gender, testCallback); | ||
expect(NativeBrazeReactModule.setGender).toBeCalledWith(gender, testCallback); | ||
}); | ||
@@ -323,3 +324,3 @@ | ||
Braze.addToSubscriptionGroup(groupId, testCallback); | ||
expect(NativeModules.BrazeReactBridge.addToSubscriptionGroup).toBeCalledWith(groupId, testCallback); | ||
expect(NativeBrazeReactModule.addToSubscriptionGroup).toBeCalledWith(groupId, testCallback); | ||
}); | ||
@@ -330,3 +331,3 @@ | ||
Braze.removeFromSubscriptionGroup(groupId, testCallback); | ||
expect(NativeModules.BrazeReactBridge.removeFromSubscriptionGroup).toBeCalledWith(groupId, testCallback); | ||
expect(NativeBrazeReactModule.removeFromSubscriptionGroup).toBeCalledWith(groupId, testCallback); | ||
}); | ||
@@ -337,3 +338,3 @@ | ||
Braze.setPushNotificationSubscriptionType(sub_type, testCallback); | ||
expect(NativeModules.BrazeReactBridge.setPushNotificationSubscriptionType).toBeCalledWith(sub_type, testCallback); | ||
expect(NativeBrazeReactModule.setPushNotificationSubscriptionType).toBeCalledWith(sub_type, testCallback); | ||
}); | ||
@@ -344,17 +345,17 @@ | ||
Braze.setEmailNotificationSubscriptionType(sub_type, testCallback); | ||
expect(NativeModules.BrazeReactBridge.setEmailNotificationSubscriptionType).toBeCalledWith(sub_type, testCallback); | ||
expect(NativeBrazeReactModule.setEmailNotificationSubscriptionType).toBeCalledWith(sub_type, testCallback); | ||
}); | ||
test('it calls BrazeReactBridge.addToCustomAttributeArray', () => { | ||
test('it calls BrazeReactBridge.addToCustomUserAttributeArray', () => { | ||
const key = "some_key"; | ||
const value = "some_value" | ||
Braze.addToCustomUserAttributeArray(key, value, testCallback); | ||
expect(NativeModules.BrazeReactBridge.addToCustomAttributeArray).toBeCalledWith(key, value, testCallback); | ||
expect(NativeBrazeReactModule.addToCustomUserAttributeArray).toBeCalledWith(key, value, testCallback); | ||
}); | ||
test('it calls BrazeReactBridge.removeFromCustomAttributeArray', () => { | ||
test('it calls BrazeReactBridge.removeFromCustomUserAttributeArray', () => { | ||
const key = "some_key"; | ||
const value = "some_value" | ||
Braze.removeFromCustomUserAttributeArray(key, value, testCallback); | ||
expect(NativeModules.BrazeReactBridge.removeFromCustomAttributeArray).toBeCalledWith(key, value, testCallback); | ||
expect(NativeBrazeReactModule.removeFromCustomUserAttributeArray).toBeCalledWith(key, value, testCallback); | ||
}); | ||
@@ -365,3 +366,3 @@ | ||
Braze.unsetCustomUserAttribute(key, testCallback); | ||
expect(NativeModules.BrazeReactBridge.unsetCustomUserAttribute).toBeCalledWith(key, testCallback); | ||
expect(NativeBrazeReactModule.unsetCustomUserAttribute).toBeCalledWith(key, testCallback); | ||
}); | ||
@@ -372,3 +373,3 @@ | ||
Braze.getCardCountForCategories(category, testCallback); | ||
expect(NativeModules.BrazeReactBridge.getCardCountForCategories).toBeCalledWith(category, testCallback); | ||
expect(NativeBrazeReactModule.getCardCountForCategories).toBeCalledWith(category, testCallback); | ||
}); | ||
@@ -379,20 +380,20 @@ | ||
Braze.getUnreadCardCountForCategories(category, testCallback); | ||
expect(NativeModules.BrazeReactBridge.getUnreadCardCountForCategories).toBeCalledWith(category, testCallback); | ||
expect(NativeBrazeReactModule.getUnreadCardCountForCategories).toBeCalledWith(category, testCallback); | ||
}); | ||
test('it calls BrazeReactBridge.getInitialUrl if defined', () => { | ||
NativeModules.BrazeReactBridge.getInitialUrl.mockImplementation((callback) => { | ||
test('it calls BrazeReactBridge.getInitialURL if defined', () => { | ||
NativeBrazeReactModule.getInitialURL.mockImplementation((callback) => { | ||
callback(null, "some_data"); | ||
}); | ||
Braze.getInitialURL(testCallback); | ||
expect(NativeModules.BrazeReactBridge.getInitialUrl).toBeCalled(); | ||
expect(NativeBrazeReactModule.getInitialURL).toBeCalled(); | ||
expect(testCallback).toBeCalledWith("some_data"); | ||
}); | ||
test('it calls BrazeReactBridge.getInstallTrackingId', () => { | ||
NativeModules.BrazeReactBridge.getInstallTrackingId.mockImplementation((callback) => { | ||
test('it calls BrazeReactBridge.getDeviceId', () => { | ||
NativeBrazeReactModule.getDeviceId.mockImplementation((callback) => { | ||
callback(null, "some_tracking_id"); | ||
}); | ||
Braze.getInstallTrackingId(testCallback); | ||
expect(NativeModules.BrazeReactBridge.getInstallTrackingId).toBeCalled(); | ||
Braze.getDeviceId(testCallback); | ||
expect(NativeBrazeReactModule.getDeviceId).toBeCalled(); | ||
expect(testCallback).toBeCalledWith(null, "some_tracking_id"); | ||
@@ -402,7 +403,7 @@ }); | ||
test('it calls the callback with null and logs the error if BrazeReactBridge.getInitialUrl returns an error', () => { | ||
NativeModules.BrazeReactBridge.getInitialUrl.mockImplementation((callback) => { | ||
NativeBrazeReactModule.getInitialURL.mockImplementation((callback) => { | ||
callback("error", null); | ||
}); | ||
Braze.getInitialURL(testCallback); | ||
expect(NativeModules.BrazeReactBridge.getInitialUrl).toBeCalled(); | ||
expect(NativeBrazeReactModule.getInitialURL).toBeCalled(); | ||
expect(testCallback).toBeCalledWith(null); | ||
@@ -413,3 +414,3 @@ expect(console.log).toBeCalledWith("error"); | ||
test('it calls the callback with null if BrazeReactBridge.getInitialUrl is not defined', () => { | ||
NativeModules.BrazeReactBridge.getInitialUrl = null; | ||
NativeBrazeReactModule.getInitialURL = null; | ||
Braze.getInitialURL(testCallback); | ||
@@ -420,7 +421,7 @@ expect(testCallback).toBeCalledWith(null); | ||
test('it calls BrazeReactBridge.subscribeToInAppMessage', () => { | ||
Braze.subscribeToInAppMessage(true); | ||
expect(NativeModules.BrazeReactBridge.subscribeToInAppMessage).toBeCalledWith(true); | ||
Braze.subscribeToInAppMessage(true, testCallback); | ||
expect(NativeBrazeReactModule.subscribeToInAppMessage).toBeCalledWith(true, testCallback); | ||
Braze.subscribeToInAppMessage(false); | ||
expect(NativeModules.BrazeReactBridge.subscribeToInAppMessage).toBeCalledWith(false); | ||
Braze.subscribeToInAppMessage(false, testCallback); | ||
expect(NativeBrazeReactModule.subscribeToInAppMessage).toBeCalledWith(false, testCallback); | ||
}); | ||
@@ -430,3 +431,3 @@ | ||
Braze.hideCurrentInAppMessage(); | ||
expect(NativeModules.BrazeReactBridge.hideCurrentInAppMessage).toBeCalled(); | ||
expect(NativeBrazeReactModule.hideCurrentInAppMessage).toBeCalled(); | ||
}); | ||
@@ -517,3 +518,3 @@ | ||
Braze.logInAppMessageClicked(inAppMessage); | ||
expect(NativeModules.BrazeReactBridge.logInAppMessageClicked).toBeCalledWith(testInAppMessageJson); | ||
expect(NativeBrazeReactModule.logInAppMessageClicked).toBeCalledWith(testInAppMessageJson); | ||
}); | ||
@@ -524,3 +525,3 @@ | ||
Braze.logInAppMessageImpression(inAppMessage); | ||
expect(NativeModules.BrazeReactBridge.logInAppMessageImpression).toBeCalledWith(testInAppMessageJson); | ||
expect(NativeBrazeReactModule.logInAppMessageImpression).toBeCalledWith(testInAppMessageJson); | ||
}); | ||
@@ -532,3 +533,3 @@ | ||
Braze.logInAppMessageButtonClicked(inAppMessage, testId); | ||
expect(NativeModules.BrazeReactBridge.logInAppMessageButtonClicked).toBeCalledWith(testInAppMessageJson, testId); | ||
expect(NativeBrazeReactModule.logInAppMessageButtonClicked).toBeCalledWith(testInAppMessageJson, testId); | ||
}); | ||
@@ -546,3 +547,3 @@ | ||
Braze.requestPushPermission(options); | ||
expect(NativeModules.BrazeReactBridge.requestPushPermission).toBeCalledWith(options); | ||
expect(NativeBrazeReactModule.requestPushPermission).toBeCalledWith(options); | ||
}) | ||
@@ -584,3 +585,3 @@ | ||
Braze.getFeatureFlag('test'); | ||
expect(NativeModules.BrazeReactBridge.getFeatureFlag).toBeCalledWith(testId); | ||
expect(NativeBrazeReactModule.getFeatureFlag).toBeCalledWith(testId); | ||
}); | ||
@@ -590,3 +591,3 @@ | ||
Braze.getAllFeatureFlags(); | ||
expect(NativeModules.BrazeReactBridge.getAllFeatureFlags).toBeCalled(); | ||
expect(NativeBrazeReactModule.getAllFeatureFlags).toBeCalled(); | ||
}); | ||
@@ -596,3 +597,3 @@ | ||
Braze.refreshFeatureFlags(); | ||
expect(NativeModules.BrazeReactBridge.refreshFeatureFlags).toBeCalled(); | ||
expect(NativeBrazeReactModule.refreshFeatureFlags).toBeCalled(); | ||
}); | ||
@@ -602,3 +603,3 @@ | ||
Braze.getFeatureFlagBooleanProperty('id', 'key'); | ||
expect(NativeModules.BrazeReactBridge.getFeatureFlagBooleanProperty).toBeCalled(); | ||
expect(NativeBrazeReactModule.getFeatureFlagBooleanProperty).toBeCalled(); | ||
}); | ||
@@ -608,3 +609,3 @@ | ||
Braze.getFeatureFlagStringProperty('id', 'key'); | ||
expect(NativeModules.BrazeReactBridge.getFeatureFlagStringProperty).toBeCalled(); | ||
expect(NativeBrazeReactModule.getFeatureFlagStringProperty).toBeCalled(); | ||
}); | ||
@@ -614,3 +615,3 @@ | ||
Braze.getFeatureFlagNumberProperty('id', 'key'); | ||
expect(NativeModules.BrazeReactBridge.getFeatureFlagNumberProperty).toBeCalled(); | ||
expect(NativeBrazeReactModule.getFeatureFlagNumberProperty).toBeCalled(); | ||
}); |
@@ -1,80 +0,96 @@ | ||
// jest.mock('react-native/Libraries/EventEmitter/NativeEventEmitter.js', () => { | ||
// const { EventEmitter } = require('events'); | ||
// return EventEmitter; | ||
// }); | ||
jest.mock('react-native/Libraries/EventEmitter/NativeEventEmitter'); | ||
jest.mock('react-native', () => { | ||
const RN = jest.requireActual("react-native"); | ||
jest.mock('react-native/Libraries/TurboModule/TurboModuleRegistry', () => { | ||
const TurboModuleRegistry = jest.requireActual( | ||
'react-native/Libraries/TurboModule/TurboModuleRegistry' | ||
); | ||
RN.NativeModules.BrazeReactBridge = { | ||
registerAndroidPushToken: jest.fn(), | ||
setGoogleAdvertisingId: jest.fn(), | ||
setFirstName: jest.fn(), | ||
setLastName: jest.fn(), | ||
setLanguage: jest.fn(), | ||
setEmail: jest.fn(), | ||
setPhoneNumber: jest.fn(), | ||
changeUser: jest.fn(), | ||
setSdkAuthenticationSignature: jest.fn(), | ||
addAlias: jest.fn(), | ||
logCustomEvent: jest.fn(), | ||
logPurchase: jest.fn(), | ||
setCountry: jest.fn(), | ||
setHomeCity: jest.fn(), | ||
setDateOfBirth: jest.fn(), | ||
setAttributionData: jest.fn(), | ||
launchNewsFeed: jest.fn(), | ||
getNewsFeedCards: jest.fn(), | ||
logNewsFeedCardClicked: jest.fn(), | ||
logNewsFeedCardImpression: jest.fn(), | ||
launchContentCards: jest.fn(), | ||
getContentCards: jest.fn(), | ||
logContentCardClicked: jest.fn(), | ||
logContentCardDismissed: jest.fn(), | ||
logContentCardImpression: jest.fn(), | ||
requestFeedRefresh: jest.fn(), | ||
requestImmediateDataFlush: jest.fn(), | ||
enableSDK: jest.fn(), | ||
disableSDK: jest.fn(), | ||
wipeData: jest.fn(), | ||
setDateCustomUserAttribute: jest.fn(), | ||
setCustomUserAttributeArray: jest.fn(), | ||
setBoolCustomUserAttribute: jest.fn(), | ||
setStringCustomUserAttribute: jest.fn(), | ||
setIntCustomUserAttribute: jest.fn(), | ||
setDoubleCustomUserAttribute: jest.fn(), | ||
incrementCustomUserAttribute: jest.fn(), | ||
setGender: jest.fn(), | ||
addToSubscriptionGroup: jest.fn(), | ||
removeFromSubscriptionGroup: jest.fn(), | ||
setPushNotificationSubscriptionType: jest.fn(), | ||
setEmailNotificationSubscriptionType: jest.fn(), | ||
addToCustomAttributeArray: jest.fn(), | ||
removeFromCustomAttributeArray: jest.fn(), | ||
unsetCustomUserAttribute: jest.fn(), | ||
getCardCountForCategories: jest.fn(), | ||
getUnreadCardCountForCategories: jest.fn(), | ||
getInitialUrl: jest.fn(), | ||
getInstallTrackingId: jest.fn(), | ||
requestLocationInitialization: jest.fn(), | ||
requestGeofences: jest.fn(), | ||
setLocationCustomAttribute: jest.fn(), | ||
requestContentCardsRefresh: jest.fn(), | ||
subscribeToInAppMessage: jest.fn(), | ||
hideCurrentInAppMessage: jest.fn(), | ||
logInAppMessageClicked: jest.fn(), | ||
logInAppMessageImpression: jest.fn(), | ||
logInAppMessageButtonClicked: jest.fn(), | ||
setLastKnownLocation: jest.fn(), | ||
requestPushPermission: jest.fn(), | ||
getFeatureFlag: jest.fn(), | ||
getAllFeatureFlags: jest.fn(), | ||
refreshFeatureFlags: jest.fn(), | ||
getFeatureFlagBooleanProperty: jest.fn(), | ||
getFeatureFlagNumberProperty: jest.fn(), | ||
getFeatureFlagStringProperty: jest.fn(), | ||
return { | ||
...TurboModuleRegistry, | ||
// Overrides the `getEnforcing` method in `TurboModuleRegistry`. | ||
// This allows our unit tests to read the method stub implementations on the interface. | ||
getEnforcing: function (name) { | ||
if (name === 'BrazeReactBridge') { | ||
let NativeBrazeReactModule = jest.requireActual( | ||
'../src/NativeBrazeReactModule' | ||
); | ||
// Mocks the Turbo Module spec with Jest method stubs. | ||
NativeBrazeReactModule = { | ||
registerAndroidPushToken: jest.fn(), | ||
setGoogleAdvertisingId: jest.fn(), | ||
setFirstName: jest.fn(), | ||
setLastName: jest.fn(), | ||
setLanguage: jest.fn(), | ||
setEmail: jest.fn(), | ||
setPhoneNumber: jest.fn(), | ||
changeUser: jest.fn(), | ||
setSdkAuthenticationSignature: jest.fn(), | ||
addAlias: jest.fn(), | ||
logCustomEvent: jest.fn(), | ||
logPurchase: jest.fn(), | ||
setCountry: jest.fn(), | ||
setHomeCity: jest.fn(), | ||
setDateOfBirth: jest.fn(), | ||
setAttributionData: jest.fn(), | ||
launchNewsFeed: jest.fn(), | ||
getNewsFeedCards: jest.fn(), | ||
logNewsFeedCardClicked: jest.fn(), | ||
logNewsFeedCardImpression: jest.fn(), | ||
launchContentCards: jest.fn(), | ||
getContentCards: jest.fn(), | ||
logContentCardClicked: jest.fn(), | ||
logContentCardDismissed: jest.fn(), | ||
logContentCardImpression: jest.fn(), | ||
requestFeedRefresh: jest.fn(), | ||
requestImmediateDataFlush: jest.fn(), | ||
enableSDK: jest.fn(), | ||
disableSDK: jest.fn(), | ||
wipeData: jest.fn(), | ||
setDateCustomUserAttribute: jest.fn(), | ||
setCustomUserAttributeArray: jest.fn(), | ||
setBoolCustomUserAttribute: jest.fn(), | ||
setStringCustomUserAttribute: jest.fn(), | ||
setIntCustomUserAttribute: jest.fn(), | ||
setDoubleCustomUserAttribute: jest.fn(), | ||
incrementCustomUserAttribute: jest.fn(), | ||
setGender: jest.fn(), | ||
addToSubscriptionGroup: jest.fn(), | ||
removeFromSubscriptionGroup: jest.fn(), | ||
setPushNotificationSubscriptionType: jest.fn(), | ||
setEmailNotificationSubscriptionType: jest.fn(), | ||
addToCustomUserAttributeArray: jest.fn(), | ||
removeFromCustomUserAttributeArray: jest.fn(), | ||
unsetCustomUserAttribute: jest.fn(), | ||
getCardCountForCategories: jest.fn(), | ||
getUnreadCardCountForCategories: jest.fn(), | ||
getInitialURL: jest.fn(), | ||
getDeviceId: jest.fn(), | ||
requestLocationInitialization: jest.fn(), | ||
requestGeofences: jest.fn(), | ||
setLocationCustomAttribute: jest.fn(), | ||
requestContentCardsRefresh: jest.fn(), | ||
subscribeToInAppMessage: jest.fn(), | ||
hideCurrentInAppMessage: jest.fn(), | ||
logInAppMessageClicked: jest.fn(), | ||
logInAppMessageImpression: jest.fn(), | ||
logInAppMessageButtonClicked: jest.fn(), | ||
setLastKnownLocation: jest.fn(), | ||
requestPushPermission: jest.fn(), | ||
getFeatureFlag: jest.fn(), | ||
getAllFeatureFlags: jest.fn(), | ||
refreshFeatureFlags: jest.fn(), | ||
getFeatureFlagBooleanProperty: jest.fn(), | ||
getFeatureFlagNumberProperty: jest.fn(), | ||
getFeatureFlagStringProperty: jest.fn(), | ||
}; | ||
return { | ||
...NativeBrazeReactModule | ||
}; | ||
} | ||
return TurboModuleRegistry.getEnforcing(...arguments); | ||
} | ||
}; | ||
return RN; | ||
}); | ||
}); |
{ | ||
"name": "@braze/react-native-sdk", | ||
"version": "5.2.0", | ||
"version": "6.0.0", | ||
"description": "Braze SDK for React Native.", | ||
@@ -59,5 +59,13 @@ "main": "src/index.js", | ||
"transform": { | ||
"^.+\\.js$": "<rootDir>/node_modules/react-native/jest/preprocessor.js" | ||
"^.+\\.[jt]s$": "<rootDir>/node_modules/react-native/jest/preprocessor.js" | ||
} | ||
}, | ||
"codegenConfig": { | ||
"name": "BrazeReactModuleSpec", | ||
"type": "modules", | ||
"jsSrcsDir": "src", | ||
"android": { | ||
"javaPackageName": "com.braze.reactbridge" | ||
} | ||
} | ||
} |
@@ -15,9 +15,8 @@ <p align="center"> | ||
| Braze Plugin | React Native | | ||
| ------------ | ------------ | | ||
| 2.0.0+ | >= 0.68 | | ||
| <= 1.41.0 | <= 0.71 | | ||
| Braze Plugin | React Native | Supports New Architecture? | | ||
| ------------ | ------------ | -------------------------- | | ||
| 6.0.0+ | >= 0.68 | ✅ (>= 0.70.0) | | ||
| 2.0.0+ | >= 0.68 | ✅ | | ||
| <= 1.41.0 | <= 0.71 | ❌ | | ||
> From version 2.0.1 and up, the Braze React Native SDK is compatible with the React Native New Architecture introduced in React Native v0.68+. While our React Native SDK is currently compatible with the New Architecture as a Native Module, we are actively working on converting our Braze library to a backwards compatible Turbo Module and will continue to make improvements for the New Architecture. | ||
## Braze Expo Plugin | ||
@@ -50,3 +49,3 @@ | ||
cd ios/ | ||
pod install | ||
pod install # If you are using the New Architecture, you need to run `RCT_NEW_ARCH_ENABLED=1 pod install` instead. | ||
cd ../ | ||
@@ -53,0 +52,0 @@ npx react-native run-ios |
import { | ||
DeviceEventEmitter, | ||
NativeEventEmitter, | ||
NativeModules, | ||
Platform | ||
@@ -36,3 +35,3 @@ } from 'react-native'; | ||
static bridge = NativeModules.BrazeReactBridge; | ||
static bridge = require('./NativeBrazeReactModule').default; | ||
static eventEmitter = Platform.select({ | ||
@@ -51,4 +50,4 @@ ios: new NativeEventEmitter(this.bridge), | ||
static getInitialURL(callback) { | ||
if (this.bridge.getInitialUrl) { | ||
this.bridge.getInitialUrl((err, res) => { | ||
if (this.bridge.getInitialURL) { | ||
this.bridge.getInitialURL((err, res) => { | ||
if (err) { | ||
@@ -68,9 +67,7 @@ console.log(err); | ||
/** | ||
* Returns a unique device ID for install tracking. This method is equivalent to calling | ||
* Braze.getInstallTrackingId() on Android and returns the IDFV on iOS. | ||
* @param {function(error, result)} callback - A callback that receives the function call result. | ||
* @deprecated This method is deprecated in favor of `getDeviceId`. | ||
*/ | ||
static getInstallTrackingId(callback) { | ||
callFunctionWithCallback( | ||
this.bridge.getInstallTrackingId, | ||
this.bridge.getDeviceId, | ||
[], | ||
@@ -82,2 +79,19 @@ callback | ||
/** | ||
* Returns a unique ID stored on the device. | ||
* | ||
* On Android, a randomly generated, app specific ID that is stored on the device. A new ID will be generated if the user | ||
* clears the data for the app or removes/re-installs the app. The ID will persist across Braze.changeUser calls. | ||
* | ||
* On iOS, this ID is generated from the IDFV. This behavior will be updated in the next major version. | ||
* @param {function(error, result)} callback - A callback that receives the function call result. | ||
*/ | ||
static getDeviceId(callback) { | ||
callFunctionWithCallback( | ||
this.bridge.getDeviceId, | ||
[], | ||
callback | ||
); | ||
} | ||
/** | ||
* When a user first uses Braze on a device they are considered "anonymous". Use this method to identify a user | ||
@@ -456,3 +470,3 @@ * with a unique ID, which enables the following: | ||
callFunctionWithCallback( | ||
this.bridge.addToCustomAttributeArray, | ||
this.bridge.addToCustomUserAttributeArray, | ||
[key, value], | ||
@@ -473,3 +487,3 @@ callback | ||
callFunctionWithCallback( | ||
this.bridge.removeFromCustomAttributeArray, | ||
this.bridge.removeFromCustomUserAttributeArray, | ||
[key, value], | ||
@@ -709,3 +723,3 @@ callback | ||
} | ||
this.bridge.subscribeToInAppMessage(withBrazeUI); | ||
this.bridge.subscribeToInAppMessage(withBrazeUI, subscriber); | ||
@@ -712,0 +726,0 @@ if (typeof subscriber === "function") { |
@@ -17,5 +17,3 @@ // Definitions by: ahanriat <https://github.com/ahanriat> | ||
/** | ||
* Returns a unique device ID for install tracking. This method is equivalent to calling | ||
* Braze.getInstallTrackingId() on Android and returns the IDFV on iOS. | ||
* @param {function(error, result)} callback - A callback that receives the function call result. | ||
* @deprecated This method is deprecated in favor of `getDeviceId`. | ||
*/ | ||
@@ -25,2 +23,13 @@ export function getInstallTrackingId(callback: Callback<string>): void; | ||
/** | ||
* Returns a unique ID stored on the device. | ||
* | ||
* On Android, a randomly generated, app specific ID that is stored on the device. A new ID will be generated if the user | ||
* clears the data for the app or removes/re-installs the app. The ID will persist across Braze.changeUser calls. | ||
* | ||
* On iOS, this ID is generated from the IDFV. This behavior will be updated in the next major version. | ||
* @param {function(error, result)} callback - A callback that receives the function call result. | ||
*/ | ||
export function getDeviceId(callback: Callback<string>): void; | ||
/** | ||
* When a user first uses Braze on a device they are considered "anonymous". Use this method to identify a user | ||
@@ -561,3 +570,3 @@ * with a unique ID, which enables the following: | ||
useBrazeUI: boolean, | ||
callback?: Function | ||
callback?: (event: {inAppMessage: BrazeInAppMessage}) => void | ||
): EmitterSubscription | undefined; | ||
@@ -687,3 +696,3 @@ | ||
*/ | ||
export function refreshFeatureFlags(); | ||
export function refreshFeatureFlags(): void; | ||
@@ -988,2 +997,2 @@ export class BrazeInAppMessage { | ||
| 'ZMW' | ||
| 'ZWL'; | ||
| 'ZWL'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
231833
34
2619
66