最近闲来无事就把个推研究了一下,发现个推的SDK版本已经更新到2.9.5.0了,而且跟以前的版本相比感觉变化实在是太大了。
以前的版本在配置清单里面的配置为

<!-- 配置第三方Receiver--><receiver
            android:name="cn.com.zhaoshuikan.bdhospital.PushReceiver"android:exported="false" ><intent-filter><action android:name="com.igexin.sdk.action.bDEt739zAr9OJJfcUu0hL7" /></intent-filter></receiver> <!-- 配置SDK核心服务  --><service
            android:name="com.igexin.sdk.PushService"android:exported="true"android:label="NotificationCenter"android:process=":pushservice" ></service><receiver android:name="com.igexin.sdk.PushReceiver" ><intent-filter><action android:name="android.intent.action.BOOT_COMPLETED" /><action android:name="android.net.conn.CONNECTIVITY_CHANGE" /><action android:name="android.intent.action.USER_PRESENT" /><action android:name="com.igexin.sdk.action.refreshls" />   <!-- 以下四项为可选的action声明,可大大提高service存活率和消息到达速度  --><action android:name="android.intent.action.MEDIA_MOUNTED" /><action android:name="android.intent.action.ACTION_POWER_CONNECTED" /><action android:name="android.intent.action.ACTION_POWER_DISCONNECTED" /></intent-filter></receiver><receiver
            android:name="com.igexin.sdk.PushManagerReceiver"android:exported="false" ><intent-filter><action android:name="com.igexin.sdk.action.pushmanager" /></intent-filter></receiver><provider android:name="com.igexin.download.DownloadProvider"android:exported="true"android:authorities="downloads.cn.com.zhaoshuikan.bdhospital"android:process=":pushservice" /><service
            android:name="com.igexin.download.DownloadService"android:process=":pushservice" /><receiver android:name="com.igexin.download.DownloadReceiver" ><intent-filter><action android:name="android.net.conn.CONNECTIVITY_CHANGE" /></intent-filter></receiver><receiver
            android:name="com.igexin.getuiext.service.PayloadReceiver"android:exported="false" ><intent-filter><!-- 这个com.igexin.sdk.action.7fjUl2Z3LH6xYy7NQK4ni4固定,不能修改--><action android:name="com.igexin.sdk.action.7fjUl2Z3LH6xYy7NQK4ni4" /> <!-- android:name="com.igexin.sdk.action.第三方的appId" --><action android:name="com.igexin.sdk.action.bDEt739zAr9OJJfcUu0hL7" /></intent-filter></receiver><service
            android:name="com.igexin.getuiext.service.GetuiExtService"android:process=":pushservice" /><service android:name="cn.com.zhaoshuikan.bdhospital.utils.downloadupdate.UpdateDownloadService"></service>

而且以前的接收推送的是继承自BroadcastReceiver的

public class PushReceiver extends BroadcastReceiver {/** Notification构造器 */NotificationCompat.Builder mBuilder;private Context context;private NotificationManager mNotificationManager;private Notification mNotification = null; // 通知public static final int NOTIFICATION_ID = 200; // 通知唯一id/*** 应用未启动, 个推 service已经被唤醒,保存在该时间段内离线消息*/private Map<String, String> payloadData = new HashMap<String, String>();@Overridepublic void onReceive(Context context, Intent intent) {Bundle bundle = intent.getExtras();switch (bundle.getInt(PushConsts.CMD_ACTION)) {case PushConsts.GET_MSG_DATA:// 获取透传数据// String appid = bundle.getString("appid");byte[] payload = bundle.getByteArray("payload");String taskid = bundle.getString("taskid");String messageid = bundle.getString("messageid");// smartPush第三方回执调用接口,actionid范围为90000-90999,可根据业务场景执行boolean result = PushManager.getInstance().sendFeedbackMessage(context, taskid, messageid, 90001);System.out.println("第三方回执接口调用" + (result ? "成功" : "失败"));if (payload != null) {String data = new String(payload);}break;case PushConsts.GET_CLIENTID:// 获取ClientID(CID)// 第三方应用需要将CID上传到第三方服务器,并且将当前用户帐号和CID进行关联,以便日后通过用户帐号查找CID进行消息推送String cid = bundle.getString("clientid");System.out.println(">>>>>>>>>cid:" + cid);break;case PushConsts.THIRDPART_FEEDBACK:break;default:break;}}

相信用过个推的对这些代码并不陌生,但是今天当我再去看的时候,发现发生的变化实在是太大了。之前的推送的消息提醒是需要自己去写的,而且当有推送的时候信息payload的值是很快就能获取到的,而且就是我们在官网测试平台输入的一些标题和内容,但是现在的变化是如果你只设置标题和内容不去设置透传的话,你获取到的payload永远只会是null。这些信息应该如何去配置呢?

之前我们只输入标题和内容应该是可以获取到payload的值的,但是现在我们还要去点击高级设置


这样设置以后我们才能获取到payload的值,而且payload的值就是我们设置的透传信息的内容,是一个json串。
之前的

PushManager.getInstance().initialize(this.getApplicationContext());

这行代码现在新版本多了一个参数,而且还需要注册服务现在已经变成了

