iphone 推送通知 服务器端java 实现
2012-06-10 14:11
399 查看
jar包下载以及代码的下载
http://download.csdn.net/detail/aibang/4288787
package com.apns.comm.util;
import javapns.back.PushNotificationManager;
import javapns.back.SSLConnectionHelper;
import javapns.data.Device;
import javapns.data.PayLoad;
public class MainApnsSend
{
public static void main(String[] args) throws Exception
{
sendCommerceAPNS();
}
public static void sendCommerceAPNS()
{
try
{
String deviceToken = "c60b33344dc727bff137bbddb0216fcce9579c48de4873845d094f0e47134275";//iphone手机获取的token
PayLoad payLoad = new PayLoad();
payLoad.addAlert("我的push测试");//push的内容
payLoad.addBadge(100);//图标小红圈的数值
//payLoad.addSound("default");//铃音
PushNotificationManager pushManager = PushNotificationManager.getInstance();
pushManager.addDevice("iPhone", deviceToken);
//Connect to APNs
/***********************************************************************************************************
* 测试的服务器地址:gateway.sandbox.push.apple.com /端口2195 产品推送服务器地址:gateway.push.apple.com / 2195
**********************************************************************************************************/
String host = "gateway.sandbox.push.apple.com";
int port = 2195;
String certificatePath = "E:/ruixinWorkspace/apns/apnsFile/TianGouCommerceAPNSCertificates.p12";//导出的证书
String certificatePassword = "123456";//此处注意导出的证书密码不能为空因为空密码会报错
pushManager.initializeConnection(host, port, certificatePath, certificatePassword, SSLConnectionHelper.KEYSTORE_TYPE_PKCS12);
//Send Push
Device client = pushManager.getDevice("iPhone");
pushManager.sendNotification(client, payLoad);
pushManager.stopConnection();
pushManager.removeDevice("iPhone");
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
http://download.csdn.net/detail/aibang/4288787
package com.apns.comm.util;
import javapns.back.PushNotificationManager;
import javapns.back.SSLConnectionHelper;
import javapns.data.Device;
import javapns.data.PayLoad;
public class MainApnsSend
{
public static void main(String[] args) throws Exception
{
sendCommerceAPNS();
}
public static void sendCommerceAPNS()
{
try
{
String deviceToken = "c60b33344dc727bff137bbddb0216fcce9579c48de4873845d094f0e47134275";//iphone手机获取的token
PayLoad payLoad = new PayLoad();
payLoad.addAlert("我的push测试");//push的内容
payLoad.addBadge(100);//图标小红圈的数值
//payLoad.addSound("default");//铃音
PushNotificationManager pushManager = PushNotificationManager.getInstance();
pushManager.addDevice("iPhone", deviceToken);
//Connect to APNs
/***********************************************************************************************************
* 测试的服务器地址:gateway.sandbox.push.apple.com /端口2195 产品推送服务器地址:gateway.push.apple.com / 2195
**********************************************************************************************************/
String host = "gateway.sandbox.push.apple.com";
int port = 2195;
String certificatePath = "E:/ruixinWorkspace/apns/apnsFile/TianGouCommerceAPNSCertificates.p12";//导出的证书
String certificatePassword = "123456";//此处注意导出的证书密码不能为空因为空密码会报错
pushManager.initializeConnection(host, port, certificatePath, certificatePassword, SSLConnectionHelper.KEYSTORE_TYPE_PKCS12);
//Send Push
Device client = pushManager.getDevice("iPhone");
pushManager.sendNotification(client, payLoad);
pushManager.stopConnection();
pushManager.removeDevice("iPhone");
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
相关文章推荐
- java实现推送通知给iphone
- iphone 推送通知 java 实现
- iphone 推送通知 java 实现
- iphone 推送通知 java 实现
- iphone 推送通知 java 实现
- iphone 推送通知 java 实现
- ZPush--基于netty4实现的苹果通知推送服务(APNs)Java客户端
- iPhone应用中APNS推送通知流程代码实现案例
- iPhone应用中APNS推送通知流程代码实现案例
- 推送通知iOS客户端编写实现及推送服务器端编写
- iphone实现本地通知(类似推送)
- 推送通知iOS客户端编写实现及推送服务器端编写
- 推送通知iOS客户端编写实现及推送服务器端编写
- iPhone应用中APNS推送通知流程代码实现案例
- iPhone开发推送通知流程实现
- 推送通知iOS客户端编写实现及推送服务器端编写
- java给iphone应用实现推送
- ZPush--基于netty4实现的苹果通知推送服务(APNs)Javaclient
- 推送通知iOS客户端编写实现及推送服务器端编写
- 推送通知iOS客户端编写实现及推送服务器端编写