iphone - Push notifications with JavaPNS successful but nothing on mobile device -
problem: code appears executing fine, no errors, , proper log results, or appears, no push notifications end on iphone. i'm sending notifications apache tomcat running on mac: mountain lion.
note: can run using same certificates, except in .pem format in php. javapns not accept .pem use .p12 files. since .pem version of certificates works in php i'm starting suspect entire problem shortcoming of javapns.
background: code below executes without error , notifications.issuccessful()
returning true. receiving no message on device , no error. when had utilized wrong key got appropriate errors, , when token string long had received errors. application runs no exception nothing reaching device.
string keyfilepath = request.getservletcontext().getrealpath("")+system.getproperty("file.separator")+"keys"+system.getproperty("file.separator")+"key.p12"; list<pushednotification> notifications = push.combined (pushnotificationmessage, 1, "sound.wav", keyfilepath, "password", false, usertoken); (pushednotification notification : notifications) { if (notification.issuccessful()) { system.out.println("push notification sent to: " + notification.getdevice().gettoken()); } else { string invalidtoken = notification.getdevice().gettoken(); exception theproblem = notification.getexception(); theproblem.printstacktrace(); /* if problem error-response packet returned apple, */ responsepacket theerrorresponse = notification.getresponse(); if (theerrorresponse != null) { system.out.println(theerrorresponse.getmessage()); } } }
logs
2014-05-16 20:29:21 debug payload:219 - adding alert [blah blah blah] 2014-05-16 20:29:21 debug payload:193 - adding badge [1] 2014-05-16 20:29:21 debug payload:205 - adding sound [sound.wav] 2014-05-16 20:29:21 debug connectiontoappleserver:94 - creating sslsocketfactory 2014-05-16 20:29:21 debug connectiontoappleserver:149 - creating sslsocket gateway.sandbox.push.apple.com:2195 2014-05-16 20:29:22 debug pushnotificationmanager:111 - initialized connection host: [gateway.sandbox.push.apple.com] port: [2195]: 5dec07cc[ssl_null_with_null_null: socket[addr=gateway.sandbox.push.apple.com/17.172.232.45,port=2195,localport=51223]] 2014-05-16 20:29:22 debug pushnotificationmanager:538 - building raw message devicetoken , payload 2014-05-16 20:29:22 debug pushnotificationmanager:617 - built raw message id 1 of total length 154 2014-05-16 20:29:22 debug pushnotificationmanager:396 - attempting send notification: {"aps":{"sound":"sound.wav","alert":"blah blah blah","badge":1}} 2014-05-16 20:29:22 debug pushnotificationmanager:397 - device: cb45519c4516907a03b3b5c2f0e48aa51f6f3d900cb7598f4e3c4482b33afea8 2014-05-16 20:29:22 debug pushnotificationmanager:415 - flushing 2014-05-16 20:29:22 debug pushnotificationmanager:417 - @ point, entire 154-bytes message has been streamed out through ssl connection 2014-05-16 20:29:22 debug pushnotificationmanager:420 - notification sent on first attempt 2014-05-16 20:29:22 debug pushnotificationmanager:222 - reading responses 2014-05-16 20:29:27 debug pushnotificationmanager:200 - closing connection push notification sent to: cb45519c4516907a03b3b5c2f0e48aa51f6f3d900cb7598f4e3c4482b33afea
registration
- (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { uiremotenotificationtype notificationtypes = [[uiapplication sharedapplication] enabledremotenotificationtypes]; if (notificationtypes != (uiremotenotificationtypealert | uiremotenotificationtypebadge | uiremotenotificationtypesound) ) { [[uiapplication sharedapplication] registerforremotenotificationtypes:(uiremotenotificationtypealert | uiremotenotificationtypebadge | uiremotenotificationtypesound) ]; nslog(@"reregistering notifications"); } else { nslog(@"notifications found"); } return yes }
obtaining token
-(void)application:(uiapplication *)application didregisterforremotenotificationswithdevicetoken:(nsdata *)devicetoken { nsstring *stringtoken = [[[[devicetoken description] stringbyreplacingoccurrencesofstring: @"<" withstring: @""] stringbyreplacingoccurrencesofstring: @">" withstring: @""] stringbyreplacingoccurrencesofstring: @" " withstring: @""]; //[nsstring stringwithformat:@"%@",devicetoken]; [self sendpntoken:[nsstring stringwithformat:@"%@",stringtoken]]; nslog(@"stringtoken: %@",stringtoken); }
system
mountain lion/mac, apache tomcat, jdk 1.7
Comments
Post a Comment