美文网首页Android开发学习
Android-极光推送集成流程

Android-极光推送集成流程

作者: 一份饥 | 来源:发表于2017-03-21 17:02 被阅读349次

一、添加依赖

//极光推送
compile 'cn.jiguang.sdk:jpush:3.0.0'
compile 'cn.jiguang.sdk:jcore:1.0.0'

二、配置参数

//defaultConfig{
    JPUSH_PKGNAME : applicationId,
    JPUSH_APPKEY : "501e0f31b4e163e1", //JPush上注册的包名对应的appkey.
    JPUSH_CHANNEL : "developer-default", //暂时填写默认值即可.   
}

三、配置清单文件

1.添加必要的权限
2.注册广播接受者
    <!-- User defined. 用户自定义的广播接收器 -->
    <receiver
        android:name=".bookstore.receiver.PushReceiver"
        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="com.laikan.reader"/>
        </intent-filter>
    </receiver>

四、创建Receiver类

    public class PushReceiver extends BroadcastReceiver{
    private static final String TAG = "PushReceiver";

    private NotificationManager nm;
    @Override
    public void onReceive(Context context, Intent intent) {
        Log.d("lyt","receiver called");
        if (null == nm) {
            nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        }

        Bundle bundle = intent.getExtras();
    //     Log.d(TAG, "onReceive - " + intent.getAction() + ", extras: " + AndroidUtil.printBundle(bundle));

        if (JPushInterface.ACTION_REGISTRATION_ID.equals(intent.getAction())) {
            Log.d(TAG, "JPush用户注册成功");

        } else if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(intent.getAction())) {
            Log.d(TAG, "接受到推送下来的自定义消息");

        } else if (JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals(intent.getAction())) {
            Log.d(TAG, "接受到推送下来的通知");

            receivingNotification(context,bundle);

        } else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) {
            Log.d(TAG, "用户点击打开了通知");

    //      openNotification(context,bundle);
            openLaikan(context);

        } else {
            Log.d(TAG, "Unhandled intent - " + intent.getAction());
        }
    }

五、在Application中初始化Jpush

JPushInterface.init(this);
JPushInterface.setDebugMode(true);  // 极光推送 设置开启日志,发布时请关闭日志

相关文章

  • Android-极光推送集成流程

    一、添加依赖 二、配置参数 三、配置清单文件 四、创建Receiver类 五、在Application中初始化Jpush

  • 实现iOS收到推送消息后跳到指定的页面

    ########这里离线推送用的极光推送,集成推送这里就不做说明了,根据极光官方文档集成基本没有什么问题。 ###...

  • 极光推送集成开发

    1.极光推送集成与设置 极光推送地址①注册极光推送账号。②在应用管理内按照步骤创建APP。③找到“文档——iOS—...

  • iOS-iOS10极光推送的使用

    1、首先先配置好推送证书,传到极光。极光推送->iOS证书设置指南极光推送->iOS SDK集成指南(XCode8...

  • iOS-极光推送的使用

    1、首先先配置好推送证书,传到极光。极光推送->iOS证书设置指南极光推送->iOS SDK集成指南(XCode8...

  • Android-极光推送

    今日没有工作项目,闲来无事,把极光推送这个再整理下,画了一个上午重新研究下,特意记录下来 准备 1.到极光推送官方...

  • "_OBJC_CLASS_$_JPUSHService

    在集成极光推送的时候运行报错:

  • Android 推送跳转逻辑

    本文例子已极光推送为例,极光推送集成连接如下:https://docs.jiguang.cn/jpush/clie...

  • 极光后台推送响铃

    前言: 本教程不讨论极光推送的集成,请自行百度如何集成极光推送本教程适用于需要支持ios10以下的后台推送响铃对于...

  • 极光推送 集成 使用 Token Authentication

    iOS 设备集成推送,以前需要集成开发证书和生产证书,比较麻烦,现在极光推送集成了Token Authentica...

网友评论

    本文标题:Android-极光推送集成流程

    本文链接:https://www.haomeiwen.com/subject/xpugnttx.html