@Override public void start() throws Exception { byte[] pushKeyStore = initializeKeyStore(pushCertificate, pushKey); byte[] voipKeyStore = initializeKeyStore(voipCertificate, voipKey); this.pushApnService = APNS.newService() .withCert(new ByteArrayInputStream(pushKeyStore), "insecure") .asQueued() .withProductionDestination().build(); this.voipApnService = APNS.newService() .withCert(new ByteArrayInputStream(voipKeyStore), "insecure") .asQueued() .withProductionDestination().build(); if (feedbackEnabled) { this.executor.scheduleAtFixedRate(new FeedbackRunnable(), 0, 1, TimeUnit.HOURS); } }
private void constructNotificationAndNotify(Exchange exchange, MessageType messageType) { String payload; Collection<String> tokens; if (isTokensConfiguredUsingUri()) { if (hasTokensHeader(exchange)) { throw new IllegalArgumentException("Tokens already configured on endpoint " + ApnsConstants.HEADER_TOKENS); } tokens = new ArrayList<>(tokenList); } else { String tokensHeader = getHeaderTokens(exchange); tokens = extractTokensFromString(tokensHeader); } if (messageType == MessageType.STRING) { String message = exchange.getIn().getBody(String.class); payload = APNS.newPayload().alertBody(message).build(); } else { String message = exchange.getIn().getBody(String.class); payload = message; } Date expiry = exchange.getIn().getHeader(ApnsConstants.HEADER_EXPIRY, Date.class); if (expiry != null) { getEndpoint().getApnsService().push(tokens, payload, expiry); } else { getEndpoint().getApnsService().push(tokens, payload); } }
public ApnsService getApnsService() { ApnsServiceBuilder builder = APNS.newService(); builder = configureServiceBuilder(builder); configureConnectionStrategy(builder); configureReconnectionPolicy(builder); configureApnsDelegate(builder); configureApnsDestinations(builder); try { configureApnsCertificate(builder); } catch (IOException e) { throw ObjectHelper.wrapRuntimeCamelException(e); } catch (GeneralSecurityException e) { throw ObjectHelper.wrapRuntimeCamelException(e); } ApnsService apnsService = builder.build(); return apnsService; }