grails app,使用java-apns

时间:2011-07-19 20:23:20

标签: java iphone grails apple-push-notifications

我有一个grails应用程序,我正在使用java-apns 0.1.5 jar!我有一个设备密钥,已经从中卸载我的应用程序,所以我的问题是,我是否应该从API收到相同的反馈,说该设备不再启用? 我的代码如下:

apnsService = APNS.newService()
        .withCert(pathToCertificate, password)
        .withFeedbackDestination("feedback.sandbox.push.apple.com",2196)
        .withSandboxDestination()
        .build();

apnsService.start();

Map<String, Date> inactiveDevices = apnsService.getInactiveDevices();
log.debug inactiveDevices

.....

认为,变量inactiveDevices总是空的!为什么?如果我从设备上卸载应用程序?!我在客户端(设备)方面错过了一些想法吗?

2 个答案:

答案 0 :(得分:2)

如果您使用的是沙盒目的地,则反馈服务可能不会 正确报告信息。这是已知解决方法的已知错误, 检查mailing list thread

  

问题来自“Sandbox”APNs反馈服务器,可能是一个   错误。如果有人遇到同样的问题,这是解决方案:

     

在程序门户中创建虚拟应用程序ID,启用开发推送   上面的通知创建并下载相关的配置   profile创建一个新的xcode项目,然后调用   registerForRemoteNotificationTypes方法启动时。安装假人   您设备上的应用。此时,你应该有两个开发   在您的设备上运行的应用:原始应用和虚拟应用。都   应该注册接收推送通知。卸载   原始应用,并尝试向该应用发送推送通知。调用   反馈服务,你应该收回数据。

     

要恢复,沙盒反馈服务器需要两个开发应用程序   在SAME iPhone上注册工作。这种操纵不是   作为“生产”APNs反馈的生产阶段所必需的   服务器工作正常。

我建议只使用生产服务器切换到测试反馈。 请使用生产服务器进行测试或使用变通方法。

答案 1 :(得分:0)

Hello Guys i have done push using grails APNS also with simple java lib.

1. With  Grails  : here is code snippet for APNS using grails

Hello Guys i have done push using grails APNS.
there are one Important point to remember
1. Proper apple certificate, Apple approved.: Apple approve certificate after 24 hours.
here is my code
1. in config.groovy
environments {
development {
apns {
pathToCertificate = "/Users/sarbogast/Desktop/APNs_development_certificates.p12"
password = "password"
environment = "sandbox"
}
} test {
apns {
pathToCertificate = "/usr/local/myapp/APNs_development_certificates.p12"
password = "password"
environment = "sandbox"
}
} production {
apns {
pathToCertificate = "/usr/local/myapp/APNs_production_certificates.p12"
password = "password"
environment = "production"
}
}
}2. i create a service and here is my service class code  def sendMessageToDevices() { List<string> aa = new ArrayList<string>() aa.add("Testing") def payload = APNS.newPayload() .badge(1) .localizedKey("key") .localizedArguments(aa) .sound("default") log.error(payload.length()) if (payload.isTooLong()){ log.info("Message is too long: " + payload.length()) } try { apnsService.testConnection() apnsService.push("Device token here", payload.build() ) } catch (Exception e) { log.error("Could not connect to APNs to send the notification"+e.getMessage()) } }
here "key" is any message which will popup on device push
3. i called this method by controller method..