Skip to content

Commit

Permalink
remove try/catch block from getTags
Browse files Browse the repository at this point in the history
The try/catch block is unnecessary since creating a new JSONObject from a Map will not throw a JSONException.
  • Loading branch information
jennantilla committed Dec 5, 2023
1 parent c076c28 commit f5d1e27
Showing 1 changed file with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -577,16 +577,12 @@ public void removeTags(ReadableArray tagKeys) {

@ReactMethod
public void getTags(Promise promise) {
try {
Map<String, String> tags = OneSignal.getUser().getTags();
WritableMap writableTags = Arguments.createMap();
for (Map.Entry<String, String> entry : tags.entrySet()) {
writableTags.putString(entry.getKey(), entry.getValue());
}
promise.resolve(writableTags);
} catch (Throwable t) {
promise.reject(t.getMessage());
Map<String, String> tags = OneSignal.getUser().getTags();
WritableMap writableTags = Arguments.createMap();
for (Map.Entry<String, String> entry : tags.entrySet()) {
writableTags.putString(entry.getKey(), entry.getValue());
}
promise.resolve(writableTags);
}

@ReactMethod
Expand Down

0 comments on commit f5d1e27

Please sign in to comment.