Skip to content

Commit

Permalink
Merge pull request #85 from AppsFlyerSDK/dev/RD-22661/linkGenerator-fix
Browse files Browse the repository at this point in the history
Dev/rd 22661/link generator fix
af-fess authored May 19, 2019
2 parents 6321b44 + daf9ed2 commit 789dd38
Showing 2 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -30,6 +30,7 @@

import java.util.HashMap;
import java.util.Map;
import java.util.Iterator;

import static com.appsflyer.reactnative.RNAppsFlyerConstants.*;

@@ -425,6 +426,10 @@ public void generateInviteLink(ReadableMap args, final Callback successCallback,
String customerID = null;
String baseDeepLink = null;

LinkGenerator linkGenerator = ShareInviteHelper.generateInviteUrl(getReactApplicationContext());

try {

JSONObject options = RNUtil.readableMapToJson(args);

channel = options.optString(INVITE_CHANNEL, "");
@@ -434,8 +439,6 @@ public void generateInviteLink(ReadableMap args, final Callback successCallback,
customerID = options.optString(INVITE_CUSTOMERID, "");
baseDeepLink = options.optString(INVITE_DEEPLINK, "");

LinkGenerator linkGenerator = ShareInviteHelper.generateInviteUrl(getReactApplicationContext());

if (channel != null && channel != "") {
linkGenerator.setChannel(channel);
}
@@ -455,6 +458,23 @@ public void generateInviteLink(ReadableMap args, final Callback successCallback,
linkGenerator.setBaseDeeplink(baseDeepLink);
}

if (options.length() > 1 && !options.get("userParams").equals("")) {

JSONObject jsonCustomValues = options.getJSONObject("userParams");

Iterator<?> keys = jsonCustomValues.keys();

while( keys.hasNext() ) {
String key = (String)keys.next();
Object keyvalue = jsonCustomValues.get(key);
linkGenerator.addParameter(key, keyvalue.toString());
}
}

} catch (JSONException e){

}

CreateOneLinkHttpTask.ResponseListener listener = new CreateOneLinkHttpTask.ResponseListener() {
@Override
public void onResponse(final String oneLinkUrl) {
5 changes: 5 additions & 0 deletions ios/RNAppsFlyer.m
Original file line number Diff line number Diff line change
@@ -260,6 +260,8 @@ -(NSError *) trackEventInternal: (NSString *)eventName eventValues:(NSDictionary
errorCallback:(RCTResponseSenderBlock)errorCallback)
{

NSDictionary* customParams = (NSDictionary*)[inviteLinkOptions objectForKey: @"userParams"];

NSString *channel = nil;
NSString *campaign = nil;
NSString *referrerName = nil;
@@ -296,6 +298,9 @@ -(NSError *) trackEventInternal: (NSString *)eventName eventValues:(NSDictionary
if (baseDeepLink != nil && ![baseDeepLink isEqualToString:@""]) {
[generator setDeeplinkPath:baseDeepLink];
}
if (![customParams isKindOfClass:[NSNull class]]) {
[generator addParameters:customParams];
}

return generator;
} completionHandler:^(NSURL * _Nullable url) {

0 comments on commit 789dd38

Please sign in to comment.