Skip to content

Instantly share code, notes, and snippets.

@pankajmi
Created April 30, 2013 11:10
Show Gist options
  • Save pankajmi/5488067 to your computer and use it in GitHub Desktop.
Save pankajmi/5488067 to your computer and use it in GitHub Desktop.
java-apns service
private val service = {
val baseBuilder =
APNS.newService().asPool(maxConnections).
asBatched(batchWaitTimeInSec, maxBatchWaitTimeInSec).
withCert(getClass.getResourceAsStream(certPath), certPassword).
withDelegate(new ApnsDelegate {
override def connectionClosed(e: DeliveryError, messageId: Int) {
logger.error(s"ConnectionClosed MessageID: $messageId Error: $e")
}
override def cacheLengthExceeded(newCacheLength: Int) {
logger.info(s"Cache length exceeded, newCacheLength: $newCacheLength")
}
override def notificationsResent(resendCount: Int) {
logger.info(s"Message resent, resend count: $resendCount")
}
override def messageSendFailed(msg: ApnsNotification, e: Throwable) {
logger.error(s"MessageSendFailed Msg: $msg Exception: $e")
}
override def messageSent(msg: ApnsNotification, resent: Boolean) {
logger.info(s"MessageSent Msg: $msg, Resent: $resent")
}
})
environment match {
case ApnsProduction => baseBuilder.withProductionDestination()
case ApnsSandbox => baseBuilder.withSandboxDestination()
}
}.build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment