From 7db1b0ae6261bf15fda08b001b1d194749e12e16 Mon Sep 17 00:00:00 2001 From: Taylor123 Date: Mon, 8 Nov 2021 15:53:09 +0000 Subject: [PATCH] allow iOS to start SDK from RN context --- .../AppboyReactBridge/AppboyReactBridge.m | 5 +++++ index.d.ts | 5 +++++ index.js | 7 +++++++ 3 files changed, 17 insertions(+) diff --git a/iOS/AppboyReactBridge/AppboyReactBridge/AppboyReactBridge.m b/iOS/AppboyReactBridge/AppboyReactBridge/AppboyReactBridge.m index 4bea6b5..32272fa 100644 --- a/iOS/AppboyReactBridge/AppboyReactBridge/AppboyReactBridge.m +++ b/iOS/AppboyReactBridge/AppboyReactBridge/AppboyReactBridge.m @@ -521,6 +521,11 @@ - (ABKCardCategory)getCardCategoryForString:(NSString *)category { [Appboy requestEnableSDKOnNextAppRun]; } +RCT_EXPORT_METHOD(startWithApiKey:(NSString *)brazeKey withLaunchOptions:(nullable NSDictionary *)launchOptions) { + UIApplication *application = [UIApplication sharedApplication]; + [Appboy startWithApiKey:brazeKey inApplication:application withLaunchOptions:launchOptions]; +} + RCT_EXPORT_METHOD(requestLocationInitialization) { RCTLogInfo(@"Warning: This is an Android only feature."); } diff --git a/index.d.ts b/index.d.ts index dd6ed88..a53292b 100644 --- a/index.d.ts +++ b/index.d.ts @@ -510,6 +510,11 @@ export function disableSDK(): void; */ export function enableSDK(): void; +/** + * Starts the Braze SDK. + */ + export function startWithApiKey(apiKey: string, options: Record | undefined): void; + /** * Call this method once a user grants location permissions on Android * to initialize Braze location features. Calling this method is a no-op on diff --git a/index.js b/index.js index a6b23df..b5f36e5 100644 --- a/index.js +++ b/index.js @@ -619,6 +619,13 @@ var ReactAppboy = { AppboyReactBridge.enableSDK(); }, + /** + * Starts the Braze SDK with an API key + */ + startWithApiKey: function(apiKey, options) { + AppboyReactBridge.startWithApiKey(apiKey, options); + }, + /** * Call this method once a user grants location permissions on Android * to initialize Braze location features. Calling this method is a no-op on