com.notnoop.apns
Class SimpleApnsNotification

java.lang.Object
  extended by com.notnoop.apns.SimpleApnsNotification
All Implemented Interfaces:
ApnsNotification

public class SimpleApnsNotification
extends Object
implements ApnsNotification

Represents an APNS notification to be sent to Apple service.


Constructor Summary
SimpleApnsNotification(byte[] dtoken, byte[] payload)
          Constructs an instance of ApnsNotification.
SimpleApnsNotification(String dtoken, String payload)
          Constructs an instance of ApnsNotification.
 
Method Summary
 boolean equals(Object obj)
           
 byte[] getDeviceToken()
          Returns the binary representation of the device token.
 int getExpiry()
          Returns the expiry date of the notification, a fixed UNIX epoch date expressed in seconds
 int getIdentifier()
          Returns the identifier of the current message.
 byte[] getPayload()
          Returns the binary representation of the payload.
 int hashCode()
           
 int length()
          Returns the length of the message in bytes as it is encoded on the wire.
 byte[] marshall()
          Returns the binary representation of the message as expected by the APNS server.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleApnsNotification

public SimpleApnsNotification(String dtoken,
                              String payload)
Constructs an instance of ApnsNotification. The message encodes the payload with a UTF-8 encoding.

Parameters:
dtoken - The Hex of the device token of the destination phone
payload - The payload message to be sent

SimpleApnsNotification

public SimpleApnsNotification(byte[] dtoken,
                              byte[] payload)
Constructs an instance of ApnsNotification.

Parameters:
dtoken - The binary representation of the destination device token
payload - The binary representation of the payload to be sent
Method Detail

getDeviceToken

public byte[] getDeviceToken()
Returns the binary representation of the device token.

Specified by:
getDeviceToken in interface ApnsNotification

getPayload

public byte[] getPayload()
Returns the binary representation of the payload.

Specified by:
getPayload in interface ApnsNotification

marshall

public byte[] marshall()
Returns the binary representation of the message as expected by the APNS server. The returned array can be used to sent directly to the APNS server (on the wire/socket) without any modification.

Specified by:
marshall in interface ApnsNotification

length

public int length()
Returns the length of the message in bytes as it is encoded on the wire. Apple require the message to be of length 255 bytes or less.

Returns:
length of encoded message in bytes

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

getIdentifier

public int getIdentifier()
Description copied from interface: ApnsNotification
Returns the identifier of the current message. The identifier is an application generated identifier.

Specified by:
getIdentifier in interface ApnsNotification
Returns:
the notification identifier

getExpiry

public int getExpiry()
Description copied from interface: ApnsNotification
Returns the expiry date of the notification, a fixed UNIX epoch date expressed in seconds

Specified by:
getExpiry in interface ApnsNotification
Returns:
the expiry date of the notification

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2013. All Rights Reserved.