 PushManager.getInstance().initialize(this.getApplicationContext(),DemoPushService.class);PushManager.getInstance().registerPushIntentService(this.getApplicationContext(), PushReceiver.class);
package com.lyxrobert.pushinfo;import android.content.Context;
import android.os.Message;
import android.util.Log;import com.igexin.sdk.GTIntentService;
import com.igexin.sdk.PushManager;
import com.igexin.sdk.message.GTCmdMessage;
import com.igexin.sdk.message.GTTransmitMessage;public class PushReceiver extends GTIntentService {@Overridepublic void onReceiveServicePid(Context context, int pid) {}@Overridepublic void onReceiveClientId(Context context, String clientid) {sendMessage(clientid, 1);}@Overridepublic void onReceiveMessageData(Context context, GTTransmitMessage msg) {String appid = msg.getAppid();String taskid = msg.getTaskId();String messageid = msg.getMessageId();byte[] payload = msg.getPayload();String pkg = msg.getPkgName();String cid = msg.getClientId();boolean result = PushManager.getInstance().sendFeedbackMessage(context, taskid, messageid, 90001);Log.d(TAG, "call sendFeedbackMessage = " + (result ? "success" : "failed"));if (payload == null) {} else {String data = new String(payload);sendMessage(data, 0);System.out.println("data-------->"+data);}}@Overridepublic void onReceiveOnlineState(Context context, boolean online) {}@Overridepublic void onReceiveCommandResult(Context context, GTCmdMessage cmdMessage) {}private void sendMessage(String data, int what) {Message msg = Message.obtain();msg.what = what;msg.obj = data;PushApplication.sendMessage(msg);}
}

配置清单里面的信息

