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
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
import org.json.JSONException;
import org.json.JSONObject;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;

/**
* Created by David Truong dt@iterable.com
Expand Down Expand Up @@ -53,7 +54,7 @@ public class IterableApi {
private @Nullable IterableEmbeddedManager embeddedManager;
private String inboxSessionId;
private IterableAuthManager authManager;
private HashMap<String, String> deviceAttributes = new HashMap<>();
private ConcurrentHashMap<String, String> deviceAttributes = new ConcurrentHashMap<>();
private IterableKeychain keychain;


Expand Down Expand Up @@ -149,7 +150,7 @@ void setAttributionInfo(IterableAttributionInfo attributionInfo) {
);
}

HashMap getDeviceAttributes() {
Map<String, String> getDeviceAttributes() {
return deviceAttributes;
}

Expand Down Expand Up @@ -676,7 +677,7 @@ void setAuthToken(String authToken, boolean bypassAuth) {
}
}

protected void registerDeviceToken(final @Nullable String email, final @Nullable String userId, final @Nullable String authToken, final @NonNull String applicationName, final @NonNull String deviceToken, final HashMap<String, String> deviceAttributes) {
protected void registerDeviceToken(final @Nullable String email, final @Nullable String userId, final @Nullable String authToken, final @NonNull String applicationName, final @NonNull String deviceToken, final Map<String, String> deviceAttributes) {
if (deviceToken != null) {
if (!checkSDKInitialization() && _userIdUnknown == null) {
if (sharedInstance.config.enableUnknownUserActivation) {
Expand Down Expand Up @@ -721,7 +722,7 @@ protected void disableToken(@Nullable String email, @Nullable String userId, @Nu
* @param deviceToken
* @param dataFields
*/
protected void registerDeviceToken(@Nullable String email, @Nullable String userId, @Nullable String authToken, @NonNull String applicationName, @NonNull String deviceToken, @Nullable JSONObject dataFields, HashMap<String, String> deviceAttributes) {
protected void registerDeviceToken(@Nullable String email, @Nullable String userId, @Nullable String authToken, @NonNull String applicationName, @NonNull String deviceToken, @Nullable JSONObject dataFields, Map<String, String> deviceAttributes) {
if (!checkSDKInitialization()) {
return;
}
Expand Down Expand Up @@ -1226,10 +1227,18 @@ public Bundle getPayloadData() {
}

public void setDeviceAttribute(String key, String value) {
if (key == null || value == null) {
IterableLogger.e(TAG, "setDeviceAttribute: key and value must not be null");
return;
}
deviceAttributes.put(key, value);
}

public void removeDeviceAttribute(String key) {
if (key == null) {
IterableLogger.e(TAG, "removeDeviceAttribute: key must not be null");
return;
}
deviceAttributes.remove(key);
}
//endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import org.json.JSONObject;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

class IterableApiClient {
private static final String TAG = "IterableApiClient";
Expand Down Expand Up @@ -620,7 +620,7 @@ protected void disableToken(@Nullable String email, @Nullable String userId, @Nu
}
}

protected void registerDeviceToken(@Nullable String email, @Nullable String userId, @Nullable String authToken, @NonNull String applicationName, @NonNull String deviceToken, @Nullable JSONObject dataFields, HashMap<String, String> deviceAttributes, @Nullable final IterableHelper.SuccessHandler successHandler, @Nullable final IterableHelper.FailureHandler failureHandler) {
protected void registerDeviceToken(@Nullable String email, @Nullable String userId, @Nullable String authToken, @NonNull String applicationName, @NonNull String deviceToken, @Nullable JSONObject dataFields, Map<String, String> deviceAttributes, @Nullable final IterableHelper.SuccessHandler successHandler, @Nullable final IterableHelper.FailureHandler failureHandler) {
Context context = authProvider.getContext();
JSONObject requestJSON = new JSONObject();
try {
Expand All @@ -630,7 +630,7 @@ protected void registerDeviceToken(@Nullable String email, @Nullable String user
dataFields = new JSONObject();
}

for (HashMap.Entry<String, String> entry : deviceAttributes.entrySet()) {
for (Map.Entry<String, String> entry : deviceAttributes.entrySet()) {
dataFields.put(entry.getKey(), entry.getValue());
}

Expand Down
Loading