diff --git a/android/src/main/java/com/adjust/sdk/Adjust.java b/android/src/main/java/com/adjust/sdk/Adjust.java index ff206fa5..9f729bf3 100755 --- a/android/src/main/java/com/adjust/sdk/Adjust.java +++ b/android/src/main/java/com/adjust/sdk/Adjust.java @@ -739,6 +739,33 @@ public void onAdidRead(String adid) { }); } + @ReactMethod + public void resolveLinkWithUrl(final String url, final ReadableArray resolveUrlSuffixArray, final Callback callback) { + if (url == null || callback == null) { + return; + } + + String[] suffixArray = null; + if (resolveUrlSuffixArray != null) { + suffixArray = new String[resolveUrlSuffixArray.size()]; + for (int i = 0; i < resolveUrlSuffixArray.size(); i++) { + suffixArray[i] = resolveUrlSuffixArray.getString(i); + } + } + + com.adjust.sdk.AdjustLinkResolution.resolveLink( + url, + suffixArray, + new com.adjust.sdk.AdjustLinkResolution.AdjustLinkResolutionCallback() { + @Override + public void resolvedLinkCallback(Uri resolvedLink) { + String resolvedUrl = resolvedLink != null ? resolvedLink.toString() : ""; + callback.invoke(resolvedUrl); + } + } + ); + } + @ReactMethod public void getLastDeeplink(final Callback callback) { com.adjust.sdk.Adjust.getLastDeeplink( diff --git a/index.d.ts b/index.d.ts index 662ddaa1..b98f323b 100644 --- a/index.d.ts +++ b/index.d.ts @@ -236,6 +236,7 @@ declare module 'react-native-adjust' { getAppTrackingAuthorizationStatus: (callback: (status: number) => void) => void trackThirdPartySharing: (adjustThirdPartySharing: AdjustThirdPartySharing) => void trackMeasurementConsent: (measurementConsent: boolean) => void + resolveLinkWithUrl: (url: string, resolveUrlSuffixArray: string[], callback: (resolvedLink: string) => void) => void getLastDeeplink: (callback: (lastDeeplink: string) => void) => void verifyAppStorePurchase: (purchase: AdjustAppStorePurchase, callback: (verificationResult: AdjustPurchaseVerificationResult) => void) => void verifyAndTrackAppStorePurchase: (adjustEvent: AdjustEvent, callback: (verificationResult: AdjustPurchaseVerificationResult) => void) => void diff --git a/index.js b/index.js index ff08aed9..cbe02b6f 100644 --- a/index.js +++ b/index.js @@ -149,6 +149,10 @@ Adjust.getAdid = function(callback) { module_adjust.getAdid(callback); }; +Adjust.resolveLinkWithUrl = function(url, resolveUrlSuffixArray, callback) { + module_adjust.resolveLinkWithUrl(url, resolveUrlSuffixArray, callback); +}; + Adjust.getLastDeeplink = function(callback) { module_adjust.getLastDeeplink(callback); }; diff --git a/ios/AdjustSdk.m b/ios/AdjustSdk.m index 6ab19356..b701ab89 100644 --- a/ios/AdjustSdk.m +++ b/ios/AdjustSdk.m @@ -553,6 +553,26 @@ @implementation AdjustSdk }]; } +RCT_EXPORT_METHOD(resolveLinkWithUrl:(NSString *)url resolveUrlSuffixArray:(NSArray *)resolveUrlSuffixArray callback:(RCTResponseSenderBlock)callback) { + NSURL *nsUrl; + if ([NSString instancesRespondToSelector:@selector(stringByAddingPercentEncodingWithAllowedCharacters:)]) { + nsUrl = [NSURL URLWithString:[url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]]]; + } else { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + nsUrl = [NSURL URLWithString:[url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; +#pragma clang diagnostic pop + } + + [ADJLinkResolution resolveLinkWithUrl:nsUrl resolveUrlSuffixArray:resolveUrlSuffixArray callback:^(NSURL *resolvedLink) { + if (resolvedLink == nil) { + callback(@[@""]); + } else { + callback(@[resolvedLink.absoluteString]); + } + }]; +} + RCT_EXPORT_METHOD(getLastDeeplink:(RCTResponseSenderBlock)callback) { [Adjust lastDeeplinkWithCompletionHandler:^(NSURL * _Nullable lastDeeplink) { if (nil == lastDeeplink) {