Java APNS开源库apns4j-1.0.1发布

Java APNS开源库apns4j-1.0.1发布

 

开源地址:https://github.com/teaey/apns4j

 

maven依赖:

 

[html]  view plain copy print ? 在CODE上查看代码片 派生到我的代码片
 
  1.         <dependency>  
  2.             <groupId>com.github.teaey</groupId>  
  3.             <artifactId>apns4j</artifactId>  
  4.             <version>1.0.1</version>  
  5.         </dependency>  



 

使用方法:使用方法

 

 

[java]  view plain copy print ? 在CODE上查看代码片 派生到我的代码片
 
  1. KeyStoreWraper keyStore = KeyStoreHelper.getKeyStoreWraper("XXXXXXXX.p12", keyStorePasswd);  
  2.   
  3. AppleNotificationServer appleNotificationServer = new AppleNotificationServer(AppleGateway.ENV_DEVELOPMENT, keyStore);  
  4.   
  5. SecurityConnectionFactory connectionFactory = new SecurityConnectionFactory(appleNotificationServer);  
  6.   
  7. SecurityConnection connection = connectionFactory.getSecurityConnection();  
  8.   
  9. NotifyPayload notifyPayload = new NotifyPayload();  
  10.   
  11. //notifyPayload.setAlert("TEST1");  
  12.   
  13. notifyPayload.setBadge(2);  
  14.   
  15. notifyPayload.setSound("default");  
  16.   
  17. notifyPayload.setAlertBody("Pushed By apns4j");  
  18.   
  19. notifyPayload.setAlertActionLocKey("Button Text");  
  20.   
  21. connection.writeAndFlush(deviceTokenString, notifyPayload);  
  22.   
  23. connection.close();  

 

 

有疑问请留言,或者联系本人:

[email protected]

微信:teaey_

猜你喜欢

转载自teaey.iteye.com/blog/2205530