Created
April 30, 2013 11:10
-
-
Save pankajmi/5488067 to your computer and use it in GitHub Desktop.
java-apns service
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
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