@braze/react-native-sdk
Advanced tools
Comparing version
const NativeEventEmitter = require('react-native').NativeEventEmitter; | ||
const NativeBrazeReactModule = require('../src/NativeBrazeReactModule').default; | ||
const NativeBrazeReactModule = require('../src/specs/NativeBrazeReactModule').default; | ||
@@ -141,2 +141,12 @@ import Braze from '../src/index'; | ||
test('it calls BrazeReactBridge.getBanner', () => { | ||
Braze.getBanner("some_banner_id"); | ||
expect(NativeBrazeReactModule.getBanner).toBeCalledWith("some_banner_id"); | ||
}); | ||
test('it calls BrazeReactBridge.requestBannersRefresh', () => { | ||
Braze.requestBannersRefresh(["sdk-test-1", "sdk-test-2"]); | ||
expect(NativeBrazeReactModule.requestBannersRefresh).toBeCalledWith(["sdk-test-1", "sdk-test-2"]); | ||
}); | ||
test('it calls BrazeReactBridge.launchNewsFeed', () => { | ||
@@ -143,0 +153,0 @@ Braze.launchNewsFeed(); |
@@ -15,3 +15,3 @@ jest.mock('react-native/Libraries/EventEmitter/NativeEventEmitter'); | ||
let NativeBrazeReactModule = jest.requireActual( | ||
'../src/NativeBrazeReactModule' | ||
'../src/specs/NativeBrazeReactModule' | ||
); | ||
@@ -50,2 +50,4 @@ | ||
requestFeedRefresh: jest.fn(), | ||
getBanner: jest.fn(), | ||
requestBannersRefresh: jest.fn(), | ||
requestImmediateDataFlush: jest.fn(), | ||
@@ -52,0 +54,0 @@ enableSDK: jest.fn(), |
{ | ||
"name": "@braze/react-native-sdk", | ||
"version": "13.2.0", | ||
"version": "14.0.0", | ||
"description": "Braze SDK for React Native.", | ||
@@ -62,4 +62,4 @@ "main": "src/index.js", | ||
"name": "BrazeReactModuleSpec", | ||
"type": "modules", | ||
"jsSrcsDir": "src", | ||
"type": "all", | ||
"jsSrcsDir": "src/specs", | ||
"android": { | ||
@@ -66,0 +66,0 @@ "javaPackageName": "com.braze.reactbridge" |
@@ -20,2 +20,3 @@ import { | ||
} from './models/enums'; | ||
import BannerView from './ui/braze-banner-view'; | ||
@@ -27,2 +28,3 @@ import { callFunctionWithCallback, parseNestedProperties } from './helpers'; | ||
static BrazeInAppMessage = InAppMessage; | ||
static BrazeBannerView = BannerView; | ||
@@ -39,3 +41,3 @@ static CardCategory = CardCategory; | ||
static bridge = require('./NativeBrazeReactModule').default; | ||
static bridge = require('./specs/NativeBrazeReactModule').default; | ||
static eventEmitter = Platform.select({ | ||
@@ -717,2 +719,11 @@ ios: new NativeEventEmitter(this.bridge), | ||
// Banner Cards | ||
static getBanner(placementId) { | ||
return this.bridge.getBanner(placementId); | ||
} | ||
static requestBannersRefresh(placementIds) { | ||
this.bridge.requestBannersRefresh(placementIds); | ||
} | ||
// Flush Controls | ||
@@ -719,0 +730,0 @@ /** |
@@ -713,3 +713,46 @@ // Definitions by: ahanriat <https://github.com/ahanriat> | ||
// Banner Cards | ||
/** | ||
* Braze Banner Cards | ||
*/ | ||
export interface Banner { | ||
/** The campaign and message variation IDs. */ | ||
trackingId: string; | ||
/** The placement ID this banner is matched to. */ | ||
placementId: string; | ||
/** Whether the banner is from a test send. */ | ||
isTestSend: boolean; | ||
/** Whether the banner is a control banner. */ | ||
isControl: boolean; | ||
/** The HTML to display for the banner. */ | ||
html: string; | ||
/** A Unix timestamp of the expiration date and time. A value of -1 means the banner never expires. */ | ||
expiresAt: number; | ||
} | ||
/** | ||
* Gets a banner with the provided placement ID if available in cache, otherwise returns null. | ||
* | ||
* @param placementId - The placement ID of the requested banner. | ||
* | ||
* @returns {Promise<Banner | null>} | ||
*/ | ||
export function getBanner(placementId: string): Promise<Banner | null>; | ||
/** | ||
* Requests a refresh of the banners associated with the provided placement IDs. | ||
* | ||
* If the banners are unsuccessfully refreshed, a failure will be logged on iOS only. | ||
* | ||
* @param placementIds - The list of placement IDs requested. | ||
*/ | ||
export function requestBannersRefresh(placementIds: string[]): void; | ||
/** | ||
* Requests a News Feed refresh. | ||
@@ -1441,2 +1484,9 @@ */ | ||
} | ||
/** | ||
* Received an updated list of Banner Cards from the Braze SDK. | ||
*/ | ||
export interface BannerCardsUpdatedEvent { | ||
/** A list of Banner Cards in this update. */ | ||
banners: Banner[]; | ||
} | ||
@@ -1449,2 +1499,4 @@ /** | ||
CONTENT_CARDS_UPDATED: 'contentCardsUpdated'; | ||
/** Callback passes an object with the `banners` as of the latest refresh. */ | ||
BANNER_CARDS_UPDATED: 'bannerCardsUpdated'; | ||
/** Callback passes an object containing "error_code", "user_id", "original_signature", and "reason". */ | ||
@@ -1463,2 +1515,4 @@ SDK_AUTHENTICATION_ERROR: 'sdkAuthenticationError'; | ||
export function addListener(event: "contentCardsUpdated", callback: (update: ContentCardsUpdatedEvent) => void): EmitterSubscription; | ||
/** Callback passes an object with the `banners` as of the latest refresh. */ | ||
export function addListener(event: "bannerCardsUpdated", callback: (update: BannerCardsUpdatedEvent) => void): EmitterSubscription; | ||
/** Callback passes an object containing "error_code", "user_id", "original_signature", and "reason". */ | ||
@@ -1465,0 +1519,0 @@ export function addListener(event: "sdkAuthenticationError", callback: (sdkAuthenticationError: SDKAuthenticationErrorType) => void): EmitterSubscription; |
@@ -57,2 +57,3 @@ // Enums | ||
CONTENT_CARDS_UPDATED: 'contentCardsUpdated', | ||
BANNER_CARDS_UPDATED: 'bannerCardsUpdated', | ||
NEWS_FEED_CARDS_UPDATED: 'newsFeedCardsUpdated', | ||
@@ -59,0 +60,0 @@ SDK_AUTHENTICATION_ERROR: 'sdkAuthenticationError', |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
330837
7.97%47
38.24%3736
3.03%