@braze/react-native-sdk
Advanced tools
Comparing version 7.0.0 to 8.0.0
@@ -16,8 +16,20 @@ const NativeEventEmitter = require('react-native').NativeEventEmitter; | ||
test('it calls BrazeReactBridge.registerAndroidPushToken', () => { | ||
test('it calls BrazeReactBridge.registerAndroidPushToken on Android', () => { | ||
const platform = Platform.OS; | ||
Platform.OS = 'android'; | ||
const token = "some_token"; | ||
Braze.registerAndroidPushToken(token); | ||
expect(NativeBrazeReactModule.registerPushToken).toBeCalledWith(token); | ||
Platform.OS = platform; | ||
}); | ||
test('it calls BrazeReactBridge.registerAndroidPushToken on iOS', () => { | ||
const platform = Platform.OS; | ||
Platform.OS = 'ios'; | ||
const token = "some_token"; | ||
Braze.registerAndroidPushToken(token); | ||
expect(NativeBrazeReactModule.registerPushToken).not.toBeCalledWith(token); | ||
Platform.OS = platform; | ||
}); | ||
test('it calls BrazeReactBridge.registerPushToken', () => { | ||
@@ -243,2 +255,18 @@ const token = "some_token"; | ||
test('it calls BrazeReactBridge.getUserId', () => { | ||
const user_id = "some_user_id"; | ||
Braze.changeUser(user_id); | ||
NativeBrazeReactModule.getUserId.mockImplementation((callback) => { | ||
callback(null, "some_user_id"); | ||
}); | ||
}); | ||
test('it calls BrazeReactBridge.getUserId with null', () => { | ||
const user_id = null; | ||
Braze.changeUser(user_id); | ||
NativeBrazeReactModule.getUserId.mockImplementation((callback) => { | ||
callback(null, null); | ||
}); | ||
}); | ||
test('it calls BrazeReactBridge.setSdkAuthenticationSignature', () => { | ||
@@ -245,0 +273,0 @@ const signature = "signature"; |
@@ -29,2 +29,3 @@ jest.mock('react-native/Libraries/EventEmitter/NativeEventEmitter'); | ||
changeUser: jest.fn(), | ||
getUserId: jest.fn(), | ||
setSdkAuthenticationSignature: jest.fn(), | ||
@@ -31,0 +32,0 @@ addAlias: jest.fn(), |
{ | ||
"name": "@braze/react-native-sdk", | ||
"version": "7.0.0", | ||
"version": "8.0.0", | ||
"description": "Braze SDK for React Native.", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -134,2 +134,16 @@ import { | ||
/** | ||
* Returns a unique ID stored for the user. | ||
* If the user is anonymous, there is no ID stored for the user and this method will return `null`. | ||
* | ||
* @param {function(error, result)} callback - A callback that receives the function call result. | ||
*/ | ||
static getUserId(callback) { | ||
callFunctionWithCallback( | ||
this.bridge.getUserId, | ||
[], | ||
callback | ||
); | ||
} | ||
/** | ||
* Sets the signature to be used to authenticate the current user. You can also set the signature when calling `changeUser`. | ||
@@ -166,3 +180,5 @@ * This signature will only have an effect if SDK Authentication is enabled. | ||
static registerAndroidPushToken(token) { | ||
this.bridge.registerPushToken(token); | ||
if (Platform.OS === 'android') { | ||
this.bridge.registerPushToken(token); | ||
} | ||
} | ||
@@ -836,3 +852,3 @@ | ||
* Returns feature flag | ||
* @returns {Promise<FeatureFlag>} | ||
* @returns {Promise<FeatureFlag|null>} | ||
*/ | ||
@@ -839,0 +855,0 @@ static getFeatureFlag(id) { |
@@ -70,2 +70,10 @@ // Definitions by: ahanriat <https://github.com/ahanriat> | ||
/** | ||
* Returns a unique ID stored for the user. | ||
* If the user is anonymous, there is no ID stored for the user and this method will return `null`. | ||
* | ||
* @param {function(error, result)} callback - A callback that receives the function call result. | ||
*/ | ||
export function getUserId(callback: Callback<string>): void; | ||
/** | ||
* Sets the signature to be used to authenticate the current user. You can also set the signature when calling `changeUser`. | ||
@@ -451,4 +459,4 @@ * This signature will only have an effect if SDK Authentication is enabled. | ||
export interface BannerContentCard extends ContentCardBase { | ||
type: 'Banner'; | ||
export interface ImageOnlyContentCard extends ContentCardBase { | ||
type: 'ImageOnly'; | ||
image: string; | ||
@@ -469,3 +477,3 @@ imageAspectRatio: number; | ||
| ClassicContentCard | ||
| BannerContentCard | ||
| ImageOnlyContentCard | ||
| CaptionedContentCard; | ||
@@ -701,6 +709,9 @@ | ||
/** | ||
* Get a feature flag by its ID | ||
* @returns {Promise<FeatureFlag>} | ||
* Get a feature flag by its ID. | ||
* | ||
* @param id - The ID of the feature flag. | ||
* @returns A promise containing the feature flag. | ||
* If there is no feature flag with that ID, this method will return a null. | ||
*/ | ||
export function getFeatureFlag(id: string): Promise<FeatureFlag>; | ||
export function getFeatureFlag(id: string): Promise<FeatureFlag | null>; | ||
@@ -714,3 +725,4 @@ /** | ||
* @returns A promise containing the value of the property if the key is found and is of type boolean. | ||
* If the key is not found or if there is a type mismatch, this method will return a null. | ||
* If the key is not found, if there is a type mismatch, or if there is no feature flag for that ID, | ||
* this method will return a null. | ||
*/ | ||
@@ -726,3 +738,4 @@ export function getFeatureFlagBooleanProperty(id: string, key: string): Promise<boolean | null>; | ||
* @returns A promise containing the value of the property if the key is found and is of type string. | ||
* If the key is not found or if there is a type mismatch, this method will return a null. | ||
* If the key is not found, if there is a type mismatch, or if there is no feature flag for that ID, | ||
* this method will return a null. | ||
*/ | ||
@@ -738,3 +751,4 @@ export function getFeatureFlagStringProperty(id: string, key: string): Promise<string | null>; | ||
* @returns A promise containing the value of the property if the key is found and is of type number. | ||
* If the key is not found or if there is a type mismatch, this method will return a null. | ||
* If the key is not found, if there is a type mismatch, or if there is no feature flag for that ID, | ||
* this method will return a null. | ||
*/ | ||
@@ -741,0 +755,0 @@ export function getFeatureFlagNumberProperty(id: string, key: string): Promise<number | null>; |
@@ -28,3 +28,3 @@ // Enums | ||
CLASSIC: 'Classic', | ||
BANNER: 'Banner', | ||
IMAGE_ONLY: 'ImageOnly', | ||
CAPTIONED: 'Captioned' | ||
@@ -31,0 +31,0 @@ }; |
@@ -9,2 +9,3 @@ import type { TurboModule } from 'react-native/Libraries/TurboModule/RCTExport'; | ||
changeUser(userId: string, signature?: string | null): void; | ||
getUserId(callback: (error?: Object, result?: string) => void): void; | ||
setSdkAuthenticationSignature(signature: string): void; | ||
@@ -189,3 +190,3 @@ addAlias(aliasName: string, aliasLabel: string): void; | ||
getAllFeatureFlags(): Promise<FeatureFlag[]>; | ||
getFeatureFlag(flagId: string): Promise<FeatureFlag>; | ||
getFeatureFlag(flagId: string): Promise<FeatureFlag | null>; | ||
getFeatureFlagBooleanProperty(flagId: string, key: string): Promise<boolean | null>; | ||
@@ -192,0 +193,0 @@ getFeatureFlagStringProperty(flagId: string, key: string): Promise<string | null>; |
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
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
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
252145
2875