Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added week10hw/.DS_Store
Binary file not shown.
670 changes: 670 additions & 0 deletions week10hw/week10hw.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>week10hw.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
63 changes: 63 additions & 0 deletions week10hw/week10hw/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"images" : [
{
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "16x16"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "16x16"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "32x32"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "32x32"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "128x128"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "128x128"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "256x256"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "256x256"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "512x512"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "512x512"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
6 changes: 6 additions & 0 deletions week10hw/week10hw/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
24 changes: 24 additions & 0 deletions week10hw/week10hw/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>kakao768d9c4c82cd61674d837f10b98ed25b</string>
</array>
</dict>
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>kakaokompassauth</string>
<string>kakaolink</string>
<string>kakaoplus</string>
<string>kakaotalk</string>
</array>
</dict>
</plist>
67 changes: 67 additions & 0 deletions week10hw/week10hw/KakaoLogin/View/LoginMainView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
//
// LoginMainView.swift
// week10hw
//
// Created by 이재용 on 6/20/24.
//
import SwiftUI
import KakaoSDKAuth
import KakaoSDKUser

struct ContentView: View {
@State private var isLoggedIn: Bool = false
@State private var userInfo: String = ""

var body: some View {
VStack {
if isLoggedIn {
Text("User Info: \(userInfo)")
} else {
Button(action: {
loginWithKakao()
}) {
Text("Login with Kakao")
.padding()
.background(Color.yellow)
.foregroundColor(.black)
.cornerRadius(10)
}
}
}
.padding()
}

func loginWithKakao() {
if UserApi.isKakaoTalkLoginAvailable() {
UserApi.shared.loginWithKakaoTalk { (oauthToken, error) in
if let error = error {
print(error)
} else {
print("loginWithKakaoTalk() success.")
getUserInfo()
}
}
} else {
UserApi.shared.loginWithKakaoAccount { (oauthToken, error) in
if let error = error {
print(error)
} else {
print("loginWithKakaoAccount() success.")
getUserInfo()
}
}
}
}

func getUserInfo() {
UserApi.shared.me { (user, error) in
if let error = error {
print(error)
} else {
print("User info: \(String(describing: user))")
isLoggedIn = true
userInfo = user?.kakaoAccount?.profile?.nickname ?? "No Name"
}
}
}
}
36 changes: 36 additions & 0 deletions week10hw/week10hw/KakaoLogin/ViewModel/File.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import SwiftUI
import KakaoSDKCommon
import KakaoSDKAuth
import KakaoSDKUser

struct KakaoSigninButton: View{
var body: some View{
Button {
if (UserApi.isKakaoTalkLoginAvailable()) {
UserApi.shared.loginWithKakaoTalk {(oauthToken, error) in
if let error = error {
print(error)
}
if let oauthToken = oauthToken{
// 소셜 로그인(회원가입 API CALL)
}
}
} else {
UserApi.shared.loginWithKakaoAccount {(oauthToken, error) in
if let error = error {
print(error)
}
if let oauthToken = oauthToken{
print("kakao success")
// 소셜 로그인(회원가입 API CALL)
}
}
}
} label : {
Image("kakao_login_large_wide")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width : UIScreen.main.bounds.width * 0.9)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
10 changes: 10 additions & 0 deletions week10hw/week10hw/week10hw.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
</dict>
</plist>
29 changes: 29 additions & 0 deletions week10hw/week10hw/week10hwApp.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// week10hwApp.swift
// week10hw
//
// Created by 이재용 on 6/20/24.
//

import SwiftUI
import KakaoSDKCommon
import KakaoSDKAuth

@main
struct week10hwApp: App {
init() {
// Kakao SDK 초기화
KakaoSDK.initSDK(appKey: "768d9c4c82cd61674d837f10b98ed25b")

}
var body: some Scene {
WindowGroup {
// onOpenURL()을 사용해 커스텀 URL 스킴 처리
ContentView().onOpenURL(perform: { url in
if (AuthApi.isKakaoTalkLoginUrl(url)) {
AuthController.handleOpenUrl(url: url)
}
})
}
}
}
35 changes: 35 additions & 0 deletions week10hw/week10hwTests/week10hwTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// week10hwTests.swift
// week10hwTests
//
// Created by 이재용 on 6/20/24.
//

import XCTest

final class week10hwTests: XCTestCase {

override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
}

override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}

func testExample() throws {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
// Any test you write for XCTest can be annotated as throws and async.
// Mark your test throws to produce an unexpected failure when your test encounters an uncaught error.
// Mark your test async to allow awaiting for asynchronous code to complete. Check the results with assertions afterwards.
}

func testPerformanceExample() throws {
// This is an example of a performance test case.
measure {
// Put the code you want to measure the time of here.
}
}

}
41 changes: 41 additions & 0 deletions week10hw/week10hwUITests/week10hwUITests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//
// week10hwUITests.swift
// week10hwUITests
//
// Created by 이재용 on 6/20/24.
//

import XCTest

final class week10hwUITests: XCTestCase {

override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.

// In UI tests it is usually best to stop immediately when a failure occurs.
continueAfterFailure = false

// In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
}

override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}

func testExample() throws {
// UI tests must launch the application that they test.
let app = XCUIApplication()
app.launch()

// Use XCTAssert and related functions to verify your tests produce the correct results.
}

func testLaunchPerformance() throws {
if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) {
// This measures how long it takes to launch your application.
measure(metrics: [XCTApplicationLaunchMetric()]) {
XCUIApplication().launch()
}
}
}
}
Loading