try {
//list是用户集合
//dev是要推动的用户的终端device_token(友盟的device_token不可定制不可自定义)
for (String dev : list) {
//实例化AndroidUnicast 类,传入参数appkey和appMasterSecret。参数在友盟控制台获取
AndroidUnicast unicast = new AndroidUnicast(appkey, appMasterSecret);
//设置要推送的终端device_token
unicast.setDeviceToken(dev);
//通知栏提示文字
unicast.setTicker("Android unicast ticker");
//通知栏提示文字
unicast.setTitle("友盟推送");
//设置android端展示通知时通知栏所用的图标,放在drawable目录下
unicast.setIcon("R.drawable.umeng_push_notification_default_small_icon");
unicast.setLargeIcon("R.drawable.[umeng_push_notification_default_small_icon]");
//设置通知内容
unicast.setText(msg);
unicast.goAppAfterOpen();
//设置通知方式为通知(NOTIFICATION改为MESSAGE时,终端不会再状态栏提示,需要手动在android端处理推送内容)
unicast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
unicast.setProductionMode();
//设置自定义参数
unicast.setExtraField("id","自定义参数"));
//发送至友盟服务器
client.send(unicast);
}
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage());
}