Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions android/src/main/java/com/adjust/sdk/Adjust.java
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
Expand Down
20 changes: 20 additions & 0 deletions ios/AdjustSdk.m
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down