From 4258d3e073ffc9c79fef5b08447d8e7d06ad1f31 Mon Sep 17 00:00:00 2001 From: mym0404 Date: Sun, 28 Apr 2024 16:54:36 +0900 Subject: [PATCH 1/5] feat(core): getKeyHashAndroid utility fn --- docs/docs/core/get-android-keyhash.mdx | 15 +++++++++++++++ docs/docs/install-android.mdx | 6 ++++-- .../mjstudio/rnkakao/core/RNCKakaoCoreModule.kt | 7 +++++++ .../core/android/src/oldarch/KakaoCoreSpec.kt | 3 +++ packages/core/ios/RNCKakaoCore.mm | 6 ++++++ packages/core/src/index.tsx | 4 ++++ packages/core/src/spec/NativeKakaoCore.ts | 1 + 7 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 docs/docs/core/get-android-keyhash.mdx diff --git a/docs/docs/core/get-android-keyhash.mdx b/docs/docs/core/get-android-keyhash.mdx new file mode 100644 index 0000000..cec9b47 --- /dev/null +++ b/docs/docs/core/get-android-keyhash.mdx @@ -0,0 +1,15 @@ +--- +sidebar_position: 3 +--- + +# 안드로이드 키 해시 얻기 + +## 안드로이드 키 해시 얻기 + +안드로이드의 키 해시를 각 환경에서 쉽게 얻을 수 있는 유틸리티 함수입니다. + +```tsx title='index.js' +import { getKeyHashAndroid } from '@react-native-kakao/core'; + +getKeyHashAndroid().then(console.log); +``` diff --git a/docs/docs/install-android.mdx b/docs/docs/install-android.mdx index f1cd06a..e803dae 100644 --- a/docs/docs/install-android.mdx +++ b/docs/docs/install-android.mdx @@ -37,8 +37,6 @@ sidebar_position: 3 - 디버그 키 해시: 프로젝트를 처음 생성하거나 디버그할 때, 안드로이드 스튜디오에서 개발 환경에 맞게 자동으로 생성되는 디버그 인증서에서 해시(hash)한 값 - 릴리즈 키 해시: 앱 스토어에 앱을 배포하기 위해 생성한 릴리즈 인증서로부터 해시한 값 -키 해시 생성은 [공식 문서](https://developers.kakao.com/docs/latest/ko/android/getting-started#before-you-begin-add-key-hash)에서 참고해주세요. - :::info 이것과 더불어 Google Play Console에서 발급해주는 키 해시가 하나 더 있습니다. @@ -50,6 +48,10 @@ Google Play Console에선 앱을 릴리즈 할 때마다 [App signing](https://p 이것을 등록하지 않을 시 실제 플레이 스토어에 앱을 출시해 구동시킬 때 Kakao SDK가 동작하지 않습니다. ::: +키 해시는 `core`패키지의 `getKeyHashAndroid()`함수로 쉽게 얻어올 수 있습니다. + +디버그, 릴리즈, 플레이스토어 환경에서 각각 이 함수의 결과값을 콘솔이나 텍스트에 출력 후 그대로 사용하시면 됩니다. + ## 프로젝트 권한 안드로이드의 `AndroidManifest.xml`에서 인터넷에 사용된 권한을 허용해줍니다. diff --git a/packages/core/android/src/main/java/net/mjstudio/rnkakao/core/RNCKakaoCoreModule.kt b/packages/core/android/src/main/java/net/mjstudio/rnkakao/core/RNCKakaoCoreModule.kt index f55b136..7714f81 100644 --- a/packages/core/android/src/main/java/net/mjstudio/rnkakao/core/RNCKakaoCoreModule.kt +++ b/packages/core/android/src/main/java/net/mjstudio/rnkakao/core/RNCKakaoCoreModule.kt @@ -1,8 +1,10 @@ package net.mjstudio.rnkakao.core +import com.facebook.react.bridge.Promise import com.facebook.react.bridge.ReactApplicationContext import com.facebook.react.bridge.ReactMethod import com.kakao.sdk.common.KakaoSdk +import com.kakao.sdk.common.util.Utility import net.mjstudio.rnkakao.core.util.onMain class RNCKakaoCoreModule internal constructor(context: ReactApplicationContext) : @@ -17,6 +19,11 @@ class RNCKakaoCoreModule internal constructor(context: ReactApplicationContext) KakaoSdk.init(context = reactApplicationContext, appKey = appKey) } + @ReactMethod + override fun getKeyHashAndroid(promise: Promise) { + promise.resolve(Utility.getKeyHash(reactApplicationContext)) + } + companion object { const val NAME = "RNCKakaoCore" } diff --git a/packages/core/android/src/oldarch/KakaoCoreSpec.kt b/packages/core/android/src/oldarch/KakaoCoreSpec.kt index 09e4e96..19f9c9f 100644 --- a/packages/core/android/src/oldarch/KakaoCoreSpec.kt +++ b/packages/core/android/src/oldarch/KakaoCoreSpec.kt @@ -1,9 +1,12 @@ package net.mjstudio.rnkakao.core +import com.facebook.react.bridge.Promise import com.facebook.react.bridge.ReactApplicationContext import com.facebook.react.bridge.ReactContextBaseJavaModule abstract class KakaoCoreSpec internal constructor(context: ReactApplicationContext) : ReactContextBaseJavaModule(context) { abstract fun initializeKakaoSDK(appKey: String) + + abstract fun getKeyHashAndroid(promise: Promise) } diff --git a/packages/core/ios/RNCKakaoCore.mm b/packages/core/ios/RNCKakaoCore.mm index 825ed50..bad5ebd 100644 --- a/packages/core/ios/RNCKakaoCore.mm +++ b/packages/core/ios/RNCKakaoCore.mm @@ -13,6 +13,12 @@ - (RNCKakaoCoreManager*)manager { [[self manager] initializeKakaoSDK:appKey]; } +RCT_EXPORT_METHOD(getKeyHashAndroid + : (RCTPromiseResolveBlock)resolve reject + : (RCTPromiseRejectBlock)reject) { + resolve(nil); +} + // Don't compile this code when we build for the old architecture. #ifdef RCT_NEW_ARCH_ENABLED - (std::shared_ptr)getTurboModule: diff --git a/packages/core/src/index.tsx b/packages/core/src/index.tsx index 59988b1..8764cbe 100644 --- a/packages/core/src/index.tsx +++ b/packages/core/src/index.tsx @@ -30,4 +30,8 @@ const Native: Spec = Module export function initializeKakaoSDK(appKey: string) { Native.initializeKakaoSDK(appKey); } + +export function getKeyHashAndroid(): Promise { + return Native.getKeyHashAndroid(); +} export { kAssert }; diff --git a/packages/core/src/spec/NativeKakaoCore.ts b/packages/core/src/spec/NativeKakaoCore.ts index 375af3a..09c34ba 100644 --- a/packages/core/src/spec/NativeKakaoCore.ts +++ b/packages/core/src/spec/NativeKakaoCore.ts @@ -3,6 +3,7 @@ import { TurboModuleRegistry } from 'react-native'; export interface Spec extends TurboModule { initializeKakaoSDK(appKey: string): void; + getKeyHashAndroid(): Promise; } export default TurboModuleRegistry.getEnforcing('RNCKakaoCore'); From a0476e4dd358c0a58cca31b507a98dbf5cb9fb1d Mon Sep 17 00:00:00 2001 From: mym0404 Date: Sun, 28 Apr 2024 17:09:28 +0900 Subject: [PATCH 2/5] docs: update docs --- docs/docs/core/get-android-keyhash.mdx | 9 +++++++++ docs/docs/install-android.mdx | 2 ++ 2 files changed, 11 insertions(+) diff --git a/docs/docs/core/get-android-keyhash.mdx b/docs/docs/core/get-android-keyhash.mdx index cec9b47..35f9c76 100644 --- a/docs/docs/core/get-android-keyhash.mdx +++ b/docs/docs/core/get-android-keyhash.mdx @@ -13,3 +13,12 @@ import { getKeyHashAndroid } from '@react-native-kakao/core'; getKeyHashAndroid().then(console.log); ``` + +:::info +이 함수는 콘솔이 출력되는 debug환경에서는 위와 같이 단순히 `console.log`로 확인할 수 있지만, + +디버그 환경이 아닌 릴리즈 환경에서는 정확한 키를 얻기 위해 `Text`같은 컴포넌트에 보여준 뒤 얻어오는 것도 방법이 될 수 있습니다. + +물론 이 유틸리티를 사용하지 않고 [공식 문서](https://developers.kakao.com/docs/latest/ko/android/getting-started#before-you-begin-add-key-hash)를 따라 직접 추출할 수 있습니다. + +::: diff --git a/docs/docs/install-android.mdx b/docs/docs/install-android.mdx index e803dae..aeca68b 100644 --- a/docs/docs/install-android.mdx +++ b/docs/docs/install-android.mdx @@ -52,6 +52,8 @@ Google Play Console에선 앱을 릴리즈 할 때마다 [App signing](https://p 디버그, 릴리즈, 플레이스토어 환경에서 각각 이 함수의 결과값을 콘솔이나 텍스트에 출력 후 그대로 사용하시면 됩니다. +키 해시 직접 생성은 [공식 문서](https://developers.kakao.com/docs/latest/ko/android/getting-started#before-you-begin-add-key-hash)에서 참고해주세요. + ## 프로젝트 권한 안드로이드의 `AndroidManifest.xml`에서 인터넷에 사용된 권한을 허용해줍니다. From 6bed258ae5387f7d0e822948188a63bfd69f4813 Mon Sep 17 00:00:00 2001 From: mym0404 Date: Sun, 28 Apr 2024 17:18:27 +0900 Subject: [PATCH 3/5] ci: skip cocoapods install if cache hit --- .github/workflows/ci.yml | 2 +- turbo.json | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3ca129f..9bbfbbf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -172,7 +172,7 @@ jobs: ${{ runner.os }}-cocoapods-${{matrix.arch}}- - name: Install cocoapods -# if: env.turbo_cache_hit != 1 && steps.cocoapods-cache.outputs.cache-hit != 'true' + if: env.turbo_cache_hit != 1 && steps.cocoapods-cache.outputs.cache-hit != 'true' run: yarn pod:${{matrix.arch}} env: NO_FLIPPER: 1 diff --git a/turbo.json b/turbo.json index 3de5ca7..cd686f9 100644 --- a/turbo.json +++ b/turbo.json @@ -50,6 +50,7 @@ "packages/**/ios/**", "packages/core/expo-config-plugin", "example/ios/**", + "!example/ios/.xcode.env*", "!example/android/.gradle", "!example/android/build", "!example/android/app/build", @@ -69,6 +70,7 @@ "packages/**/ios/**", "packages/core/expo-config-plugin", "example/ios/**", + "!example/ios/.xcode.env*", "!example/android/.gradle", "!example/android/build", "!example/android/app/build", From 7688d7e3a41d6334c2b744e0129fcbe6828023de Mon Sep 17 00:00:00 2001 From: mym0404 Date: Sun, 28 Apr 2024 17:24:24 +0900 Subject: [PATCH 4/5] ci: fix ci --- .github/workflows/ci.yml | 2 +- turbo.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9bbfbbf..3ca129f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -172,7 +172,7 @@ jobs: ${{ runner.os }}-cocoapods-${{matrix.arch}}- - name: Install cocoapods - if: env.turbo_cache_hit != 1 && steps.cocoapods-cache.outputs.cache-hit != 'true' +# if: env.turbo_cache_hit != 1 && steps.cocoapods-cache.outputs.cache-hit != 'true' run: yarn pod:${{matrix.arch}} env: NO_FLIPPER: 1 diff --git a/turbo.json b/turbo.json index cd686f9..4e63287 100644 --- a/turbo.json +++ b/turbo.json @@ -49,7 +49,7 @@ "packages/**/src/**", "packages/**/ios/**", "packages/core/expo-config-plugin", - "example/ios/**", + "example/ios/**/*.{mm,m,swift,h,plist,lock}", "!example/ios/.xcode.env*", "!example/android/.gradle", "!example/android/build", @@ -69,7 +69,7 @@ "packages/**/src/**", "packages/**/ios/**", "packages/core/expo-config-plugin", - "example/ios/**", + "example/ios/**/.{mm,m,swift,h,plist,lock}", "!example/ios/.xcode.env*", "!example/android/.gradle", "!example/android/build", From bafe4e7942489c9acf99ed8d0e28aa8b99ea888e Mon Sep 17 00:00:00 2001 From: mym0404 Date: Sun, 28 Apr 2024 17:34:19 +0900 Subject: [PATCH 5/5] docs: update docs --- docs/docs/core/get-android-keyhash.mdx | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/docs/core/get-android-keyhash.mdx b/docs/docs/core/get-android-keyhash.mdx index 35f9c76..e6eb1f2 100644 --- a/docs/docs/core/get-android-keyhash.mdx +++ b/docs/docs/core/get-android-keyhash.mdx @@ -20,5 +20,4 @@ getKeyHashAndroid().then(console.log); 디버그 환경이 아닌 릴리즈 환경에서는 정확한 키를 얻기 위해 `Text`같은 컴포넌트에 보여준 뒤 얻어오는 것도 방법이 될 수 있습니다. 물론 이 유틸리티를 사용하지 않고 [공식 문서](https://developers.kakao.com/docs/latest/ko/android/getting-started#before-you-begin-add-key-hash)를 따라 직접 추출할 수 있습니다. - :::