package pxds.iqiv.ioih.gxph.rrax

import android.util.Log
import com.google.android.gms.tasks.OnCompleteListener
import com.google.android.gms.tasks.Task
import com.google.firebase.messaging.FirebaseMessaging
import com.test.basd.supercleanermax.R
import pxds.lmmd.zmwf.Khko.string
import pxds.lmmd.zmwf.Wspd

object Mqmn {

    private val TAG = R.string.ޢދޥޗކ_D.string()

    fun subscribeToTopic() {
        FirebaseMessaging.getInstance().subscribeToTopic(R.string.ޢޚޙޝޙ_D.string())
            .addOnCompleteListener { task: Task<Void?> ->
                if (task.isSuccessful) {
                    Wspd.event(R.string.ޤޟމޣޙ_D.string(), R.string.ޢޚޙޝޙ_D.string())

                } else {
                    Wspd.event(R.string.ދޜނދޤ_D.string())

                }
            }

    }

    fun unSubscribeToTopic() {
        FirebaseMessaging.getInstance().unsubscribeFromTopic(R.string.ޢޚޙޝޙ_D.string())
            .addOnCompleteListener { task: Task<Void?> ->
                if (task.isSuccessful) {

                } else {

                }
            }
    }

    fun getToken() {

        FirebaseMessaging.getInstance().token
            .addOnCompleteListener(OnCompleteListener { task ->
                if (!task.isSuccessful) {
                    Wspd.event(R.string.ބޔށޘޞ_D.string())
                    Log.w(TAG, R.string.ޑޒޖޓޝ_D.string(), task.exception)
                    return@OnCompleteListener
                }

                val token = task.result
                Wspd.event("fcm_token_suc", token)
                Log.d(TAG, R.string.ހޢއއޜ_D.string((token).toString()))
            })
    }
}