diff --git a/android/build.gradle b/android/build.gradle index 1a0b682..ce3f207 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -42,7 +42,9 @@ android { targetCompatibility JavaVersion.VERSION_1_8 } - jvmTarget = "1.8" + kotlinOptions { + jvmTarget = "1.8" + } } repositories { diff --git a/android/src/main/java/com/dooboolab/kakaologins/RNKakaoLoginsModule.kt b/android/src/main/java/com/dooboolab/kakaologins/RNKakaoLoginsModule.kt index afcaca0..5de03b5 100644 --- a/android/src/main/java/com/dooboolab/kakaologins/RNKakaoLoginsModule.kt +++ b/android/src/main/java/com/dooboolab/kakaologins/RNKakaoLoginsModule.kt @@ -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? -> @@ -178,4 +180,4 @@ class RNKakaoLoginsModule(private val reactContext: ReactApplicationContext) : R reactContext.resources.getIdentifier("kakao_app_key", "string", reactContext.packageName)) init(reactContext, kakaoAppKey) } -} \ No newline at end of file +} diff --git a/package.json b/package.json index 4781a32..9820e67 100644 --- a/package.json +++ b/package.json @@ -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",