Codota Logo
PayloadBuilder
Code IndexAdd Codota to your IDE (free)

How to use
PayloadBuilder
in
com.notnoop.apns

Best Java code snippets using com.notnoop.apns.PayloadBuilder (Showing top 14 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
OutputStreamWriter o =
  • Codota IconOutputStream out;new OutputStreamWriter(out)
  • Codota IconOutputStream out;String charsetName;new OutputStreamWriter(out, charsetName)
  • Codota IconHttpURLConnection connection;new OutputStreamWriter(connection.getOutputStream())
  • Smart code suggestions by Codota
}
origin: stackoverflow.com

PayloadBuilder payloadBuilder = APNS.newPayload()
       .alertBody(message)
       .sound(sound)
       .actionKey(actionLocKey)
       .localizedKey(locKey)
       .localizedArguments(locArgs)
       .badge(badge)
       .customFields(customData)
       .category(category);
   if (contentAvailable!=null && contentAvailable.intValue()==1){
     payloadBuilder.instantDeliveryOrSilentNotification();
   }
   payload =payloadBuilder.build();
origin: stackoverflow.com

PayloadBuilder payloadBuilder = APNS.newPayload();
   payloadBuilder = payloadBuilder
       .alertBody("yourMessage")
       .sound("default"));
origin: com.notnoop.apns/apns

/**
 * Returns a copy of this builder
 *
 * @return a copy of this builder
 */
public PayloadBuilder copy() {
  return new PayloadBuilder(root, aps, customAlert);
}
origin: com.notnoop.apns/apns

/**
 * Returns the length of payload bytes once marshaled to bytes
 *
 * @return the length of the payload
 */
public int length() {
  return copy().buildBytes().length;
}
origin: stackoverflow.com

for (ApnsDevice apnsDevice : apnsDeviceList) {
     try {
       PayloadBuilder perDevicePayloadBuilder = payloadBuilder.copy()
           .badge(apnsDevice.getBadgeCount()+1);
       // check if the message is too long (it won't be sent if it is)
       //and trim it if it is.
       if (perDevicePayloadBuilder.isTooLong()) {
         logger.warn("Payload is too long, shrinking it");
         perDevicePayloadBuilder = perDevicePayloadBuilder.shrinkBody();
       }
       String token = apnsDevice.getDeviceToken();
       service.push(token, perDevicePayloadBuilder.build());
     } catch (Exception ex) {
       logger.error("Error while pushing apns alerts", ex);
     }
   }
origin: org.apache.camel/camel-apns

private void constructNotificationAndNotify(Exchange exchange, MessageType messageType) {
  String payload;
  Collection<String> tokens;
  if (isTokensConfiguredUsingUri()) {
    if (hasTokensHeader(exchange)) {
      throw new IllegalArgumentException("Tokens already configured on endpoint " + ApnsConstants.HEADER_TOKENS);
    }
    tokens = new ArrayList<>(tokenList);
  } else {
    String tokensHeader = getHeaderTokens(exchange);
    tokens = extractTokensFromString(tokensHeader);
  }
  if (messageType == MessageType.STRING) {
    String message = exchange.getIn().getBody(String.class);
    payload = APNS.newPayload().alertBody(message).build();
  } else {
    String message = exchange.getIn().getBody(String.class);
    payload = message;
  }
  Date expiry = exchange.getIn().getHeader(ApnsConstants.HEADER_EXPIRY, Date.class);
  if (expiry != null) {
    getEndpoint().getApnsService().push(tokens, payload, expiry);
  } else {
    getEndpoint().getApnsService().push(tokens, payload);
  }
}
origin: com.notnoop.apns/apns

@Override
public String toString() {
  return build();
}
origin: com.notnoop.apns/apns

/**
 * Shrinks the alert message body so that the resulting payload
 * message fits within require Apple specification (256 bytes).
 *
 * This method performs best-effort approach, and its behavior
 * is unspecified when handling alerts where the payload
 * without body is already longer than the permitted size, or
 * if the break occurs within word.
 *
 * @return  this
 */
public PayloadBuilder shrinkBody() {
  return shrinkBody("");
}
origin: com.notnoop.apns/apns

/**
 * Requests clearing of the badge number next to the application
 * icon.
 *
 * This is an alias to {@code badge(0)}.
 *
 * @return this
 */
public PayloadBuilder clearBadge() {
  return badge(0);
}
origin: com.notnoop.apns/apns

/**
 * Set the notification view to display an action button.
 *
 * This is an alias to {@code actionKey(null)}
 *
 * @return this
 */
public PayloadBuilder noActionButton() {
  return actionKey(null);
}
origin: com.notnoop.apns/apns

public PayloadBuilder mdm(final String s) {
  return customField("mdm", s);
}
origin: com.notnoop.apns/apns

/**
 * Returns the bytes representation of the payload according to
 * Apple APNS specification
 *
 * @return the bytes as expected by Apple
 */
public byte[] buildBytes() {
  return Utilities.toUTF8Bytes(build());
}
origin: com.notnoop.apns/apns

/**
 * Returns a new Payload builder
 */
public static PayloadBuilder newPayload() {
  return new PayloadBuilder();
}
origin: com.notnoop.apns/apns

  /**
   * @return a new instance of Payload Builder
   */
  public static PayloadBuilder newPayload() {
    return new PayloadBuilder();
  }
}
com.notnoop.apnsPayloadBuilder

Javadoc

Represents a builder for constructing Payload requests, as specified by Apple Push Notification Programming Guide.

Most used methods

  • build
    Returns the JSON String representation of the payload according to Apple APNS specification
  • alertBody
    Sets the alert body text, the text the appears to the user, to the passed value
  • shrinkBody
    Shrinks the alert message body so that the resulting payload message fits within require Apple speci
  • <init>
  • actionKey
    Sets the value of action button (the right button to be displayed). The default value is "View". The
  • badge
    Sets the notification badge to be displayed next to the application icon. The passed value is the va
  • buildBytes
    Returns the bytes representation of the payload according to Apple APNS specification
  • copy
    Returns a copy of this builder
  • customField
    Sets any application-specific custom fields. The values are presented to the application and the iPh
  • insertCustomAlert
  • instantDeliveryOrSilentNotification
  • isTooLong
    Returns true if the payload built so far is larger than the size permitted by Apple (which is 256 by
  • instantDeliveryOrSilentNotification,
  • isTooLong,
  • length,
  • localizedArguments,
  • resizeAlertBody

Popular in Java

  • Making http post requests using okhttp
  • onRequestPermissionsResult (Fragment)
  • getExternalFilesDir (Context)
  • setScale (BigDecimal)
    Returns a BigDecimal whose scale is the specified value, and whose value is numerically equal to thi
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • List (java.util)
    A List is a collection which maintains an ordering for its elements. Every element in the List has a
  • Stack (java.util)
    The Stack class represents a last-in-first-out (LIFO) stack of objects. It extends class Vector with
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • Runner (org.openjdk.jmh.runner)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now