Skip to content

Commit

Permalink
fix: Fix for missing authorization header
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed May 2, 2023
1 parent 154b301 commit 7c56d7d
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 7 deletions.
5 changes: 5 additions & 0 deletions android/src/main/java/com/extole/android/sdk/RNExtole.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 <T> executeWithPromise(
promise: Promise,
Expand Down
8 changes: 4 additions & 4 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function HomeScreen({ navigation }: { navigation: any }) {
}, []);

const onCtaButtonPress = () => {
extole.sendEvent('deeplink', { 'extole_item': 'value', 'email': '[email protected]' });
extole.sendEvent('deeplink', { 'extole_item': 'value' });
};
return (
<View style={styles.container}>
Expand Down
2 changes: 1 addition & 1 deletion extole-mobile-sdk.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions ios/ExtoleMobileSdk.m
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
5 changes: 5 additions & 0 deletions ios/ExtoleMobileSdk.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}
2 changes: 2 additions & 0 deletions src/impl/ExtoleInternal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ export interface ExtoleInternal extends Extole {
setViewElement: (view: Element) => void;
navigationCallback: () => void;
getLogLevel: () => LogLevel;

getAccessToken: () => string;
}
4 changes: 4 additions & 0 deletions src/impl/ExtoleInternalImpl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
3 changes: 3 additions & 0 deletions src/impl/ExtoleNative.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ export class ExtoleNative {
return ExtoleMobileSdk.identify(email, params);
}

public getAccessToken() {
return ExtoleMobileSdk.getAccessToken();
}
public logout() {
return ExtoleMobileSdk.logout();
}
Expand Down
7 changes: 6 additions & 1 deletion src/impl/ViewFullScreenAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ export class ViewFullScreenAction implements Action {
zone_name = '';
data: Record<string, string> = {};

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),
Expand Down Expand Up @@ -78,6 +82,7 @@ export class ViewFullScreenAction implements Action {
}}
source={{
uri: zoneUrl.href,
headers: headers,
}}
/>,
);
Expand Down

0 comments on commit 7c56d7d

Please sign in to comment.