Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Android User calls to always resolve #800

Merged
merged 2 commits into from
Dec 14, 2023
Merged
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
32 changes: 18 additions & 14 deletions android/src/main/java/com/onesignal/flutter/OneSignalUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,19 @@ else if (call.method.contentEquals("OneSignal#removeTags"))

private void setLanguage(MethodCall call, Result result) {
String language = call.argument("language");
if (language != null && language.length() == 0)
language = null;

OneSignal.getUser().setLanguage(language);
if (language != null && language.length() == 0) {
language = null;
}
OneSignal.getUser().setLanguage(language);
replySuccess(result, null);
}

private void addAliases(MethodCall call, Result result) {
// call.arguments is being casted to a Map<String, Object> so a try-catch with
// a ClassCastException will be thrown
try {
OneSignal.getUser().addAliases((Map<String, String>) call.arguments);
replySuccess(result, null);
} catch(ClassCastException e) {
replyError(result, "OneSignal", "addAliases failed with error: " + e.getMessage() + "\n" + e.getStackTrace(), null);
}
Expand All @@ -75,6 +77,7 @@ private void removeAliases(MethodCall call, Result result) {
// a ClassCastException will be thrown
try {
OneSignal.getUser().removeAliases((List<String>) call.arguments);
replySuccess(result, null);
} catch(ClassCastException e) {
replyError(result, "OneSignal", "removeAliases failed with error: " + e.getMessage() + "\n" + e.getStackTrace(), null);
}
Expand All @@ -83,27 +86,29 @@ private void removeAliases(MethodCall call, Result result) {
private void addEmail(MethodCall call, Result result) {
OneSignal.getUser().addEmail((String) call.arguments);
replySuccess(result, null);
}
}

private void removeEmail(MethodCall call, Result result) {
private void removeEmail(MethodCall call, Result result) {
OneSignal.getUser().removeEmail((String) call.arguments);
replySuccess(result, null);
}
}

private void addSms(MethodCall call, Result result) {
private void addSms(MethodCall call, Result result) {
OneSignal.getUser().addSms((String) call.arguments);
replySuccess(result, null);
}
}

private void removeSms(MethodCall call, Result result) {
private void removeSms(MethodCall call, Result result) {
OneSignal.getUser().removeSms((String) call.arguments);
replySuccess(result, null);
}
private void addTags(MethodCall call, Result result) {
}

private void addTags(MethodCall call, Result result) {
// call.arguments is being casted to a Map<String, Object> so a try-catch with
// a ClassCastException will be thrown
try {
OneSignal.getUser().addTags((Map<String, String>) call.arguments);
replySuccess(result, null);
} catch(ClassCastException e) {
replyError(result, "OneSignal", "addTags failed with error: " + e.getMessage() + "\n" + e.getStackTrace(), null);
}
Expand All @@ -114,10 +119,9 @@ private void removeTags(MethodCall call, Result result) {
// a ClassCastException will be thrown
try {
OneSignal.getUser().removeTags((List<String>) call.arguments);
replySuccess(result, null);
} catch(ClassCastException e) {
replyError(result, "OneSignal", "deleteTags failed with error: " + e.getMessage() + "\n" + e.getStackTrace(), null);
}
}


}
Loading