New Command 2 Apple Push Notification Do not send multiple alerts

I am trying to implement a new 'Command 2' push notification in Java and cannot get it to push multiple alerts. The first warning completed successfully. Please help if you can detect any problem in this code.

Apple Features https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/CommunicatingWIthAPS.html#//apple_ref/doc/uid/TP40008194-CH101-SW1

for (DeviceApps deviceApps : deviceAppsList) {
outputStream.write(getByteArray(deviceApps, pushAlert));
}


private byte[] getByteArray(DeviceApps deviceApps, PushAlert pushAlert) {

ByteArrayOutputStream dataBao = new ByteArrayOutputStream();
// Write the TokenLength as a 16bits unsigned int, in big endian
dataBao.write((byte)1);
 dataBao.write(intTo2ByteArray(32));
dataBao.write(deviceTokenAsBytes);

// Write the PayloadLength as a 16bits unsigned int, in big endian
 dataBao.write((byte)2);
dataBao.write(intTo2ByteArray(payLoadAsBytes.length));
dataBao.write(payLoadAsBytes);

// 4 bytes. Notification identifier
dataBao.write((byte)3);
dataBao.write(intTo2ByteArray(4));
dataBao.write(intTo4ByteArray(random.nextInt()));

// 4 bytes Expiration date
dataBao.write((byte)4);
dataBao.write(intTo2ByteArray(4));
dataBao.write(intTo4ByteArray(pushAlert.getUtcExpireTime()));
LOG.error("UtcExpireTime="+ pushAlert.getUtcExpireTime());

// 1 bytes Priority
dataBao.write((byte)5);
dataBao.write(intTo2ByteArray(1));
dataBao.write((byte)10);


//Frame Info
bao = new ByteArrayOutputStream();
bao.write((byte)2);
byte [] data = dataBao.toByteArray();
bao.write(intTo4ByteArray(data.length));
LOG.error(" data.length "+data.length);
bao.write(data);

return bao.toByteArray();               
}


Support Methods
private static final byte[] intTo4ByteArray(int value) {
return ByteBuffer.allocate(4).putInt(value).array();
}

private static final byte[] intTo2ByteArray(int value) {
int s1 = (value & 0xFF00) >> 8;
    int s2 = value & 0xFF;
    return new byte[] { (byte) s1, (byte) s2 };
}
+2
source share
3 answers

APNS, , APNS . , - , .

- , , . , , ( 30 , , Apple ).

0

, bao, , ? , , bao .

+1

2 . , : send command 2, 5 (, , id, expiry, priority)

+1

All Articles