@@ -30,7 +30,6 @@ class LineLogin(private val reactContext: ReactApplicationContext) :
3030 ReactContextBaseJavaModule (reactContext) {
3131 companion object {
3232 private const val MODULE_NAME : String = " LineLogin"
33- private const val ERROR_MESSAGE : String = " ERROR"
3433 }
3534
3635 private lateinit var channelId: String
@@ -43,13 +42,12 @@ class LineLogin(private val reactContext: ReactApplicationContext) :
4342 override fun getName () = MODULE_NAME
4443
4544 @ReactMethod
46- fun setup (channelId : String , promise : Promise ) {
45+ fun setup (args : ReadableMap , promise : Promise ) {
4746 val context: Context = reactContext.applicationContext
48- this . channelId = channelId
49- this . lineApiClient = LineApiClientBuilder (context, channelId).build()
47+ channelId = args.getString( " channelId" ) !!
48+ lineApiClient = LineApiClientBuilder (context, channelId).build()
5049 reactContext.addActivityEventListener(object : ActivityEventListener {
5150 override fun onNewIntent (intent : Intent ? ) {}
52-
5351 override fun onActivityResult (
5452 activity : Activity ? ,
5553 requestCode : Int ,
@@ -118,7 +116,7 @@ class LineLogin(private val reactContext: ReactApplicationContext) :
118116 @ReactMethod
119117 fun getProfile (promise : Promise ) {
120118 uiCoroutineScope.launch {
121- val lineApiResponse = withContext(Dispatchers .IO ) { lineApiClient.profile }
119+ val lineApiResponse = withContext(Dispatchers .IO ) { lineApiClient.getProfile() }
122120 if (! lineApiResponse.isSuccess) {
123121 promise.reject(
124122 lineApiResponse.responseCode.name,
@@ -137,7 +135,7 @@ class LineLogin(private val reactContext: ReactApplicationContext) :
137135 if (resultCode != Activity .RESULT_OK || intent == null ) {
138136 loginResult?.reject(
139137 resultCode.toString(),
140- ERROR_MESSAGE ,
138+ " ERROR " ,
141139 null
142140 )
143141 }
0 commit comments