|
17 | 17 | import org.json.JSONException; |
18 | 18 | import org.json.JSONObject; |
19 | 19 |
|
20 | | -import java.util.HashMap; |
21 | 20 | import java.util.List; |
| 21 | +import java.util.Map; |
22 | 22 | import java.util.Objects; |
23 | 23 | import java.util.UUID; |
| 24 | +import java.util.concurrent.ConcurrentHashMap; |
24 | 25 |
|
25 | 26 | /** |
26 | 27 | * Created by David Truong dt@iterable.com |
@@ -55,7 +56,7 @@ public class IterableApi { |
55 | 56 | private @Nullable IterableEmbeddedManager embeddedManager; |
56 | 57 | private String inboxSessionId; |
57 | 58 | private IterableAuthManager authManager; |
58 | | - private HashMap<String, String> deviceAttributes = new HashMap<>(); |
| 59 | + private ConcurrentHashMap<String, String> deviceAttributes = new ConcurrentHashMap<>(); |
59 | 60 | private IterableKeychain keychain; |
60 | 61 |
|
61 | 62 |
|
@@ -159,7 +160,7 @@ void setAttributionInfo(IterableAttributionInfo attributionInfo) { |
159 | 160 | ); |
160 | 161 | } |
161 | 162 |
|
162 | | - HashMap getDeviceAttributes() { |
| 163 | + Map<String, String> getDeviceAttributes() { |
163 | 164 | return deviceAttributes; |
164 | 165 | } |
165 | 166 |
|
@@ -695,7 +696,7 @@ void setAuthToken(String authToken, boolean bypassAuth) { |
695 | 696 | } |
696 | 697 | } |
697 | 698 |
|
698 | | - 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) { |
| 699 | + 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) { |
699 | 700 | if (deviceToken != null) { |
700 | 701 | if (!checkSDKInitialization() && _userIdUnknown == null) { |
701 | 702 | if (sharedInstance.config.enableUnknownUserActivation) { |
@@ -740,7 +741,7 @@ protected void disableToken(@Nullable String email, @Nullable String userId, @Nu |
740 | 741 | * @param deviceToken |
741 | 742 | * @param dataFields |
742 | 743 | */ |
743 | | - 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) { |
| 744 | + 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) { |
744 | 745 | if (!checkSDKInitialization()) { |
745 | 746 | return; |
746 | 747 | } |
@@ -1245,10 +1246,18 @@ public Bundle getPayloadData() { |
1245 | 1246 | } |
1246 | 1247 |
|
1247 | 1248 | public void setDeviceAttribute(String key, String value) { |
| 1249 | + if (key == null || value == null) { |
| 1250 | + IterableLogger.e(TAG, "setDeviceAttribute: key and value must not be null"); |
| 1251 | + return; |
| 1252 | + } |
1248 | 1253 | deviceAttributes.put(key, value); |
1249 | 1254 | } |
1250 | 1255 |
|
1251 | 1256 | public void removeDeviceAttribute(String key) { |
| 1257 | + if (key == null) { |
| 1258 | + IterableLogger.e(TAG, "removeDeviceAttribute: key must not be null"); |
| 1259 | + return; |
| 1260 | + } |
1252 | 1261 | deviceAttributes.remove(key); |
1253 | 1262 | } |
1254 | 1263 | //endregion |
|
0 commit comments