Skip to content

Commit

Permalink
Merge pull request #14 from verloop/fix/update_user_id
Browse files Browse the repository at this point in the history
Update RNVerloopSdkModule.java
  • Loading branch information
raghav39 authored Aug 20, 2021
2 parents 56b84b6 + cd227fe commit a9a8bd5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ public class RNVerloopSdkModule extends ReactContextBaseJavaModule implements Li
private VerloopConfig verloopConfig;

private Verloop verloop;

private boolean configModified;

public RNVerloopSdkModule(ReactApplicationContext reactContext) {
super(reactContext);
this.reactContext = reactContext;
reactContext.addLifecycleEventListener(this);
this.configModified = false;
}

@Override
Expand All @@ -55,6 +58,7 @@ public void buttonClicked(String title, String type, String payload) {
sendEvent(reactContext, "veloop_button_clicked", params);
}
});
configModified = true;
}

private void setUrlClickListener(VerloopConfig verloopConfig){
Expand All @@ -65,26 +69,30 @@ public void urlClicked(String url) {
sendEvent(reactContext, "veloop_url_clicked", params);
}
});
configModified = true;
}

@ReactMethod
public void createUserConfig(String clientId, String userId) {
verloopConfig = new VerloopConfig(clientId, userId);
setButtonClickListener(verloopConfig);
setUrlClickListener(verloopConfig);
configModified = true;
}

@ReactMethod
public void createAnonymousUserConfig(String clientId) {
verloopConfig = new VerloopConfig(clientId);
setButtonClickListener(verloopConfig);
setUrlClickListener(verloopConfig);
configModified = true;
}

@ReactMethod
public void setFcmToken(String token) {
if (verloopConfig != null) {
verloopConfig.setFcmToken(token);
configModified = true;
}
}

Expand All @@ -99,6 +107,7 @@ public void setStaging(Boolean isStaging) {
public void putCustomField(String key, String value) {
if (verloopConfig != null) {
verloopConfig.putCustomField(key, value);
configModified = true;
}
}

Expand All @@ -112,43 +121,49 @@ public void putCustomFieldWithScope(String key, String value, String scope) {
}else{
verloopConfig.putCustomField(key, value);
}
configModified = true;
}
}

@ReactMethod
public void setRecipeId(String recipeId) {
if (verloopConfig != null) {
verloopConfig.setRecipeId(recipeId);
configModified = true;
}
}

@ReactMethod
public void setUserEmail(String userEmail) {
if (verloopConfig != null) {
verloopConfig.setUserEmail(userEmail);
configModified = true;
}
}

@ReactMethod
public void setUserName(String userName) {
if (verloopConfig != null) {
verloopConfig.setUserName(userName);
configModified = true;
}
}

@ReactMethod
public void setUserPhone(String userPhone) {
if (verloopConfig != null) {
verloopConfig.setUserPhone(userPhone);
configModified = true;
}
}

@ReactMethod
public void showChat() {
if (verloopConfig != null) {
if(verloop == null){
if(verloop == null || configModified){
final Activity activity = getCurrentActivity();
verloop = new Verloop(activity, verloopConfig);
configModified = false;
}
verloop.showChat();
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "react-native-verloop-sdk",
"title": "React Native Verloop Sdk",
"version": "1.0.70",
"version": "1.0.71-rc1",
"description": "TODO",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit a9a8bd5

Please sign in to comment.