推送通知已成功转发到apns但iphone未收到任何通知

时间:2016-07-28 10:12:34

标签: java ios iphone api

推送通知已成功转发到com.notnoop.apns api但未将通知转发给iphone。最初它工作正常,我可以从相同的代码接收通知但突然停止工作。如果你有任何想法,请建议我

我的代码:

if (!p12File.equals(null) && !password.equals(null)) {
    try {
        ClassLoader classLoader = getClass().getClassLoader();
        File file = new File(classLoader.getResource(p12File).getFile());
        if (file.exists()) {
            if (pushNotification.getPushService().equals("APNS")) {
                ApnsService service = null;
                if (pushNotification.getP12File().equals("dev")) {
                    service = APNS.newService().withCert(file.getAbsolutePath(), password).withSandboxDestination().build();
                } else if (pushNotification.getP12File().equals("dis")) {
                    service = APNS.newService().withCert(file.getAbsolutePath(), password).withProductionDestination().build();
                }
                deleteInactiveDevices(service);
                String payload = APNS.newPayload().alertBody(pushNotification.getMessage()).alertTitle(pushNotification.getTitleAlert()).
                sound("default").customField("secret", "what do you think?").build();
                String token = pushNotification.getDeviceToken();
                //  System.out.println(service.hashCode());
                service.testConnection();

                ApnsNotification ser = service.push(token, payload);

                System.out.println(ser);
            } else if (pushNotification.getPushService().equals("GCM")) {
                System.out.println("GCM Not implemented");
            }
            message = "Successfully send your push notification message";
        }
    } catch (Exception e) {
        e.printStackTrace();
        message = "Cannot send your push notification message";
    }
}

0 个答案:

没有答案