package expo.modules.nekotest import expo.modules.kotlin.modules.Module import expo.modules.kotlin.modules.ModuleDefinition import android.util.Log import expo.modules.nekotest.Retrofit.NKRetrofit import expo.modules.nekotest.Retrofit.NKService import okhttp3.ResponseBody import retrofit2.Call import retrofit2.Callback import retrofit2.Response fun getDApps() { val accessToken: String = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ3YWxsZXRfaWQiOiI2OTVjM2U1Yi1iMDBhLTQ3MTYtODY2MS00NjFkODk1M2EyNmQiLCJyb2xlIjoidXNlciIsIndhbGxldF9hZGRyZXNzIjoiRGlzWHdWbTFUNmpkYWp5S1g2Rm9NbVNKOThDekNQY1dXcVVBSjN4VUFTYzkiLCJpYXQiOjE2NjMyMjgzMTUsImV4cCI6MTY2MzgzMzExNX0.ol056CfU4K2O8K6q0NgDf3-mZQl8pkg_vm2q24u7x1Y"; NKRetrofit.apiService.getDApps("Bearer $accessToken").enqueue(object : Callback { override fun onFailure(call: Call?, t: Throwable?) { Log.v("retrofit", "call failed") } override fun onResponse(call: Call?, response: Response?) { if(response!!.code() == 200) { val value = response!!.body()!!.string(); Log.e("AAA", value); } else { Log.e("AAA", "error") } } }) } class NekoTestModule : Module() { // Each module class must implement the definition function. The definition consists of components // that describes the module's functionality and behavior. // See https://docs.expo.dev/modules/module-api for more details about available components. override fun definition() = ModuleDefinition { // Sets the name of the module that JavaScript code will use to refer to the module. Takes a string as an argument. // Can be inferred from module's class name, but it's recommended to set it explicitly for clarity. // The module will be accessible from `requireNativeModule('NekoTest')` in JavaScript. Name("NekoTest") // Sets constant properties on the module. Can take a dictionary or a closure that returns a dictionary. Constants( "PI" to Math.PI ) // Defines event names that the module can send to JavaScript. Events("onChange") // Defines a JavaScript synchronous function that runs the native code on the JavaScript thread. Function("hello") { "Hello world! 👋" } AsyncFunction("setValueAsync") { value: String, promise: Promise -> launch(Dispatchers.Main) { promise.resolve(message) } } // Enables the module to be used as a view manager. The view manager definition is built from // the definition components used in the closure passed to viewManager. // Definition components that are accepted as part of the view manager definition: `View`, `Prop`. ViewManager { // Defines the factory creating a native view when the module is used as a view. View { context -> NekoTestView(context) } // Defines a setter for the `name` prop. Prop("name") { view: NekoTestView, prop: String -> println(prop) } } } }