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
<key>LSApplicationQueriesSchemes</key> | |
<array> | |
<string>naversearchapp</string> | |
<string>naversearchthirdlogin</string> | |
</array> |
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
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | |
let instance = NaverThirdPartyLoginConnection.getSharedInstance() | |
// 네이버 앱으로 인증하는 방식을 활성화 | |
instance?.isNaverAppOauthEnable = true | |
// SafariViewController에서 인증하는 방식을 활성화 | |
instance?.isInAppOauthEnable = true | |
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
import UIKit | |
import Alamofire | |
import NaverThirdPartyLogin | |
class LoginViewController: UIViewController { | |
let loginInstance = NaverThirdPartyLoginConnection.getSharedInstance() | |
private let loginButton: UIButton = { | |
let button = UIButton(type: .system) |
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
@objc private func touchUpLoginButton(_ sender: UIButton) { | |
loginInstance?.delegate = self | |
loginInstance?.requestThirdPartyLogin() | |
} | |
@objc private func touchUpLogoutButton(_ sender: UIButton) { | |
loginInstance?.requestDeleteToken() | |
} |
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
extension LoginViewController: NaverThirdPartyLoginConnectionDelegate { | |
// 로그인 버튼을 눌렀을 경우 열게 될 브라우저 | |
func oauth20ConnectionDidOpenInAppBrowser(forOAuth request: URLRequest!) { | |
// let naverSignInVC = NLoginThirdPartyOAuth20InAppBrowserViewController(request: request)! | |
// naverSignInVC.parentOrientation = UIInterfaceOrientation(rawValue: UIDevice.current.orientation.rawValue)! | |
// present(naverSignInVC, animated: false, completion: nil) | |
// UPDATE: 2019. 10. 11 (금) | |
// UIWebView가 제거되면서 NLoginThirdPartyOAuth20InAppBrowserViewController가 있는 헤더가 삭제되었습니다. | |
// 해당 코드 없이도 로그인 화면이 잘 열리는 것을 확인했습니다. |
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
private func getNaverInfo() { | |
guard let isValidAccessToken = loginInstance?.isValidAccessTokenExpireTimeNow() else { return } | |
if !isValidAccessToken { | |
return | |
} | |
guard let tokenType = loginInstance?.tokenType else { return } | |
guard let accessToken = loginInstance?.accessToken else { return } | |
let urlStr = "https://openapi.naver.com/v1/nid/me" |
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
private let tableView: UITableView = { | |
let tableView = UITableView() | |
tableView.translatesAutoresizingMaskIntoConstraints = false | |
tableView.register(MainTableViewCell.self, forCellReuseIdentifier: MainTableViewCell.identifier) | |
return tableView | |
}() |
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
private func configure() { | |
tableView.dataSource = self | |
tableView.rowHeight = 100 | |
} | |
private func addSubView() { | |
view.addSubview(tableView) | |
} | |
private func autoLayout() { |
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
static let identifier = "MainTableViewCell" | |
let personImage: UIImageView = { | |
let personImage = UIImageView() | |
personImage.translatesAutoresizingMaskIntoConstraints = false | |
return personImage | |
}() | |
let personName: UILabel = { | |
let personName = UILabel() |
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
private func addContentView() { | |
contentView.addSubview(personImage) | |
contentView.addSubview(personName) | |
contentView.addSubview(personAge) | |
} | |
private func autoLayout() { | |
let margin: CGFloat = 10 | |
NSLayoutConstraint.activate([ | |
personImage.topAnchor.constraint(equalTo: self.topAnchor), |
OlderNewer