腾讯移动推送(信鸽)地址:https://xg.qq.com/
1.注册登录后进入应用管理创建应用
服务端需要用到APP ID和SECRET KEY 后面的是安卓接入用的
2.搭建项目 导入jar包,需要方法直接调用就好(我是手动添加本地 Jar 包哒
mvn install:install-file -Dfile=xxx.jar -DgroupId=xxx -DartifactId=xxx -Dversion=1.0.0 -Dpackaging=jar
)
com.github.xingePush
xinge
1.2.0-SNAPSHOT
3.测试
import com.alibaba.fastjson.JSONObject;
import com.tencent.xinge.XingeApp;
import com.tencent.xinge.bean.AudienceType;
import com.tencent.xinge.bean.Message;
import com.tencent.xinge.bean.MessageType;
import com.tencent.xinge.bean.Platform;
import com.tencent.xinge.push.app.PushAppRequest;
import java.util.ArrayList;
/**
* @description: 推送
* @create: 2018-10-25 15:29
**/
public class PushApp {
/**
* 消息推送(单推)
*/
public static void setPushApp() {
//消息推送(921080355f1a2>>>)
XingeApp xingeApp = new XingeApp("921080355f1a2", "08c84547f465c250def23566ddb341f1");
Message message=new Message();
message.setTitle("转账");
message.setContent(JSONObject.toJSONString(new Object));
//推送请求信息
PushAppRequest pushAppRequest=new PushAppRequest();
//消息体
pushAppRequest.setMessage(message);
//消息类型
pushAppRequest.setMessage_type(MessageType.message);
//推送目标
pushAppRequest.setAudience_type(AudienceType.account);
//推送平台
pushAppRequest.setPlatform(Platform.android);
//账号
ArrayList account_list = new ArrayList<>();
account_list.add(1);
//推送账号
pushAppRequest.setAccount_list(account_list);
//打印下推送数据
System.out.println(pushAppRequest.toString());
//推送结果 0是推送成功
System.out.println(xingeApp.pushApp(pushAppRequest.toString()));
}
}
注意:audience_type
、platform
、message_type
、message这几个参数是必须的
4.结果就是这样啦
{"message":{"content":"{}","android":null,"ios":null,"title":"测试","accept_time":null},"send_time":null,"multi_pkg":false,"loop_times":0,"loop_interval":0,"environment":"product","stat_tag":null,"seq":0,"tag_list":null,"account_list":["1111"],"account_type":0,"token_list":[],"push_id":null,"audience_type":"account","message_type":"message","platform":"android","expire_time":259200}
{"result":"[10113]","environment":"product","push_id":"347349094","err_msg":"帐号列表推送全部失败,请稍后重试!","ret_code":10303,"seq":0}
安卓端的账号没有登录会推送失败 只要登录就可以解决了
推送成功就是这样啦>>>>>>>>>>
{"result":"[0]","environment":"product","push_id":"347369096","err_msg":"","ret_code":0,"seq
更.......使用体验.......
感觉信鸽不完美的地方在于个别不同系统的手机需要指定系统推送如小米,华为,魅族,个人觉得太麻烦改用了极光推送,完全不需要重新为不同系统申请不同系统推送密钥。
https://blog.csdn.net/qq_42448324/article/details/85248529