Skip to content

Commit

Permalink
Fix regression #221
Browse files Browse the repository at this point in the history
  • Loading branch information
hyochan committed May 3, 2021
1 parent 5cd9e83 commit 8b39d6e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 24 deletions.
4 changes: 3 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
}

jvmTarget = "1.8"
kotlinOptions {
jvmTarget = "1.8"
}
}

repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,34 @@ class RNKakaoLoginsModule(private val reactContext: ReactApplicationContext) : R
@ReactMethod
private fun login(promise: Promise) {
if (UserApiClient.instance.isKakaoTalkLoginAvailable(reactContext)) {
UserApiClient.instance.loginWithKakaoTalk(reactContext) { token, error: Throwable? ->
if (error != null) {
promise.reject("RNKakaoLogins", error.message, error)
reactContext.currentActivity?.let {
UserApiClient.instance.loginWithKakaoTalk(it) { token, error: Throwable? ->
if (error != null) {
promise.reject("RNKakaoLogins", error.message, error)

return@loginWithKakaoTalk
}
return@loginWithKakaoTalk
}

if (token != null) {
val (accessToken, accessTokenExpiresAt, refreshToken, refreshTokenExpiresAt, scopes) = token
val map = Arguments.createMap()
map.putString("accessToken", accessToken)
map.putString("refreshToken", refreshToken)
map.putString("accessTokenExpiresAt", dateFormat(accessTokenExpiresAt))
map.putString("refreshTokenExpiresAt", dateFormat(refreshTokenExpiresAt))
val scopeArray = Arguments.createArray()
if (scopes != null) {
for (scope in scopes) {
scopeArray.pushString(scope)
if (token != null) {
val (accessToken, accessTokenExpiresAt, refreshToken, refreshTokenExpiresAt, scopes) = token
val map = Arguments.createMap()
map.putString("accessToken", accessToken)
map.putString("refreshToken", refreshToken)
map.putString("accessTokenExpiresAt", dateFormat(accessTokenExpiresAt))
map.putString("refreshTokenExpiresAt", dateFormat(refreshTokenExpiresAt))
val scopeArray = Arguments.createArray()
if (scopes != null) {
for (scope in scopes) {
scopeArray.pushString(scope)
}
}
map.putArray("scopes", scopeArray)
promise.resolve(map)
return@loginWithKakaoTalk
}
map.putArray("scopes", scopeArray)
promise.resolve(map)
return@loginWithKakaoTalk
}

promise.reject("RNKakaoLogins", "Token is null")
promise.reject("RNKakaoLogins", "Token is null")
}
}
} else {
UserApiClient.instance.loginWithKakaoAccount(reactContext) { token, error: Throwable? ->
Expand Down Expand Up @@ -178,4 +180,4 @@ class RNKakaoLoginsModule(private val reactContext: ReactApplicationContext) : R
reactContext.resources.getIdentifier("kakao_app_key", "string", reactContext.packageName))
init(reactContext, kakaoAppKey)
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@react-native-seoul/kakao-login",
"version": "3.2.0",
"version": "3.3.0",
"description": "React Native Module for Kakao Login",
"main": "index.js",
"types": "index.d.ts",
Expand Down

0 comments on commit 8b39d6e

Please sign in to comment.