Skip to content

Commit

Permalink
[feat] 카카오 소셜 로그인 기능 추가 (#1)
Browse files Browse the repository at this point in the history
* [feat] gradlew 권한 변경

* [feat] @react-native-seoul/kakao-login 추가

* [feat] package 추가

* [feat] react-native-config package 추가

* [feat] gitignore .env 추가

* [feat] react-native-config 관련 설정

* [feat] react-native-kakao-login 설정

* [feat] 로그인 페이지
  • Loading branch information
ujunhwan authored Dec 30, 2021
1 parent 480243a commit 7416d10
Show file tree
Hide file tree
Showing 11 changed files with 10,465 additions and 23 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,6 @@ buck-out/
.expo/
web-build/
dist/

# KEY
.env
24 changes: 24 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
apply plugin: "com.android.application"
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"

import com.android.build.OutputFile

Expand Down Expand Up @@ -137,6 +138,7 @@ android {
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
resValue "string", "build_config_package", "com.chatminderclient"
}
splits {
abi {
Expand Down Expand Up @@ -165,6 +167,27 @@ android {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}

devDebug {
initWith debug
applicationIdSuffix ".dev"
matchingFallbacks = ['debug']
}
devRelease {
initWith release
applicationIdSuffix ".dev"
matchingFallbacks = ['release']
}
stageDebug {
initWith debug
applicationIdSuffix ".test"
matchingFallbacks = ['debug']
}
stageRelease {
initWith release
applicationIdSuffix ".test"
matchingFallbacks = ['release']
}
}

// applicationVariants are e.g. debug, release
Expand All @@ -187,6 +210,7 @@ dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules
implementation project(':react-native-config') // for react-native-config

def isGifEnabled = (findProperty('expo.gif.enabled') ?: "") == "true";
def isWebpEnabled = (findProperty('expo.webp.enabled') ?: "") == "true";
Expand Down
13 changes: 12 additions & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</intent>
</queries>

<application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="false" android:theme="@style/AppTheme" android:usesCleartextTraffic="true">
<application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="true" android:theme="@style/AppTheme" android:usesCleartextTraffic="true">
<meta-data android:name="expo.modules.updates.EXPO_UPDATE_URL" android:value="YOUR-APP-URL-HERE"/>
<meta-data android:name="expo.modules.updates.EXPO_SDK_VERSION" android:value="YOUR-APP-SDK-VERSION-HERE"/>
<activity android:name=".MainActivity" android:label="@string/app_name" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:theme="@style/Theme.App.SplashScreen">
Expand All @@ -28,5 +28,16 @@
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity"/>
<activity android:name="com.kakao.sdk.auth.AuthCodeHandlerActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<!-- Redirect URI: "kakao{NATIVE_APP_KEY}://oauth“ -->
<data android:host="oauth"
android:scheme="@string/KAKAO_SCHEME" />
</intent-filter>
</activity>
</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@
import android.content.res.Configuration;
import androidx.annotation.NonNull;

/* for key hash */
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.Signature;
import android.util.Base64;
import android.util.Log;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

import com.lugg.ReactNativeConfig.ReactNativeConfigPackage;
import com.facebook.react.shell.MainReactPackage;
/* key hash end */

import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactInstanceManager;
Expand All @@ -20,6 +34,7 @@

import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Arrays;

public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHostWrapper(
Expand All @@ -34,8 +49,6 @@ public boolean getUseDeveloperSupport() {
protected List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
return packages;
}

Expand All @@ -58,6 +71,7 @@ public ReactNativeHost getReactNativeHost() {
@Override
public void onCreate() {
super.onCreate();
getHashKey();
SoLoader.init(this, /* native exopackage */ false);

initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
Expand Down Expand Up @@ -100,4 +114,26 @@ private static void initializeFlipper(
}
}
}

private void getHashKey(){
PackageInfo packageInfo = null;
try {
packageInfo = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_SIGNATURES);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
if (packageInfo == null)
Log.e("KeyHash", "KeyHash:null");

for (Signature signature : packageInfo.signatures) {
try {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Log.d("KeyHash", Base64.encodeToString(md.digest(), Base64.DEFAULT));
} catch (NoSuchAlgorithmException e) {
Log.e("KeyHash", "Unable to get MessageDigest. signature=" + signature, e);
}
}
}

}
1 change: 1 addition & 0 deletions android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<resources>
<string name="app_name">ChatMinder-Client</string>
<string name="kakao_app_key">@string/KAKAO_APP_KEY</string>
</resources>
12 changes: 11 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@

buildscript {
ext {
buildToolsVersion = "29.0.3"
// buildToolsVersion = "29.0.3"
// minSdkVersion = 21
// compileSdkVersion = 29
// targetSdkVersion = 29
buildToolsVersion = "30.0.0"
minSdkVersion = 21
compileSdkVersion = 30
targetSdkVersion = 30
kotlinVersion = "1.5.20"
}
repositories {
google()
Expand All @@ -14,6 +19,7 @@ buildscript {
}
dependencies {
classpath("com.android.tools.build:gradle:4.1.0")
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -27,6 +33,10 @@ allprojects {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url(new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), "../android"))
}

maven {
url 'https://devrepo.kakao.com/nexus/content/groups/public/'
}
maven {
// Android JSC is installed from npm
url(new File(["node", "--print", "require.resolve('jsc-android/package.json')"].execute(null, rootDir).text.trim(), "../dist"))
Expand Down
Empty file modified android/gradlew
100644 → 100755
Empty file.
3 changes: 3 additions & 0 deletions android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ useExpoModules()
apply from: new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json')"].execute(null, rootDir).text.trim(), "../native_modules.gradle");
applyNativeModulesSettingsGradle(settings)

include ':react-native-config'
project(':react-native-config').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-config/android')

include ':app'
Loading

0 comments on commit 7416d10

Please sign in to comment.