mac
2024-01-02 d1ebb94e1a17b7c25d4fcf73d85345d92cc86b5c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package com.hdl.photovoltaic.jpush;
 
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
 
import com.google.gson.Gson;
import com.hdl.photovoltaic.config.ConstantManage;
import com.hdl.photovoltaic.other.HdlLogLogic;
import com.hdl.photovoltaic.ui.MyPowerStationActivity;
import com.hdl.photovoltaic.ui.StartActivity;
import com.hdl.photovoltaic.ui.bean.BUserInfo;
import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus;
 
import org.greenrobot.eventbus.EventBus;
 
import cn.jpush.android.api.CustomMessage;
import cn.jpush.android.api.JPushInterface;
import cn.jpush.android.api.NotificationMessage;
import cn.jpush.android.service.JPushMessageService;
 
/**
 * 接收极光推送消息
 */
public class JPushReceiverService extends JPushMessageService {
 
    /**
     * 自定义消息回调
     *
     * @param context       Context
     * @param customMessage 接收自定义消息内容
     */
    public void onMessage(Context context, CustomMessage customMessage) {
 
        HdlLogLogic.print("极光--->自定义消息回调--->" + new Gson().toJson(customMessage), true);
    }
 
    /**
     * 点击通知栏回调
     *
     * @param context Context
     * @param message 接收到的通知内容
     */
    public void onNotifyMessageOpened(Context context, NotificationMessage message) {
 
//        //点击后删除本地通知
//        JPushInterface.clearAllNotifications(context);
        HdlLogLogic.print("极光--->点击通知回调--->" + new Gson().toJson(message), true);
        Intent intent = new Intent(context, MyPowerStationActivity.class);
//        Bundle bundle = new Bundle();
//        bundle.putString(JPushInterface.EXTRA_NOTIFICATION_TITLE, message.notificationTitle);
//        bundle.putString(JPushInterface.EXTRA_ALERT, message.notificationContent);
//        intent.putExtras(bundle);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
        intent.putExtra("skip", "skip");//标识跳转
        context.startActivity(intent);
 
        BaseEventBus bus = new BaseEventBus();
        bus.setTopic(ConstantManage.message_function_push_post);
        EventBus.getDefault().postSticky(bus);
 
    }
 
    /**
     * 收到推送通知回调
     *
     * @param context Context
     * @param message 接收到的通知内容
     */
    public void onNotifyMessageArrived(Context context, NotificationMessage message) {
        HdlLogLogic.print("极光--->接收到的通知内容--->" + new Gson().toJson(message), true);
 
    }
 
    /**
     * 注册成功回调
     *
     * @param context        Context
     * @param registrationId 注册 id
     */
    public void onRegister(Context context, String registrationId) {
        HdlLogLogic.print("极光--->注册成功回调Id--->" + registrationId, true);
    }
 
    /**
     * 长连接状态回调
     *
     * @param context     Context。
     * @param isConnected 长连接状态
     */
    public void onConnected(Context context, boolean isConnected) {
        HdlLogLogic.print("极光--->长连接状态回调--->" + isConnected, true);
    }
 
}