Package com.notnoop.apns

Examples of com.notnoop.apns.ApnsServiceBuilder


    public void setApnsDelegate(ApnsDelegate apnsDelegate) {
        this.apnsDelegate = apnsDelegate;
    }

    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;
    }
View Full Code Here


    public void setApnsDelegate(ApnsDelegate apnsDelegate) {
        this.apnsDelegate = apnsDelegate;
    }

    public ApnsService getApnsService() {
        ApnsServiceBuilder builder = APNS.newService();

        configureConnectionStrategy(builder);
        configureReconnectionPolicy(builder);
        configureApnsDelegate(builder);
        configureApnsDestinations(builder);
        try {
            configureApnsCertificate(builder);
        } catch (IOException e) {
            throw ObjectHelper.wrapRuntimeCamelException(e);
        }

        ApnsService apnsService = builder.build();
        return apnsService;
    }
View Full Code Here

    public ApnsDelegate getApnsDelegate() {
        return apnsDelegate;
    }

    public ApnsService getApnsService() {
        ApnsServiceBuilder builder = APNS.newService();

        configureConnectionStrategy(builder);
        configureReconnectionPolicy(builder);
        configureApnsDelegate(builder);
        configureApnsDestinations(builder);
        try {
            configureApnsCertificate(builder);
        } catch (FileNotFoundException e) {
            throw ObjectHelper.wrapRuntimeCamelException(e);
        }

        ApnsService apnsService = builder.build();
        return apnsService;
    }
View Full Code Here

    public ApnsDelegate getApnsDelegate() {
        return apnsDelegate;
    }

    public ApnsService getApnsService() {
        ApnsServiceBuilder builder = APNS.newService();

        configureConnectionStrategy(builder);
        configureReconnectionPolicy(builder);
        configureApnsDelegate(builder);
        configureApnsDestinations(builder);
        try {
            configureApnsCertificate(builder);
        } catch (FileNotFoundException e) {
            throw ObjectHelper.wrapRuntimeCamelException(e);
        }

        ApnsService apnsService = builder.build();
        return apnsService;
    }
View Full Code Here

    private ApnsService buildApnsService(iOSVariant iOSVariant, final NotificationSenderCallback notificationSenderCallback) {

        // this check should not be needed, but you never know:
        if (iOSVariant.getCertificate() != null && iOSVariant.getPassphrase() != null) {

            final ApnsServiceBuilder builder = APNS.newService().withNoErrorDetection();

            // using the APNS Delegate callback to trigger our own notifications for success/failure status:
            builder.withDelegate(new ApnsDelegateAdapter() {
                @Override
                public void messageSent(ApnsNotification message, boolean resent) {
                    notificationSenderCallback.onSuccess();
                }

                @Override
                public void messageSendFailed(ApnsNotification message, Throwable e) {
                    logger.log(Level.SEVERE, "Error sending payload to APNs server", e);
                    notificationSenderCallback.onError("Error sending payload to APNs server");
                }
            });

            // add the certificate:
            try {
                ByteArrayInputStream stream = new ByteArrayInputStream(iOSVariant.getCertificate());
                builder.withCert(stream, iOSVariant.getPassphrase());

                // release the stream
                stream.close();
            } catch (Exception e) {
                logger.log(Level.SEVERE, "Error reading certificate", e);

                // indicating an incomplete service
                return null;
            }

            // pick the destination:
            if (iOSVariant.isProduction()) {
                builder.withProductionDestination();
            } else {
                builder.withSandboxDestination();
            }

            // create the service
            return builder.build();
        }
        // null if, why ever, there was no cert/passphrase
        return null;
    }
View Full Code Here

    public ApnsDelegate getApnsDelegate() {
        return apnsDelegate;
    }

    public ApnsService getApnsService() {
        ApnsServiceBuilder builder = APNS.newService();

        configureConnectionStrategy(builder);
        configureReconnectionPolicy(builder);
        configureApnsDelegate(builder);
        configureApnsDestinations(builder);
        try {
            configureApnsCertificate(builder);
        } catch (FileNotFoundException e) {
            throw ObjectHelper.wrapRuntimeCamelException(e);
        }

        ApnsService apnsService = builder.build();
        return apnsService;
    }
