Skip to content

Commit c42e6bc

Browse files
[SDK-395] Fix for possible NoSuchMethodException on android 5-10 versions (#1014)
1 parent 3a2f577 commit c42e6bc

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
55
## [Unreleased]
66
### Fixed
77
- Fixed `ConcurrentModificationException` crash during device token registration caused by concurrent access to `deviceAttributes`.
8+
- Fixed possible `NoSuchMethodException` crash on Android 5-10 caused by using `Map.of()` which is unavailable on those versions
89

910
## [3.7.0]
1011
- Replaced the deprecated `AsyncTask`-based push notification handling with `WorkManager` for improved reliability and compatibility with modern Android versions. No action is required.

iterableapi/src/main/java/com/iterable/iterableapi/IterableHelper.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
import androidx.annotation.NonNull;
55
import androidx.annotation.Nullable;
66

7+
import org.json.JSONException;
78
import org.json.JSONObject;
89

9-
import java.util.Map;
10-
1110
/**
1211
* Created by David Truong dt@iterable.com
1312
*/
@@ -38,7 +37,17 @@ public interface SuccessAuthHandler {
3837
}
3938

4039
class IterableResponse {
41-
static final JSONObject setEmailLocalSuccessResponse = new JSONObject(Map.of("message", "setEmail was completed locally."));
42-
43-
static final JSONObject setReadLocalSuccessResponse = new JSONObject(Map.of("message", "setRead was completed locally."));
40+
static final JSONObject setEmailLocalSuccessResponse;
41+
static final JSONObject setReadLocalSuccessResponse;
42+
43+
static {
44+
JSONObject emailResponse = new JSONObject();
45+
JSONObject readResponse = new JSONObject();
46+
try {
47+
emailResponse.put("message", "setEmail was completed locally.");
48+
readResponse.put("message", "setRead was completed locally.");
49+
} catch (JSONException ignored) {}
50+
setEmailLocalSuccessResponse = emailResponse;
51+
setReadLocalSuccessResponse = readResponse;
52+
}
4453
}

0 commit comments

Comments
 (0)