集成Jpush

1.用Android Studio创建一个Demo

2.创建激光推送开发者账号,要创建极光推送开发者帐号,请访问极光推送官方网站https://www.jiguang.cn/push

3.在Portal上创建应用

使用注册账号登陆,进入极光控制台后,点击“创建应用”按钮。创建帐号进入极光推送后,首先显示的是创建应用的界面。填上你的应用程序的名称,以及 Android包名这二项就可以了。

4.手动集成,导入相关文件 http://docs.jiguang.cn/jpush/client/Android/android_guide/

注意:在Android studio中需要建立jni文件夹,在更名为jniLibs,把so文件导进去。

再复制res中的drawable-hdpi,layout,values文件中的资源导入到建立的工程对应的同名目录下

3.配置AndroidManifest.xml

3.1添加权限(注意改包名)

<permission android:name="您应用的包名.permission.JPUSH_MESSAGE"  android:protectionLevel="signature" /><uses-permission android:name="您应用的包名.permission.JPUSH_MESSAGE" /><uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" /><uses-permission android:name="android.permission.INTERNET" /><uses-permission android:name="android.permission.WAKE_LOCK" /><uses-permission android:name="android.permission.READ_PHONE_STATE" /><uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /><uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /><uses-permission android:name="android.permission.VIBRATE" /><uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" /><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /><uses-permission android:name="android.permission.WRITE_SETTINGS" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

3.2复制核心代码(执意更改包名以及appkey)

<!-- Required SDK 核心功能--><!-- 可配置android:process参数将PushService放在其他进程中 --><serviceandroid:name="cn.jpush.android.service.PushService"android:enabled="true"android:exported="false" ><intent-filter><action android:name="cn.jpush.android.intent.REGISTER" /><action android:name="cn.jpush.android.intent.REPORT" /><action android:name="cn.jpush.android.intent.PushService" /><action android:name="cn.jpush.android.intent.PUSH_TIME" /></intent-filter></service><!-- since 1.8.0 option 可选项。用于同一设备中不同应用的JPush服务相互拉起的功能。 --><!-- 若不启用该功能可删除该组件,将不拉起其他应用也不能被其他应用拉起 --><serviceandroid:name="cn.jpush.android.service.DaemonService"android:enabled="true"android:exported="true"><intent-filter ><action android:name="cn.jpush.android.intent.DaemonService" /><category android:name="您应用的包名"/></intent-filter></service><!-- Required SDK核心功能--><receiverandroid:name="cn.jpush.android.service.PushReceiver"android:enabled="true" ><intent-filter android:priority="1000"> <action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED_PROXY" /> <category android:name="您应用的包名"/> </intent-filter><intent-filter><action android:name="android.intent.action.USER_PRESENT" /><action android:name="android.net.conn.CONNECTIVITY_CHANGE" /></intent-filter><!-- Optional --><intent-filter><action android:name="android.intent.action.PACKAGE_ADDED" /><action android:name="android.intent.action.PACKAGE_REMOVED" /><data android:scheme="package" /></intent-filter></receiver><!-- Required SDK核心功能--><activityandroid:name="cn.jpush.android.ui.PushActivity"android:configChanges="orientation|keyboardHidden"android:theme="@android:style/Theme.NoTitleBar"android:exported="false" ><intent-filter><action android:name="cn.jpush.android.ui.PushActivity" /><category android:name="android.intent.category.DEFAULT" /><category android:name="您应用的包名" /></intent-filter></activity><!-- SDK核心功能--><activityandroid:name="cn.jpush.android.ui.PopWinActivity"android:configChanges="orientation|keyboardHidden"android:exported="false"android:theme="@style/MyDialogStyle"><intent-filter><category android:name="android.intent.category.DEFAULT" /><category android:name="您应用的包名" /></intent-filter></activity><!-- Required SDK核心功能--><serviceandroid:name="cn.jpush.android.service.DownloadService"android:enabled="true"android:exported="false" ></service><!-- Required SDK核心功能--><receiver android:name="cn.jpush.android.service.AlarmReceiver" /><!-- User defined. 用户自定义的广播接收器--><receiverandroid:name="您自己定义的Receiver"android:enabled="true"><intent-filter><!--Required 用户注册SDK的intent--><action android:name="cn.jpush.android.intent.REGISTRATION" /> <!--Required 用户接收SDK消息的intent--> <action android:name="cn.jpush.android.intent.MESSAGE_RECEIVED" /> <!--Required 用户接收SDK通知栏信息的intent--><action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED" /> <!--Required 用户打开自定义通知栏的intent--><action android:name="cn.jpush.android.intent.NOTIFICATION_OPENED" /> <!-- 接收网络变化 连接/断开 since 1.6.3 --><action android:name="cn.jpush.android.intent.CONNECTION" /><category android:name="您应用的包名" /></intent-filter></receiver><!-- Required. For publish channel feature --><!-- JPUSH_CHANNEL 是为了方便开发者统计APK分发渠道。--><!-- 例如: --><!-- 发到 Google Play 的APK可以设置为 google-play; --><!-- 发到其他市场的 APK 可以设置为 xxx-market。 --><!-- 目前这个渠道统计功能的报表还未开放。--><meta-data android:name="JPUSH_CHANNEL" android:value="developer-default"/><!-- Required. AppKey copied from Portal --><meta-data android:name="JPUSH_APPKEY" android:value="您应用的Appkey"/> 

