twmauth sdk 使用方法

100 阅读1分钟

使用方法

Version配置

 defaultConfig {
        applicationId "com.example.twmauthDemo"
        minSdk 24
        targetSdk 32
        versionCode 1
        versionName "1.0"
        
        // 你的其他配置:
        // ...

    }

  dependencies {
    implementation project(path: ':twmauth')
  }

注册SDK

在MyApplication中,注册SDK:

import com.twm.tamauth.sdk.MyOpenSDK

class MyApplication : Application() {
    @SuppressLint("NewApi")
    override fun onCreate() {
        super.onCreate()
        initSDK()
    }

    /**
     * 初始化
     */
    @RequiresApi(Build.VERSION_CODES.O)
    fun initSDK() {
        MyOpenSDK.init(this)
    }

    companion object {

    }
}

调用上号授权

/**
 * Initialize onClick listeners for the buttons.
 */
private fun setupListeners() {
    binding.tvOpenShowFloat.setOnClickListener {
        /**<must start service first>*/
        MyOpenSDK.startAuth(this, "com.tencent.tmgp.sgame", userToken = "uwc3av7ul3vk0d9dtxv0udyp35lgdnzpr7ama6oqfc2nreiwsmoz4l1lqs0dhtj1", orderId = "2600")
    }
}