 <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"package="com.lyxrobert.pushinfo"><uses-permission android:name="android.permission.INTERNET"/><uses-permission android:name="android.permission.READ_PHONE_STATE"/><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/><uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/><uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/><uses-permission android:name="android.permission.WAKE_LOCK"/><uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/><uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/><uses-permission android:name="android.permission.VIBRATE"/><uses-permission android:name="android.permission.GET_TASKS"/><!-- 支持iBeancon 需要蓝牙权限 --><uses-permission android:name="android.permission.BLUETOOTH"/><uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/><!-- 支持个推3.0 电子围栏功能 --><uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/><uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/><!-- 浮动通知权限 --><uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/><uses-permission android:name="getui.permission.GetuiService.com.lyxrobert.pushinfo"/><permission
        android:name="getui.permission.GetuiService.com.lyxrobert.pushinfo"android:protectionLevel="normal"/><application
        android:name="com.lyxrobert.pushinfo.PushApplication"android:allowBackup="true"android:icon="@drawable/photo"android:theme="@style/AppTheme"android:label="@string/app_name" ><!-- 第三方应用配置 --><meta-data
            android:name="PUSH_APPID"android:value="JChyfqDCbvAJf5NMLEXr1A"/><meta-data
            android:name="PUSH_APPKEY"android:value="h0uZ4AMTLj7WHg0z6GiNt7"/><meta-data
            android:name="PUSH_APPSECRET"android:value="Bz5sUvrG546b1B7uEMbVo2"/><activity android:name="com.lyxrobert.pushinfo.MainActivity"><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" /></intent-filter></activity><service android:name=".PushReceiver"/><!-- 配置SDK核心服务 --><service
            android:name="com.igexin.sdk.PushService"android:exported="true"android:label="NotificationCenter"android:process=":pushservice"><intent-filter><action android:name="com.igexin.sdk.action.service.message"/></intent-filter></service><receiver
            android:name="com.igexin.sdk.PushReceiver"><intent-filter><action android:name="android.intent.action.BOOT_COMPLETED"/><action android:name="android.net.conn.CONNECTIVITY_CHANGE"/><action android:name="android.intent.action.USER_PRESENT"/><action android:name="com.igexin.sdk.action.refreshls"/><action android:name="android.intent.action.MEDIA_MOUNTED"/><action android:name="android.intent.action.ACTION_POWER_CONNECTED"/><action android:name="android.intent.action.ACTION_POWER_DISCONNECTED"/></intent-filter></receiver><activity
            android:name="com.igexin.sdk.PushActivity"android:excludeFromRecents="true"android:exported="false"android:process=":pushservice"android:taskAffinity="com.igexin.sdk.PushActivityTask"android:theme="@android:style/Theme.Translucent.NoTitleBar"/><activity
            android:name="com.igexin.sdk.GActivity"android:excludeFromRecents="true"android:exported="true"android:process=":pushservice"android:taskAffinity="com.igexin.sdk.PushActivityTask"android:theme="@android:style/Theme.Translucent.NoTitleBar"/><service
            android:name="com.igexin.download.DownloadService"android:process=":pushservice"/><receiver
            android:name="com.igexin.download.DownloadReceiver"><intent-filter><action android:name="android.net.conn.CONNECTIVITY_CHANGE"/></intent-filter></receiver><provider
            android:name="com.igexin.download.DownloadProvider"android:authorities="downloads.com.getui.demo"android:exported="true"android:process=":pushservice"/><!-- 用户自定义服务继承自GTIntentService,作为SDK与APP桥梁服务,用来接收各种消息和命令回复--><service android:name=".PushReceiver"/><!-- 用户自定义服务名 --><service
            android:name=".DemoPushService"android:exported="true"android:label="PushService"android:process=":pushservice"></service></application></manifest>

之前的一下几个在配置清单里面不再需要了,因为以前的配置需要两个jar包

现在只要一个jar包就可以可以了,但是还要注意的是,

com.igexin.sdk.PushServiceUser
com.igexin.sdk.PushManagerReceiver
com.igexin.getuiext.activity.GetuiExtActivity
com.igexin.getuiext.service.PayloadReceiver
com.igexin.getuiext.service.GetuiExtService

还有就是

如果想要混淆代码还要做如下配置

基本设置完毕了,来看下成功打印信息


如有疑问请留言交流

Android 推送-个推相关推荐

  1. 极光推送——App推送

    极光推送:主要用于APP实时获取最新消息.本文主要描述如何使用极光提供的SDK进行推送. 极光推送中主要需要配置的参数如下: 推送平台:JPush 当前支持 Android, iOS, Windows ...

  2. 移动应用消息推送及推送原理

    消息推送 消息通知分本地通知和远程推送通知. 本文是记录React Native使用aws push notifications推送及相关配置及遇到的相关问题.在twilio和aws中选择使用aws的 ...

  3. php主动推送弹幕_源起网-织梦发布文档主动百度推送熊掌推送批量推送

    源起网-织梦发布文档主动百度推送熊掌推送批量推送 环境要求 PHP必须开启了curl扩展 百度主动推送(实时)可以缩短百度爬虫发现您站点新链接的时间,使新发布的页面可以在第一时间被百度收录 织梦程序我 ...

