Created
January 29, 2015 06:01
-
-
Save matzew/461fb3f6fb26cfc092e7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ApnsService service = | |
APNS.newService() | |
.withCert("/Users/matzew/Desktop/prod.p12", "ultraSecurePassword") | |
.withProductionDestination() | |
.withDelegate(new ApnsDelegate() { | |
@Override | |
public void messageSent(ApnsNotification message, boolean resent) { | |
System.out.println("messageSent ->" + message); | |
} | |
@Override | |
public void messageSendFailed(ApnsNotification message, Throwable e) { | |
System.out.println("messageSendFailed -> " + Utilities.encodeHex(message.getDeviceToken()) + "\n" +e); | |
} | |
@Override | |
public void connectionClosed(DeliveryError e, int messageIdentifier) { | |
System.out.println("Closed: " + e); | |
} | |
@Override | |
public void cacheLengthExceeded(int newCacheLength) { | |
} | |
@Override | |
public void notificationsResent(int resendCount) { | |
System.out.println("Retry: " + resendCount); | |
} | |
}) | |
.build(); | |
final String payload = APNS.newPayload().alertBody("Ahoy! It is now \r\n -> "+new Date()).sound("default").build(); | |
service.push(collectionContainingMyTokens, payload); | |
try { | |
//Thread.sleep(TimeUnit.SECONDS.toMillis(5)); | |
Thread.currentThread().join(); | |
} | |
catch (InterruptedException e) { | |
e.printStackTrace(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment