package com.gh.gamecenter.jg.push.provider

import android.content.Context
import com.gh.gamecenter.core.provider.IPushProvider
import com.gh.gamecenter.jg.push.HaloApp
import com.gh.gamecenter.jg.push.JPushHelper
import com.lightgame.utils.Utils
import io.reactivex.Single

/**
 * 极光推送服务提供者类
 */
@com.therouter.inject.ServiceProvider
class JGPushProviderImpl : IPushProvider {
    override fun initialize(applicationContext: Context) {
        Utils.log("JGPushProviderImpl", "初始化推送")
    }

    override fun register(applicationContext: Context): Single<String> {
        JPushHelper.init(applicationContext)
        return Single.just("")
    }

    override fun bindAccount(account: String): Single<String> {
        Utils.log("JGPushProviderImpl", "绑定账号: $account")
        return Single.just("")
    }

    override fun bindAlias(alias: String): Single<String> {
        Utils.log("JGPushProviderImpl", "绑定别名: $alias")
        return Single.just("")
    }

    override fun unbindAlias(alias: String): Single<String> {
        Utils.log("JGPushProviderImpl", "解绑别名: $alias")
        return Single.just("")
    }

    override fun bindChannel(channel: String): Single<String> {
        JPushHelper.setChannel(HaloApp.getInstance().applicationContext, channel)
        return Single.just("")
    }

    override fun getRegistrationId(context: Context): String {
        return JPushHelper.getRegistrationId(context)
    }

    override fun cleanBadgeNumber(applicationContext: Context) {
        JPushHelper.cleanBadgeNumber(applicationContext)
    }

    override fun setOnPushOpenedCallback(callback: (String, String, String, String, String) -> Unit) {
        JPushHelper.onPushOpenedCallback = callback
    }
}