-
Notifications
You must be signed in to change notification settings - Fork 140
feat: kakao login scopes #411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nnnnoel
wants to merge
3
commits into
crossplatformkorea:main
Choose a base branch
from
nnnnoel:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ import KakaoSDKUser | |
|
||
@objc(RNKakaoLogins) | ||
class RNKakaoLogins: NSObject { | ||
|
||
public override init() { | ||
let appKey: String? = Bundle.main.object(forInfoDictionaryKey: "KAKAO_APP_KEY") as? String | ||
let customScheme: String? = Bundle.main.object(forInfoDictionaryKey: "KAKAO_APP_SCHEME") as? String | ||
|
@@ -24,36 +24,37 @@ class RNKakaoLogins: NSObject { | |
KakaoSDK.initSDK(appKey: appKey!) | ||
} | ||
} | ||
|
||
@objc | ||
static func requiresMainQueueSetup() -> Bool { | ||
return true | ||
return true | ||
} | ||
|
||
@objc(isKakaoTalkLoginUrl:) | ||
public static func isKakaoTalkLoginUrl(url:URL) -> Bool { | ||
|
||
let appKey = try? KakaoSDK.shared.appKey(); | ||
|
||
if (appKey != nil) { | ||
return AuthApi.isKakaoTalkLoginUrl(url) | ||
} | ||
return false | ||
} | ||
|
||
@objc(handleOpenUrl:) | ||
public static func handleOpenUrl(url:URL) -> Bool { | ||
return AuthController.handleOpenUrl(url: url) | ||
} | ||
|
||
@objc(login:rejecter:) | ||
func login(_ resolve: @escaping RCTPromiseResolveBlock, | ||
rejecter reject: @escaping RCTPromiseRejectBlock) -> Void { | ||
func login(_ scopes: [String], | ||
resolver resolve: @escaping RCTPromiseResolveBlock, | ||
rejecter reject: @escaping RCTPromiseRejectBlock) -> Void { | ||
DispatchQueue.main.async { | ||
let dateFormatter = DateFormatter() | ||
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"; | ||
|
||
if (UserApi.isKakaoTalkLoginAvailable()) { | ||
if (scopes.isEmpty && UserApi.isKakaoTalkLoginAvailable()) { | ||
UserApi.shared.loginWithKakaoTalk {(oauthToken, error) in | ||
if let error = error { | ||
reject("RNKakaoLogins", error.localizedDescription, nil) | ||
|
@@ -70,7 +71,7 @@ class RNKakaoLogins: NSObject { | |
} | ||
} | ||
} else { | ||
UserApi.shared.loginWithKakaoAccount {(oauthToken, error) in | ||
UserApi.shared.loginWithKakaoAccount(scopes: scopes) {(oauthToken, error) in | ||
if let error = error { | ||
reject("RNKakaoLogins", error.localizedDescription, nil) | ||
} | ||
|
@@ -88,14 +89,15 @@ class RNKakaoLogins: NSObject { | |
} | ||
} | ||
} | ||
|
||
@objc(loginWithKakaoAccount:rejecter:) | ||
func loginWithKakaoAccount(_ resolve: @escaping RCTPromiseResolveBlock, | ||
rejecter reject: @escaping RCTPromiseRejectBlock) -> Void { | ||
|
||
@objc(loginWithKakaoAccount:resolver:rejecter:) | ||
func loginWithKakaoAccount(_ scopes: [String], | ||
resolver resolve: @escaping RCTPromiseResolveBlock, | ||
rejecter reject: @escaping RCTPromiseRejectBlock) -> Void { | ||
DispatchQueue.main.async { | ||
let dateFormatter = DateFormatter() | ||
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"; | ||
UserApi.shared.loginWithKakaoAccount {(oauthToken, error) in | ||
let dateFormatter = DateFormatter() | ||
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"; | ||
UserApi.shared.loginWithKakaoAccount(scopes: scopes) {(oauthToken, error) in | ||
if let error = error { | ||
reject("RNKakaoLogins", error.localizedDescription, nil) | ||
} | ||
|
@@ -112,10 +114,10 @@ class RNKakaoLogins: NSObject { | |
} | ||
} | ||
} | ||
|
||
@objc(logout:rejecter:) | ||
func logout(_ resolve: @escaping RCTPromiseResolveBlock, | ||
rejecter reject: @escaping RCTPromiseRejectBlock) -> Void { | ||
rejecter reject: @escaping RCTPromiseRejectBlock) -> Void { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 여기도요! |
||
DispatchQueue.main.async { | ||
UserApi.shared.logout {(error) in | ||
if let error = error { | ||
|
@@ -127,10 +129,10 @@ class RNKakaoLogins: NSObject { | |
} | ||
} | ||
} | ||
|
||
@objc(unlink:rejecter:) | ||
func unlink(_ resolve: @escaping RCTPromiseResolveBlock, | ||
rejecter reject: @escaping RCTPromiseRejectBlock) -> Void { | ||
rejecter reject: @escaping RCTPromiseRejectBlock) -> Void { | ||
DispatchQueue.main.async { | ||
UserApi.shared.unlink {(error) in | ||
if let error = error { | ||
|
@@ -142,10 +144,10 @@ class RNKakaoLogins: NSObject { | |
} | ||
} | ||
} | ||
|
||
@objc(getAccessToken:rejecter:) | ||
func getAccessToken(_ resolve: @escaping RCTPromiseResolveBlock, | ||
rejecter reject: @escaping RCTPromiseRejectBlock) -> Void { | ||
rejecter reject: @escaping RCTPromiseRejectBlock) -> Void { | ||
DispatchQueue.main.async { | ||
UserApi.shared.accessTokenInfo {(accessTokenInfo, error) in | ||
if let error = error { | ||
|
@@ -160,10 +162,10 @@ class RNKakaoLogins: NSObject { | |
} | ||
} | ||
} | ||
|
||
@objc(getProfile:rejecter:) | ||
func getProfile(_ resolve: @escaping RCTPromiseResolveBlock, | ||
rejecter reject: @escaping RCTPromiseRejectBlock) -> Void { | ||
rejecter reject: @escaping RCTPromiseRejectBlock) -> Void { | ||
DispatchQueue.main.async { | ||
UserApi.shared.me() {(user, error) in | ||
if let error = error { | ||
|
@@ -199,14 +201,14 @@ class RNKakaoLogins: NSObject { | |
} | ||
} | ||
} | ||
|
||
@objc(shippingAddresses:rejecter:) | ||
func shippingAddresses(_ resolve: @escaping RCTPromiseResolveBlock, | ||
rejecter reject: @escaping RCTPromiseRejectBlock) -> Void { | ||
rejecter reject: @escaping RCTPromiseRejectBlock) -> Void { | ||
DispatchQueue.main.async { | ||
let dateFormatter = DateFormatter() | ||
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"; | ||
|
||
UserApi.shared.shippingAddresses() {(shippingAddresses, error) in | ||
if let error = error { | ||
reject("RNKakaoLogins", error.localizedDescription, nil) | ||
|
@@ -234,10 +236,10 @@ class RNKakaoLogins: NSObject { | |
} | ||
} | ||
} | ||
|
||
@objc(serviceTerms:rejecter:) | ||
func serviceTerms(_ resolve: @escaping RCTPromiseResolveBlock, | ||
rejecter reject: @escaping RCTPromiseRejectBlock) -> Void { | ||
rejecter reject: @escaping RCTPromiseRejectBlock) -> Void { | ||
DispatchQueue.main.async { | ||
UserApi.shared.serviceTerms {(userServiceTerms, error) in | ||
if let error = error { | ||
|
@@ -246,13 +248,13 @@ class RNKakaoLogins: NSObject { | |
else { | ||
let dateFormatter = DateFormatter() | ||
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss" | ||
|
||
var result: [String: Any] = [:] | ||
|
||
if let useId = userServiceTerms?.id { | ||
result["userId"] = useId | ||
} | ||
|
||
if let serviceTerms = userServiceTerms?.serviceTerms { | ||
result["serviceTerms"] = serviceTerms.map { | ||
var terms = [ | ||
|
@@ -261,15 +263,15 @@ class RNKakaoLogins: NSObject { | |
"required": $0.required, | ||
"revocable": $0.revocable | ||
] | ||
|
||
if let agreedAt = $0.agreedAt { | ||
terms["agreedAt"] = dateFormatter.string(from: agreedAt) | ||
} | ||
|
||
return terms | ||
} | ||
} | ||
|
||
resolve(result) | ||
} | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
불필요한 띄어쓰기를 되돌려 주시면 감사하겠습니다.