package com.laihua.pushtestproject

import android.app.Application
import android.content.Intent
import android.net.Uri
import android.util.Log
import com.laihua.push.PushManager
import com.laihua.push.platform.InitParam
import com.laihua.push.utils.LogUtils

/**
 * Author: pengjunjing
 * Date: 2021/5/18
 * Description:
 */
class MyApplication : Application() {
    private val TAG = "MyApplication"
    override fun onCreate() {
        super.onCreate()

        val intent = Intent(this, MainActivity::class.java)
        intent.setData(Uri.parse("vpushscheme://com.vivo.push.notifysdk/detail?"))
        intent.putExtra("key1", "xxx")
        val toUri = intent.toUri(Intent.URI_INTENT_SCHEME)
        Log.i(TAG, "onCreate: $toUri")


        PushManager.instance.initContext(this)
        //vivo的配置信息直接在manifest配置,华为的配置信息在agconnect-services.json文件
        val autoInitPushSdk = PushManager.instance.autoInitPushSdk(
            //OPPO APPID 30532383
            InitParam("220c8dc643ce4a709b116a0aa26e6bf4", "0305238c1c6949c38caa1fdd8070b4aa"),
            InitParam("2882303761519924093", "5121992433093"),
            InitParam("141361", "f3e78d580c7d46c295263b3dde94ca72"),
            { platform, it ->
                LogUtils.i("推送SDK初始化成功:$it")
                PushManager.instance.addTopic("test_topic")
                PushManager.instance.setAlias("test_alias")
            },
            { LogUtils.i("推送SDK初始化失败:${it.message}") }
        )
        LogUtils.i("所使用的推送渠道为${autoInitPushSdk}")

    }
}