开发者

grails app, using java-apns

I have a grails app, and I am using the java-apns 0.1.5 jar! I have a device key, which already uninst开发者_开发技巧all my app from it, so my question is, should I receive same feedback from the API saying that device is not enable anymore? My code is the following:

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

.....

the think is that, the variable inactiveDevices is always empty! why? if I uninstall the app from the device?! am I missing some think in the client(device) side?


If you are using the Sandbox destination, the feedback service may not report info correctly. This is a known bug with a known workaround, check the mailing list thread

The problem comes from the "Sandbox" APNs Feedback server, probably a bug. Here is the solution if anyone has the same problem:

Create a dummy app id in the program portal, enable development push notifications on it Create and download the associated provisioning profile Create a new xcode project, and invoke the registerForRemoteNotificationTypes method on start. Install the dummy app on your device. At this point, you should have two DEVELOPMENT apps running on your device: the original app and the dummy app. Both should be registered to receive push notifications. Uninstall the original app, and try to send a push notification to that app. Invoke the feedback service, and you should receive data back.

To resume, the Sandbox Feedbacks server needs TWO DEVELOPMENT Apps registered on the SAME iPhone to work. This manipulation is not necessary for the production phase as the "Production" APNs Feedback server works fine.

I would recommend just switching to test feedback with the production servers. Please either test with the production servers or use the workaround.


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..
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