Class PushContent

java.lang.Object
com.codename1.push.PushContent

public final class PushContent extends Object
Encapsulates the content of a Push message. Use this class inside the PushCallback#push(java.lang.String) method to retrieve details of the push, including title, body, image URL, category, type, and metadata if available.
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    Checks if there is pending push content to retrieve.
    get()
    Gets the most recent push notification content if it exists.
    If the user selected an action on the push notification, then the ID of the selected action will be stored in the PushContent's actionId.
    Gets the body of the push content.
    Gets category of the push content.
    Gets the image URL of the push content.
    Gets the metadata associated with push.
    If the push notification action included a text field for the user to enter a response, then that response will be returned here.
    Gets the title of the Push content.
    int
    Gets the type of the push content.
    static void
    Resets the push content.
    static void
    setActionId(String actionId)
    Sets the action ID of the push content.
    static void
    Sets the body of pending push content.
    static void
    setCategory(String category)
    Sets the category of the pending push content.
    static void
    setImageUrl(String imageUrl)
    Sets the image URL of pending push content.
    static void
    setMetaData(String metaData)
    Sets the metadata of pending push content.
    static void
    setTextResponse(String textResponse)
    Sets the text response for the notification.
    static void
    Sets the title of the pending push content.
    static void
    setType(int type)
    Sets the type of the push content.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • exists

      public static boolean exists()

      Checks if there is pending push content to retrieve.

      Returns

      True if there is pending push content to retrieve.

    • get

      public static PushContent get()

      Gets the most recent push notification content if it exists. This functions like Stack.pop() for a single-element stack. I.e. In addition to returning the PushContent, that push content is removed from the queue.

      if (PushContent.exists()) { PushContent content = PushContent.get(); // content should be non-null PushContent content2 = PushContent.get(); // content2 should be null PushContent.exists(); // false }

      Returns

      Pending push content if it exists.

    • reset

      public static void reset()
      Resets the push content. After calling this, PushContent#exists() will return false.
    • getTitle

      public String getTitle()

      Gets the title of the Push content.

      Returns

      the title

    • setTitle

      public static void setTitle(String title)

      Sets the title of the pending push content.

      Parameters
      • title: the title to set
      Deprecated

      For internal use only.

    • getBody

      public String getBody()

      Gets the body of the push content.

      Returns

      the body

    • setBody

      public static void setBody(String body)

      Sets the body of pending push content.

      Parameters
      • body: the body to set
      Deprecated

      For internal use only

    • getImageUrl

      public String getImageUrl()

      Gets the image URL of the push content.

      Returns

      the imageUrl

    • setImageUrl

      public static void setImageUrl(String imageUrl)

      Sets the image URL of pending push content.

      Parameters
      • imageUrl: the imageUrl to set
      Deprecated

      For internal use only.

    • getCategory

      public String getCategory()

      Gets category of the push content.

      Returns

      the category

    • setCategory

      public static void setCategory(String category)

      Sets the category of the pending push content.

      Parameters
      • category: the category to set
      Deprecated

      For internal use only.

    • getMetaData

      public String getMetaData()

      Gets the metadata associated with push. This is hidden content not shown to the user.

      Returns

      the metaData

    • setMetaData

      public static void setMetaData(String metaData)

      Sets the metadata of pending push content.

      Parameters
      • metaData: the metaData to set
      Deprecated

      For internal use only.

    • getType

      public int getType()

      Gets the type of the push content.

      Returns

      the type of the push content.

    • setType

      public static void setType(int type)

      Sets the type of the push content.

      Parameters
      • type: the type to set
      Deprecated

      For internal use only.

    • getActionId

      public String getActionId()

      If the user selected an action on the push notification, then the ID of the selected action will be stored in the PushContent's actionId. If the user did not tap an action, then this will be null.

      Returns

      The action ID that was selected by the user.

      See also
      • PushActionsProvider

      • PushActionCategory

      • PushAction

    • setActionId

      public static void setActionId(String actionId)

      Sets the action ID of the push content. The action ID is only set if the user tapped on one of the actions in the push notification; and, if set, it will be set to the ID of the action that was selected.

      Parameters
      • actionId: The ID of the action that was selected by the user.
      Deprecated

      For internal use only.

      See also
      • PushActionsProvider

      • PushActionCategory

      • PushAction

    • getTextResponse

      public String getTextResponse()

      If the push notification action included a text field for the user to enter a response, then that response will be returned here. For notifications that don't include a response, this will return null.

      Returns

      The action ID that was selected by the user.

      See also
      • PushActionsProvider

      • PushActionCategory

      • PushAction

      • PushAction#getTextInputButtonText()

      • PushAction#getTextInputPlaceholder()

    • setTextResponse

      public static void setTextResponse(String textResponse)

      Sets the text response for the notification. Only applies to notifications where the user has entered a text response.

      Deprecated

      For internal use only.

      See also
      • PushActionsProvider

      • PushActionCategory

      • PushAction

      • PushAction#getTextInputButtonText()

      • PushAction#getTextInputPlaceholder()