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
package cn.flightfeather.thirdapp.util.push
 
import android.content.Context
import android.util.Log
import com.alibaba.sdk.android.push.MessageReceiver
import com.alibaba.sdk.android.push.notification.CPushMessage
 
/**
 * 阿里云推送消息接收
 * @author riku
 * Date: 2019/12/26
 */
class MyMessageReceiver : MessageReceiver() {
    companion object {
        // 消息接收部分的LOG_TAG
        const val REC_TAG = "MyMessageReceiver"
    }
 
    override fun onNotification(
        context: Context?,
        title: String?,
        summary: String?,
        extraMap: Map<String, String>?
    ) {
        // TODO 处理推送通知
        Log.e(REC_TAG, "Receive notification, title: $title, summary: $summary, extraMap: $extraMap")
    }
 
    override fun onMessage(context: Context?, cPushMessage: CPushMessage) {
        Log.e(
            REC_TAG,
            "onMessage, messageId: " + cPushMessage.messageId + ", title: " + cPushMessage.title + ", content:" + cPushMessage.content
        )
 
        
    }
 
    override fun onNotificationOpened(context: Context?, title: String?, summary: String?, extraMap: String?) {
        Log.e(REC_TAG, "onNotificationOpened, title: $title, summary: $summary, extraMap:$extraMap")
    }
 
    override fun onNotificationClickedWithNoAction(
        context: Context?,
        title: String?,
        summary: String?,
        extraMap: String?
    ) {
        Log.e(
            REC_TAG,
            "onNotificationClickedWithNoAction, title: $title, summary: $summary, extraMap:$extraMap"
        )
    }
 
    override fun onNotificationReceivedInApp(
        context: Context?,
        title: String?,
        summary: String?,
        extraMap: Map<String, String>?,
        openType: Int,
        openActivity: String?,
        openUrl: String?
    ) {
        Log.e(
            REC_TAG,
            "onNotificationReceivedInApp, title: $title, summary: $summary, extraMap:$extraMap, openType:$openType, openActivity:$openActivity, openUrl:$openUrl"
        )
    }
 
    override fun onNotificationRemoved(context: Context?, messageId: String?) {
        Log.e(REC_TAG, "onNotificationRemoved")
    }
}