Skip to content

Commit 4ea50de

Browse files
committed
fix: android build issues
1 parent caef14a commit 4ea50de

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

android/src/main/java/com/xmartlabs/rnline/LineLogin.kt

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class LineLogin(private val reactContext: ReactApplicationContext) :
3434

3535
private lateinit var channelId: String
3636
private lateinit var lineApiClient: LineApiClient
37-
private const val LOGIN_REQUEST_CODE: Int = 0
37+
private var LOGIN_REQUEST_CODE: Int = 0
3838
private val uiCoroutineScope: CoroutineScope = CoroutineScope(Dispatchers.Main)
3939

4040
private var loginResult: Promise? = null
@@ -48,26 +48,31 @@ class LineLogin(private val reactContext: ReactApplicationContext) :
4848
lineApiClient = LineApiClientBuilder(context, channelId).build()
4949
reactContext.addActivityEventListener(object : ActivityEventListener {
5050
override fun onNewIntent(intent: Intent?) {}
51-
5251
override fun onActivityResult(
5352
activity: Activity?,
5453
requestCode: Int,
5554
resultCode: Int,
5655
data: Intent?
57-
) {
56+
) =
5857
handleActivityResult(requestCode, resultCode, data)
59-
}
6058
})
6159
}
6260

6361
@ReactMethod
6462
fun login(args: ReadableMap, promise: Promise) {
65-
val scopes: List<String> =
66-
args.getArray(LoginArguments.SCOPES.key)?.toArrayList()?.mapNotNull { it as? String }
67-
?: listOf("profile")
68-
val onlyWebLogin = args.getBoolean(LoginArguments.ONLY_WEB_LOGIN.key, false)
69-
val botPromptString = args.getString(LoginArguments.BOT_PROMPT.key) ?: "normal"
70-
login(scopes, onlyWebLogin, botPromptString, promise)
63+
val scopes =
64+
if (args.hasKey(LoginArguments.SCOPES.key)) args.getArray(LoginArguments.SCOPES.key)!!
65+
.toArrayList() as List<String> else listOf("profile")
66+
val onlyWebLogin =
67+
args.hasKey(LoginArguments.ONLY_WEB_LOGIN.key) && args.getBoolean(LoginArguments.ONLY_WEB_LOGIN.key)
68+
val botPromptString =
69+
if (args.hasKey(LoginArguments.BOT_PROMPT.key)) args.getString(LoginArguments.BOT_PROMPT.key)!! else "normal"
70+
login(
71+
scopes,
72+
onlyWebLogin,
73+
botPromptString,
74+
promise
75+
)
7176
}
7277

7378
private fun login(

example/package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)