Class PushBuilder

java.lang.Object
com.codename1.push.PushBuilder

public class PushBuilder extends Object
A convenience class for building a push notification Payload.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    badge(int badge)
    Sets the badge to set with the push notification.
    body(String body)
    Sets the body of the push notification.
    Builds the payload for this rich push notification.
    category(String category)
    Sets the category of the push notification.
    int
    Gets the type of the notification.
    imageUrl(String imageUrl)
    Sets the URL for an image to send in the push notification.
    boolean
    A notification is considered to be a rich push notification if either #imageUrl or #category is set.
    metaData(String metaData)
    Sets the metadata (i.e. content the user shouldn't see) for the push notification.
    title(String title)
    Sets the title of the push notification.
    type(int type)
    Sets the type of the push notification.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    Modifier and Type
    Method
    Description
    protected Object
     
    boolean
    Indicates whether some other object is "equal to" this one.
    final Class
    Returns the runtime class of an object.
    int
    Returns a hash code value for the object.
    final void
    Wakes up a single thread that is waiting on this object's monitor.
    final void
    Wakes up all threads that are waiting on this object's monitor.
    Returns a string representation of the object.
    final void
    Causes current thread to wait until another thread invokes the method or the method for this object.
    final void
    wait(long timeout)
    Causes current thread to wait until either another thread invokes the method or the method for this object, or a specified amount of time has elapsed.
    final void
    wait(long timeout, int nanos)
    Causes current thread to wait until another thread invokes the method or the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
  • Constructor Details

    • PushBuilder

      public PushBuilder()
  • Method Details

    • title

      public PushBuilder title(String title)

      Sets the title of the push notification.

      Parameters
      • title: The title of the push notification.
      Returns

      Self for chaining.

    • badge

      public PushBuilder badge(int badge)

      Sets the badge to set with the push notification.

      Parameters
      • badge: The badge to set.
      Returns

      Self for chaining.

    • body

      public PushBuilder body(String body)

      Sets the body of the push notification.

      Parameters
      • body: The body of the push notification.
      Returns

      Self for chaining.

    • metaData

      public PushBuilder metaData(String metaData)

      Sets the metadata (i.e. content the user shouldn't see) for the push notification.

      Parameters
      • metaData: The metadata.
      Returns

      Self for chaining.

    • imageUrl

      public PushBuilder imageUrl(String imageUrl)

      Sets the URL for an image to send in the push notification. Make sure you use https:// or the image won't be shown on iOS.

      Parameters
      • imageUrl: The image URL.
      Returns

      Self for chaining.

    • category

      public PushBuilder category(String category)

      Sets the category of the push notification.

      Parameters
      • category: The category.
      Returns

      Self for chaining.

    • type

      public PushBuilder type(int type)

      Sets the type of the push notification.

      Types

      TypeDescription 1Sends only body as the notification message 2Sends only metadata. Invisible to user but will be received in push callback 3Sends both metadata and body. Body is visible to the user. Push callback will receive ;. 4Sends both title and body. Push callback will receive ;<body> 100Sends only the badge 101Sends the badge and body. Push callback will receive the body only. 102Sends the badge, title, and body. Push callback will receive <title>;<body></p> <p>Both <code>#imageUrl</code> and <code>#category</code> can be added to any notification type. If either of these values are non-null, then the push notification is considered to be a rich push notification, and <code>#getType()</code> will return 99, which signifies that it is a rich push notification.</p> <h6 id="parameters-heading6">Parameters</h6> <ul> <li><code>type</code>: The type of the push notification.</li> </ul> <h6 id="returns-heading6">Returns</h6> <p>Self for chaining.</p> </div> </div> </section> </li> <li> <section class="detail" id="isRichPush()"> <h3>isRichPush</h3> <div class="horizontal-scroll"> <div class="member-signature"><span class="modifiers">public</span> <span class="return-type">boolean</span> <span class="element-name">isRichPush</span>()</div> <div class="block"><p>A notification is considered to be a rich push notification if either <code>#imageUrl</code> or <code>#category</code> is set.</p> <h6 id="returns-heading7">Returns</h6> <p>True if the notification is a rich notification.</p> </div> </div> </section> </li> <li> <section class="detail" id="getType()"> <h3>getType</h3> <div class="horizontal-scroll"> <div class="member-signature"><span class="modifiers">public</span> <span class="return-type">int</span> <span class="element-name">getType</span>()</div> <div class="block"><p>Gets the type of the notification. This will return 99 if <code>#isRichPush()</code> is true. Otherwise it will return the underlying type as set with <code>#type(int)</code>.</p> <h6 id="returns-heading8">Returns</h6> <p>The type of the notification.</p> <h6 id="see-also-heading">See also</h6> <ul> <li> <p>#type(int)</p> </li> <li> <p>#isRichPush()</p> </li> </ul> </div> </div> </section> </li> <li> <section class="detail" id="build()"> <h3>build</h3> <div class="horizontal-scroll"> <div class="member-signature"><span class="modifiers">public</span> <span class="return-type"><a href="../../../java/lang/String.html" title="class in java.lang">String</a></span> <span class="element-name">build</span>()</div> <div class="block"><p>Builds the payload for this rich push notification.</p> <h6 id="returns-heading9">Returns</h6> <p>The payload that can be passed as the message body to <code>Push</code></p> </div> </div> </section> </li> </ul> </section> </li> </ul> </section> <!-- ========= END OF CLASS DATA ========= --> </main> </div> </body> </html>