  4. 【转】推送消息推送机制

    原文链接:推送消息&推送机制 - 知乎 消息推送(push)用一句话解释就是:服务端向客户端发送了一条消息,我们在通知栏.锁屏通知.微信消息等等之类的都是消息推送. 1/推送类型有哪些? 消息 ...

  5. iOS远程消息推送(信鸽推送平台)

    首先进入信鸽推送平台网站,登录, 下载iOS SDK文档,解压文件,将demo文件夹下面的sdk文件拖入工程中. 在苹果开发者网站,创建自己的APP id ,推送证书,描述文件.  详情见推送平台的文 ...

  6. android推送接口,推送API

    推送API 简述 个推为开发者提供了如下3种消息推送方式: toSingle :简称"单推",指向单个用户推送消息 toList:简称"批量推",指向制定的一批 ...

  7. android推送如何推送不在线设备,推送系统从0到1(四):消息如何到达用户设备...

    本篇主要为大家揭秘推送消息是如何传输的,如何到达用户设备上的,在不同的设备上会如何展示. 在上一篇文章中,我们可以知道在建立推送任务的过程中,需要考虑带有自滤功能的用户池构建.筛选有效用户.设置推送内 ...

  8. android设备报警推送,Firebase推送通知未送达所有android设备

    我正在使用PHP向特定的Android应用程序用户发送firebase推送通知. function enviar_push($token,$titulo,$subtitulo){ define( 'A ...

  9. Android 阿里推送正常推送以及辅助通道走过的坑,字节跳动+阿里+华为+腾讯等大厂Android面试题

    dependencies { ...... compile 'com.aliyun.ams:third_vivopush:2.9.0.1' } 在AndroidManifest文件中添加如下配置: & ...

最新文章

  1. 原生ajax的post操作
  2. Jmeter 可视化监控
  3. 裴健当选加拿大皇家学会院士:曾任华为首席科学家、京东副总裁,学术引用超8万次...
  4. 全球最快学术超算Frontera,也用英特尔至强可扩展处理器
  5. 高通平台Tag精确寻找进阶教程
  6. SQL语言之多表查询(oracle)
  7. matlab您的安装可能需要执行其他配置步骤_手把手超详细介绍MATLAB+RoadRunner+Unreal Engine自动驾驶联合仿真...
  8. 应该在什么时候使用Hadoop
  9. 【软件使用】Windows下的Objective-C集成开发环境搭建(IDE)
  10. 常用的函数式接口_Function接口_默认方法andThen
  11. pythonuiautomator2教程_UIAutomator2 + Python 入门使用总结
  12. java bloomfilter_爬虫技术之——bloom filter(含java代码)
  13. 浙江省2018年高等数学竞赛工科类试题
  14. idea下载与安装 0913
  15. json在java中的使用_有效地使用JSON流(在Java中)
  16. mysql的时间在cmd的输入格式_获取“System.FormatException:输入字符串的格式不正确。”在日期时间对象插入到MySql数据库...
  17. UITableView性能优化 - 中级篇
  18. Jetson TX2入门学习之Ubuntu默认密码
  19. php+对象和数组装备_php对象和数组有什么区别
  20. QT与游戏手柄测试(数据与UI相连,ui界面作出反应)

热门文章

  1. 2018安卓面试经历
  2. cdh 简介_CDH的介绍和部署
  3. 学校计算机有麦克风吗,一体机有麦克风功能吗
  4. 【UOJ#386】【UNR#3】鸽子固定器(贪心)
  5. Educational Codeforces Round 121 (Rated for Div. 2) unr场 A B C
  6. 基于 OSGi的企业级开发框架实践——开发框架的创建
  7. c++入门 有关《c++关键字》 《命名空间》《缺省参数》《函数重载》《引用》《内联函数》《outo关键字》
  8. 网络流:最大流,最小割 基本概念及算法
  9. 01-名词冠词(思维导图记录)
  10. MRR@K P@K R@K意义阐述与对比