-
public final class OneSignalResult<T extends OneSignalResultData>The outcome of an asynchronous OneSignal call: either a data payload or an error, never both and never neither.
Every SDK returns the same envelope, so a wrapper can handle results uniformly regardless of the platform underneath it:
{ "success": true, "data": { }, "error": null } { "success": false, "data": null, "error": [ { "code": "STORAGE_LOCKED", ... } ] }The presence of error is what defines the outcome; isSuccess and the wire-level
successflag are both derived from it, so the two can never disagree.Construct through success, failure, or fromMap. The internal companion is still reachable from Java, so the either/or invariant is enforced in
init, not by visibility.From Kotlin, inside a coroutine:
val result = OneSignal.login("user-123", OneSignalUserProfile.builder().setEmail("a@b.co").build()) if (result.isSuccess) println(result.data?.onesignalId) else println(result.error?.first?.code)From Java the generated accessors read naturally:
if (result.isSuccess()) { result.getData(); } else { result.getError().getDetails(); }
-
-
Method Summary
Modifier and Type Method Description final BooleangetIsSuccess()final TgetData()The payload on success, nullon failure.final OneSignalErrorgetError()The failure detail on failure, nullon success.final Map<String, Object>toMap()Projects the envelope onto the cross-SDK wire shape consumed by the wrapper bridges. StringtoString()-
-
Method Detail
-
getIsSuccess
final Boolean getIsSuccess()
-
getError
final OneSignalError getError()
The failure detail on failure,
nullon success.
-
toMap
final Map<String, Object> toMap()
Projects the envelope onto the cross-SDK wire shape consumed by the wrapper bridges.
-
-
-
-