版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/javaer_lee/article/details/53394962
public void sendIOSUnicast() throws Exception {
IOSUnicast unicast = new IOSUnicast(appkey,appMasterSecret);
// TODO Set your device token
unicast.setDeviceToken("你的设备token");
unicast.setAlert("IOS 单播测试");
unicast.setBadge( 0);
unicast.setSound( "default");
// TODO set 'production_mode' to 'true' if your app is under production mode
unicast.setTestMode();
// Set customized fields
unicast.setCustomizedField("test", "helloworld");
client.send(unicast);
}
如上代码是友盟的demo中提供的,IOS设备可以获取到本机的device token,传送到服务器中存储,每次想推送的时候直接调用上面的方法,在 setDeviceToken中设置为想要推送的设备的deviceToken 友盟会自动推送到该设备。