View Full Code Here

    public void setApnsDelegate(ApnsDelegate apnsDelegate) {
        this.apnsDelegate = apnsDelegate;
    }

    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);
        }

        ApnsService apnsService = builder.build();
        return apnsService;
    }
View Full Code Here

    public ApnsDelegate getApnsDelegate() {
        return apnsDelegate;
    }

    public ApnsService getApnsService() {
        ApnsServiceBuilder builder = APNS.newService();

        configureConnectionStrategy(builder);
        configureReconnectionPolicy(builder);
        configureApnsDelegate(builder);
        configureApnsDestinations(builder);
        try {
            configureApnsCertificate(builder);
        } catch (IOException e) {
            throw ObjectHelper.wrapRuntimeCamelException(e);
        }

        ApnsService apnsService = builder.build();
        return apnsService;
    }
View Full Code Here

    private ApnsService buildApnsService(iOSVariant iOSVariant, final NotificationSenderCallback notificationSenderCallback) {

        // this check should not be needed, but you never know:
        if (iOSVariant.getCertificate() != null && iOSVariant.getPassphrase() != null) {

            final ApnsServiceBuilder builder = APNS.newService().withNoErrorDetection();

            // using the APNS Delegate callback to trigger our own notifications for success/failure status:
            builder.withDelegate(new ApnsDelegateAdapter() {
                @Override
                public void messageSent(ApnsNotification message, boolean resent) {
                    notificationSenderCallback.onSuccess();
                }

                @Override
                public void messageSendFailed(ApnsNotification message, Throwable e) {
                    notificationSenderCallback.onError();
                }
            });

            // add the certificate:
            try {
                ByteArrayInputStream stream = new ByteArrayInputStream(iOSVariant.getCertificate());
                builder.withCert(stream, iOSVariant.getPassphrase());

                // release the stream
                stream.close();
            } catch (Exception e) {
                logger.log(Level.SEVERE, "Error reading certificate", e);

                // indicating an incomplete service
                return null;
            }

            // pick the destination:
            if (iOSVariant.isProduction()) {
                builder.withProductionDestination();
            } else {
                builder.withSandboxDestination();
            }

            // create the service
            return builder.build();
        }
        // null if, why ever, there was no cert/passphrase
        return null;
    }
View Full Code Here

    private ApnsService buildApnsService(iOSVariant iOSVariant, final NotificationSenderCallback notificationSenderCallback) {

        // this check should not be needed, but you never know:
        if (iOSVariant.getCertificate() != null && iOSVariant.getPassphrase() != null) {

            final ApnsServiceBuilder builder = APNS.newService().withNoErrorDetection();

            // using the APNS Delegate callback to log success/failure for each token:
            builder.withDelegate(new ApnsDelegateAdapter() {
                @Override
                public void messageSent(ApnsNotification message, boolean resent) {
                    logger.fine("Sending APNs message: " + message.getDeviceToken());
                }

                @Override
                public void messageSendFailed(ApnsNotification message, Throwable e) {
                    logger.severe("Error sending payload to APNs server", e);
                }
            });

            // add the certificate:
            try {
                ByteArrayInputStream stream = new ByteArrayInputStream(iOSVariant.getCertificate());
                builder.withCert(stream, iOSVariant.getPassphrase());

                // release the stream
                stream.close();
            } catch (Exception e) {
                logger.severe("Error reading certificate", e);

                // indicating an incomplete service
                return null;
            }

            // pick the destination:
            if (iOSVariant.isProduction()) {
                builder.withProductionDestination();
            } else {
                builder.withSandboxDestination();
            }

            // create the service
            return builder.build();
        }
        // null if, why ever, there was no cert/passphrase
        return null;
    }
View Full Code Here

TOP

Related Classes of com.notnoop.apns.ApnsServiceBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.