I'm out of ideas. Whatever I try, I can't get pushy to push a message to my device. It's just silently sending it out to Apple (I think), but it never arrives.--
First of all, I downloaded an APNS testing utility from the mac app store and that app is consistently able to send a test push with the same certificate and token, so I know the credentials are valid.
I made a simple testing class and it throws no errors, RejectedNotificationListener and FailedConnectionListener are not called, the test finishes and nothing happens.
My second problem is that I am unable to enable trace logging. I use a huge library which uses maven and sl4j is in there somewhere, but I am apparently unable to figure out how to find or create the properties file - I spend a few hours on stackoverflow trying to enable logging alone. Is there a programmatic way to tell pushy to just log everything?
I updated pushy to 0.4.3, for netty I have to use 4.1.0-beta4 because of a maven dependency. This has been updated together with the 4.0.26 release, so I think it has the same changes.
My test class is pasted below. Logging works for warn and error levels. As I said, it runs through fine and gives no indication that something is wrong. What am I missing? Where could I go from here?
Thank you for listening.
public class PushTest {
public static void main(String[] args) throws Exception {
final org.slf4j.Logger log = LoggerFactory.getLogger(PushTest.class);
log.trace("trace");
log.debug("debug");
log.info("info");
log.warn("warning");
log.error("error");
PushTest pushTest = new PushTest();
}
public PushTest() throws Exception {
String pushCertificatePath = "CertAndKey20150306.p12";
System.out.println("Certificate path: " + pushCertificatePath);
final PushManager<SimpleApnsPushNotification> pushManager =
new PushManager<SimpleApnsPushNotification>(
ApnsEnvironment.getProductionEnvironment(),
SSLContextUtil.createDefaultSSLContext(pushCertificatePath, "password"),
null, // Optional: custom event loop group
null, // Optional: custom ExecutorService for calling listeners
null, // Optional: custom BlockingQueue implementation
new PushManagerConfiguration(),
"ExamplePushManager");
pushManager.registerRejectedNotificationListener(new MyRejectedNotificationListener());
pushManager.registerFailedConnectionListener(new MyFailedConnectionListener());
pushManager.start();
System.out.println("Testpush start...");
final byte[] token = TokenUtil.tokenStringToByteArray("38541569d205f99d9db7c75ef4d67462c7b3b98941cdaf69593d24a27d0d29bc");
//final byte[] token = TokenUtil.tokenStringToByteArray("<38541569 d205f99d 9db7c75e f4d67462 c7b3b989 41cdaf69 593d24a2 7d0d29bc>");
final ApnsPayloadBuilder payloadBuilder = new ApnsPayloadBuilder();
payloadBuilder.setAlertBody("Ring ring, Neo.");
payloadBuilder.setSoundFileName("ring-ring.aiff");
final String payload = payloadBuilder.buildWithDefaultMaximumLength();
SimpleApnsPushNotification sapn = new SimpleApnsPushNotification(token, payload);
System.out.println("notification: " + sapn.toString()) ;
pushManager.getQueue().put(sapn);
System.out.println("Testpush finished, shutting down...");
pushManager.shutdown();
System.out.println("Shutdown complete.");
}
class MyRejectedNotificationListener implements RejectedNotificationListener<SimpleApnsPushNotification> {
@Override
public void handleRejectedNotification(
final PushManager<? extends SimpleApnsPushNotification> pushManager,
final SimpleApnsPushNotification notification,
final RejectedNotificationReason reason) {
System.out.format("%s was rejected with rejection reason %s\n", notification, reason);
}
}
class MyFailedConnectionListener implements FailedConnectionListener<SimpleApnsPushNotification> {
@Override
public void handleFailedConnection(
final PushManager<? extends SimpleApnsPushNotification> pushManager,
final Throwable cause) {
System.out.format("handshake failed!");
if (cause instanceof SSLHandshakeException) {
// This is probably a permanent failure, and we should shut down
// the PushManager.
}
}
}
}
Pushy is an open-source Java library for sending APNs (iOS and OS X) push notifications. Pushy is brought to you by the engineers at RelayRides.
---
You received this message because you are subscribed to the Google Groups "pushy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pushy-apns+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.