4.创建自己的广播接收器MyReceiver

/*** 自定义接收器* <p>* 如果不定义这个 Receiver,则:* 1) 默认用户会打开主界面* 2) 接收不到自定义消息*/
public class MyReceiver extends BroadcastReceiver {private static final String TAG = "JPush";private List<String> list = new ArrayList<>();public void onReceive(Context context, Intent intent) {Bundle bundle = intent.getExtras();if (JPushInterface.ACTION_REGISTRATION_ID.equals(intent.getAction())) {String regId = bundle.getString(JPushInterface.EXTRA_REGISTRATION_ID);Log.d(TAG, "[MyReceiver] 接收Registration Id : " + regId);} else if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(intent.getAction())) {Log.d(TAG, "收到了自定义消息。消息内容是:" + bundle.getString(JPushInterface.EXTRA_MESSAGE));// 自定义消息不会展示在通知栏,完全要开发者写代码去处理
String content = bundle.getString(JPushInterface.EXTRA_MESSAGE);Toast.makeText(context, content, Toast.LENGTH_SHORT).show();} else if (JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals(intent.getAction())) {// 在这里可以做些统计,或者做些其他工作} else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) {String content = bundle.getString(JPushInterface.EXTRA_ALERT);
//此处,我们取出的是通知的内容。还可以取出别的信息,这个大家可自行处理//           在这里可以自己写代码去定义用户点击后的行为Intent i = new Intent(context, TestActivity.class); i.putExtra("content", content);i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);context.startActivity(i);} else {}}
}

5.集成Jpush Android SDK的混淆

在工程的混淆文件proguard.jar中添加以下配置

-dontoptimize
-dontpreverify
-dontwarn cn.jpush.**
-keep class cn.jpush.* { ; }
-dontwarn cn.jiguang.**
-keep class cn.jiguang.* { ; }

6.注册(最好在application中注册)

JPushInterface.init(this); 

这样,在极光推送控制台推送消息,程序就可以接收了。

转载于:https://www.cnblogs.com/chhom/p/6699579.html

Android 极光推送集成相关推荐

  1. 极光小课堂 | 极光推送集成解决方案

    1. 极光推送集成背景 最近在研究推送和长连接,调研了市场上的几家平台,综合考虑选择了极光推送.长连接保活一直是一个大问题,尤其是 Android 方面.在最近谷歌公司的几次更新之后,Android ...

  2. Android 极光推送

    Android 极光推送 效果图 极光推送步骤: 1.首先需要打开极光推送官网:点击打开链接 注册账号并登陆 2.在主页选择SDK下载(如果嫌麻烦可以参考下文中的jcenter 自动集成步骤) 3.在 ...

  3. Flutter极光推送集成小米厂商通道【教程】

    极光推送官方已经开发出Flutter版的插件,地址:https://pub.dev/packages/jpush_flutter 在Flutter项目里面的pubspec.yaml里面依赖极光推送:j ...

