java - Method for know unregistered tokens in APNS server (using Spring Server) -


successfully done push notification in android. , deal ios push notification.

in case of gcm sever push notification, server notify token unregistered or invalid etc. likewise there method in apns server.

please check code send push notification in apns

 public void pushmessage() {         apnsservice service = null;         try {             // certificate             inputstream certstream = this.getclass().getclassloader().getresourceasstream("your_certificate.p12");             service = apns.newservice().withcert(certstream, "your_cert_password").withsandboxdestination().build();             // or             // service = apns.newservice().withcert(certstream,             // "your_cert_password").withproductiondestination().build();             service.start();              // read user list             list<user> userlist = userdao.readusers();             (user user : userlist) {                 try {                     // had daily update here, need know how many                      //days user hasn't started app                     // number of updates display badge.                     int days = (int) ((system.currenttimemillis() - user.getlastupdate()) / 1000 / 60 / 60 / 24);                     payloadbuilder payloadbuilder = apns.newpayload();                     payloadbuilder = payloadbuilder.badge(days).alertbody("some message want send here");                     // check if message long (it won't sent if is)                      //and trim if is.                     if (payloadbuilder.istoolong()) {                         payloadbuilder = payloadbuilder.shrinkbody();                     }                     string payload = payloadbuilder.build();                     string token = user.gettoken();                     service.push(token, payload);                 } catch (exception ex) {                     // logging stuff                 }             }         } catch (exception ex) {             // more logging         } {             // check if service successfull initialized , stop here, if             if (service != null) {                 service.stop();             }          }     } 

and use com.notnoop.apns library send apns push notification.

you have delete devices list no longer , use following codes

map<string, date> inactivedevices = service.getinactivedevices();             (string devicetoken : inactivedevices.keyset()) {                // delete table             } 

here service object of apnsservice.

apnsservice service; 

Comments

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -