Package 

Class OneSignalResult


  • 
    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 success flag 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 Boolean getIsSuccess()
      final T getData() The payload on success, null on failure.
      final OneSignalError getError() The failure detail on failure, null on success.
      final Map<String, Object> toMap() Projects the envelope onto the cross-SDK wire shape consumed by the wrapper bridges.
      String toString()
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait