diff --git a/android/src/main/java/com/extole/android/sdk/RNExtole.kt b/android/src/main/java/com/extole/android/sdk/RNExtole.kt index d13e036..3c78a11 100644 --- a/android/src/main/java/com/extole/android/sdk/RNExtole.kt +++ b/android/src/main/java/com/extole/android/sdk/RNExtole.kt @@ -162,6 +162,11 @@ class RNExtole(reactContext: ReactApplicationContext?) : promise.resolve(JSONArray(extole?.getJsonConfiguration()).toString()) } + @ReactMethod + fun getAccessToken(promise: Promise) { + promise.resolve(extole?.getAccessToken()) + } + @Suppress("TooGenericExceptionCaught") private fun executeWithPromise( promise: Promise, diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index ed2c876..82562fb 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -4,11 +4,11 @@ PODS: - CocoaAsyncSocket (7.6.5) - DoubleConversion (1.1.6) - extole-mobile-sdk (0.0.2): - - ExtoleMobileSDK (~> 0.0.42) + - ExtoleMobileSDK (~> 0.0.43) - React-Core - ExtoleConsumerAPI (0.0.17): - Alamofire (~> 5.1.0) - - ExtoleMobileSDK (0.0.42): + - ExtoleMobileSDK (0.0.43): - ExtoleConsumerAPI (~> 0.0.17) - Logging (~> 1.4) - ObjectMapper (~> 4.1.0) @@ -568,9 +568,9 @@ SPEC CHECKSUMS: boost: a7c83b31436843459a1961bfd74b96033dc77234 CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99 DoubleConversion: 831926d9b8bf8166fd87886c4abab286c2422662 - extole-mobile-sdk: 3b5e13fe33f4334064b025b28507745e551c0b46 + extole-mobile-sdk: b99ec2ae2549f5d5dd70d6cb6c9502acda98e619 ExtoleConsumerAPI: 4e512cfee398d5fba446ca04076ee382cbf0979b - ExtoleMobileSDK: a8f9dda3f9ffa42e67a603a6e95cae16b90c48d5 + ExtoleMobileSDK: 0616225e29a6b3dc54bfef761f8e7086952b8e76 FBLazyVector: a7a655862f6b09625d11c772296b01cd5164b648 FBReactNativeSpec: 81ce99032d5b586fddd6a38d450f8595f7e04be4 Flipper: 26fc4b7382499f1281eb8cb921e5c3ad6de91fe0 diff --git a/example/src/App.tsx b/example/src/App.tsx index a5ab770..d6ed473 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -45,7 +45,7 @@ function HomeScreen({ navigation }: { navigation: any }) { }, []); const onCtaButtonPress = () => { - extole.sendEvent('deeplink', { 'extole_item': 'value', 'email': 'email@mailosaur.com' }); + extole.sendEvent('deeplink', { 'extole_item': 'value' }); }; return ( diff --git a/extole-mobile-sdk.podspec b/extole-mobile-sdk.podspec index 7bcab7f..4535b5f 100644 --- a/extole-mobile-sdk.podspec +++ b/extole-mobile-sdk.podspec @@ -17,7 +17,7 @@ Pod::Spec.new do |s| s.source_files = "ios/**/*.{h,m,mm,swift}" s.dependency "React-Core" - s.dependency "ExtoleMobileSDK", '~> 0.0.42' + s.dependency "ExtoleMobileSDK", '~> 0.0.43' # Don't install the dependencies when we run `pod install` in the old architecture. if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then diff --git a/ios/ExtoleMobileSdk.m b/ios/ExtoleMobileSdk.m index 63fe468..2a38b3b 100644 --- a/ios/ExtoleMobileSdk.m +++ b/ios/ExtoleMobileSdk.m @@ -45,6 +45,9 @@ @interface RCT_EXTERN_MODULE(ExtoleMobileSdk, NSObject) RCT_EXTERN_METHOD(getJsonConfiguration:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject) +RCT_EXTERN_METHOD(getAccessToken:(RCTPromiseResolveBlock)resolve + withRejecter:(RCTPromiseRejectBlock)reject) + RCT_EXTERN_METHOD(extoleView:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject) diff --git a/ios/ExtoleMobileSdk.swift b/ios/ExtoleMobileSdk.swift index 1a7acf5..5ea1730 100644 --- a/ios/ExtoleMobileSdk.swift +++ b/ios/ExtoleMobileSdk.swift @@ -92,4 +92,9 @@ class ExtoleMobileSdk: NSObject { func getJsonConfiguration(resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) { resolve(extole?.getJsonConfiguration()) } + + @objc(getAccessToken:withRejecter:) + func getAccessToken(resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) { + resolve(extole?.getAccessToken()) + } } diff --git a/src/impl/ExtoleInternal.tsx b/src/impl/ExtoleInternal.tsx index 4263903..ccfc56f 100644 --- a/src/impl/ExtoleInternal.tsx +++ b/src/impl/ExtoleInternal.tsx @@ -5,4 +5,6 @@ export interface ExtoleInternal extends Extole { setViewElement: (view: Element) => void; navigationCallback: () => void; getLogLevel: () => LogLevel; + + getAccessToken: () => string; } diff --git a/src/impl/ExtoleInternalImpl.tsx b/src/impl/ExtoleInternalImpl.tsx index 69ec438..f4f42a6 100644 --- a/src/impl/ExtoleInternalImpl.tsx +++ b/src/impl/ExtoleInternalImpl.tsx @@ -104,6 +104,10 @@ export class ExtoleInternalImpl implements ExtoleInternal { return this.logLevel; } + public getAccessToken(): string { + return this.extoleNative.getAccessToken(); + } + public logout(): void { this.extoleNative.logout(); } diff --git a/src/impl/ExtoleNative.tsx b/src/impl/ExtoleNative.tsx index 6eabca3..24390b2 100644 --- a/src/impl/ExtoleNative.tsx +++ b/src/impl/ExtoleNative.tsx @@ -71,6 +71,9 @@ export class ExtoleNative { return ExtoleMobileSdk.identify(email, params); } + public getAccessToken() { + return ExtoleMobileSdk.getAccessToken(); + } public logout() { return ExtoleMobileSdk.logout(); } diff --git a/src/impl/ViewFullScreenAction.tsx b/src/impl/ViewFullScreenAction.tsx index ef001ce..d8861bf 100644 --- a/src/impl/ViewFullScreenAction.tsx +++ b/src/impl/ViewFullScreenAction.tsx @@ -13,10 +13,14 @@ export class ViewFullScreenAction implements Action { zone_name = ''; data: Record = {}; - execute(event: AppEvent, extole: ExtoleInternal) { + async execute(event: AppEvent, extole: ExtoleInternal) { const zoneUrl = new URL( 'https://' + extole.getProgramDomain() + '/zone/' + this.zone_name, ); + const accessToken = await extole.getAccessToken(); + const headers = { + 'Authorization': 'Bearer ' + accessToken, + }; for (const key in event.params) { zoneUrl.searchParams.append( encodeURIComponent(key), @@ -78,6 +82,7 @@ export class ViewFullScreenAction implements Action { }} source={{ uri: zoneUrl.href, + headers: headers, }} />, );