package com.iscs.bozzys.service

import android.content.Context
import com.alibaba.sdk.android.push.AliyunMessageIntentService
import com.alibaba.sdk.android.push.notification.CPushMessage
import com.iscs.bozzys.event.RefreshEvent
import com.iscs.bozzys.event.RefreshEventBus
import com.iscs.bozzys.utils.LogUtil

class AliPushService : AliyunMessageIntentService() {

    override fun onNotification(p0: Context?, p1: String?, p2: String?, p3: Map<String?, String?>?) {

    }

    override fun onMessage(p0: Context?, p1: CPushMessage?) {

    }

    override fun onNotificationOpened(ctx: Context?, title: String?, content: String?, params: String?) {
        LogUtil.i("MPS", "AliPushService -> onNotificationOpened $title $content $params")
        // 这里执行跳转到消息详情页面
        RefreshEventBus.onRefreshData(RefreshEvent.Notification)
    }

    override fun onNotificationClickedWithNoAction(p0: Context?, p1: String?, p2: String?, p3: String?) {
        LogUtil.i("MPS", "AliPushService -> onNotificationClickedWithNoAction")
        // 没有配置行为，这里执行跳转到消息详情页面
        RefreshEventBus.onRefreshData(RefreshEvent.Notification)
    }

    override fun onNotificationRemoved(p0: Context?, p1: String?) {

    }

    override fun onNotificationReceivedInApp(
        p0: Context?,
        p1: String?,
        p2: String?,
        p3: Map<String?, String?>?,
        p4: Int,
        p5: String?,
        p6: String?
    ) {

    }
}