  4. android 极光推送测试,Android 3分钟带你集成极光推送

    话不多说 首先申请极光的账号,(官方地址:https://www.jiguang.cn) 1561710140829.png 登录完成之后,先看到这个地方 ,我个人比较喜欢用旧版本,这里点击旧版 15 ...

  5. Android华为推送踩坑,极光推送集成华为遇到的坑?

    一.前言: 首先极光推送对各个厂商通道对接是没有在开发者平台提供文档的,需要申请VIP资格后,极光才会提供对应对接文档. 1.极光普通集成 1.步骤1 图片.png 2.步骤2 图片.png 3.步骤 ...

  6. Android 极光推送SDK集成

    1.创建JPush后台应用 在极光推送的开发者平台创建应用 输入应用包名 在应用信息那里可以看到你的APPKey 点击推送设置,设置包名(这个包名会在你的工程中用到),然后保存即可 2.下载资源 从h ...

  7. Android极光推送厂商离线通道集成文档及flutter集成总结

    <极光推送厂商离线通道集成文档> flutter集成指南 1.Android端配置 gradle配置 //极光推送def jpushVersion = '4.4.0'implementat ...

  8. android 极光推送解绑,app集成极光推送笔记(angular js)

    出处:极光推送官方文档以及github上的文档 1.安装 一般使用cordova安装(其他安装方式详见文档),命令行输入: cordova plugin add jpush-phonegap-plug ...

  9. Android 极光推送华为厂商通道集成问题记录

    本人根据极光推送文档华为厂商通道集成指南集成华为厂商通道后,一直并未打印上面的成功集成华为厂商通道的标志,最后发现只在华为开发者平台创建项目及应用,但是没有开通项目推送服务权限,也是被自己蠢哭了,在华 ...

  10. Android 极光推送 自定义通知铃声

    公司使用的推送功能使用的是极光推送,对于普通的通知,极光推送API自动集成了声音的提示,但是对于一些特殊的情况,我们就需要自定义声音提示. 有点坑的是极光并没有提供设置自定通知铃声的接口,所以只能自己 ...

最新文章

  1. java语言文本挖掘 分词_文本挖掘分词mapreduce化
  2. php mysql 分类_php+mysql实现无限分类实例详解
  3. textarea 换行_textarea自动换行方法总结
  4. 【caffe-windows】Linux至Windows平台的caffe移植
  5. 用python画树_Python+Turtle动态绘制一棵树实例分享
  6. 嵌入式数据库 HSQLDB
  7. linux nslcd服务,CentOS 6通过ldap集成AD域账号(nslcd方式)
  8. 深圳大学二本计算机软件,深圳大学是几本(深圳大学是一本还是二本)
  9. 7.25 8figting!
  10. 大三下,第一次前端面试经历
  11. 基于Office Visio 2010 图表绘制
  12. 机器学习--逐步回归算法,线性回归的特征选择算法
  13. 学习记录-FDD大规模MIMO系统的稀疏信道估计技术研究
  14. 数据库四种范式和部分依赖,完全依赖,传递依赖
  15. linux 内存取证_内存取证工具volatility
  16. IO_CELL里的slew rate control
  17. 2021-2027全球与中国镀铬钢管市场现状及未来发展趋势
  18. 程序员如何预防颈椎病?
  19. F5 GTM DNS 知识点和实验 3 -加速dns解析
  20. 计算机玩电脑游戏,玩电脑游戏250字

热门文章

  1. HashSet中add的执行过程
  2. 公众号文章发送pdf文件 pdf文件如何变成导出图片
  3. Fisco bcos 在多机器上搭建多个节点的区块链网络 教程
  4. 微信小程序云开发教程-JavaScript入门(2)-变量定义
  5. python 递归目录和文件 修改主组_python下递归遍历目录和文件的方法介绍
  6. 遵守java编码规范
  7. html css菜鸟,CSS菜鸟教程阅读笔记
  8. vscode插件之常用插件
  9. 2.4.PHP7.1 狐教程-【PHP常量】
  10. Android 横竖屏切换问题