GitHub 저장소yoonjaepark/flutter_naver_login

flutter_naver_login

네이버 로그인을 위한 플러터 플러그인입니다.

flutter_naver_login 프로젝트 이미지
스타
55
포크
119
최근 푸시(UTC)
2025. 5. 23.
프로젝트 상태
활성

원본 README

아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.

flutter_naver_login

Build Status Build Status Build Status Build Status

A Flutter plugin for using the native Naver Login SDKs on Android and iOS.

AndroidX support

Migration

from pre-2.1.0 to 2.1.0.

Installation

1. Add dependency

Add the following to your pubspec.yaml file:

dependencies:
  flutter_naver_login: ^2.1.0
2. Platform Setup
Android
  1. Add the following to your android/app/src/main/res/values/strings.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="client_id">[client_id]</string>
    <string name="client_secret">[client_secret]</string>
    <string name="client_name">[client_name]</string>
</resources>
  1. Update your android/app/src/main/AndroidManifest.xml:
<application
    android:name="io.flutter.app.FlutterApplication"
    android:label="your_app_name"
    android:icon="@mipmap/ic_launcher">
    <meta-data
        android:name="com.naver.sdk.clientId"
        android:value="@string/client_id" />
    <meta-data
        android:name="com.naver.sdk.clientSecret"
        android:value="@string/client_secret" />
    <meta-data
        android:name="com.naver.sdk.clientName"
        android:value="@string/client_name" />
</application>
  1. Use FlutterFragmentActivity in your MainActivity:
import io.flutter.embedding.android.FlutterFragmentActivity

class MainActivity: FlutterFragmentActivity()
iOS
  1. Install pods:
cd ios
pod install
  1. Update your ios/Runner/Info.plist:
<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>[UrlScheme]</string>
        </array>
    </dict>
</array>

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>naversearchapp</string>
    <string>naversearchthirdlogin</string>
</array>

<key>NidUrlScheme</key>
<string>[UrlScheme]</string>
<key>NidClientID</key>
<string>[ConsumerKey]</string>
<key>NidClientSecret</key>
<string>[ConsumerSecret]</string>
<key>NidAppName</key>
<string>[ServiceAppName]</string>
  1. Update your AppDelegate:
import NidThirdPartyLogin

@UIApplicationMain
class AppDelegate: FlutterAppDelegate {
    override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
        if (NidOAuth.shared.handleURL(url) == true) { // If the URL was passed from the Naver app
          return true
        }
     		
        // Handle URLs coming from other apps
        return false
    }
}

Migration Guide

iOS Migration from pre-2.1.0 to 2.1.0
1. Update Info.plist
Before 2.1.0:
<key>naverServiceAppUrlScheme</key>
<string>[UrlScheme]</string>
<key>naverConsumerKey</key>
<string>[ConsumerKey]</string>
<key>naverConsumerSecret</key>
<string>[ConsumerSecret]</string>
<key>naverServiceAppName</key>
<string>[ServiceAppName]</string>
After 2.1.0:
<key>NidUrlScheme</key>
<string>[UrlScheme]</string>
<key>NidClientID</key>
<string>[ConsumerKey]</string>
<key>NidClientSecret</key>
<string>[ConsumerSecret]</string>
<key>NidAppName</key>
<string>[ServiceAppName]</string>
2. Update AppDelegate
Before 2.1.0:
import NaverThirdPartyLogin

@UIApplicationMain
class AppDelegate: FlutterAppDelegate {
    override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
        var applicationResult = false
        if (!applicationResult) {
           applicationResult = NaverThirdPartyLoginConnection.getSharedInstance().application(app, open: url, options: options)
        }
        if (!applicationResult) {
           applicationResult = super.application(app, open: url, options: options)
        }
        return applicationResult
    }
}
After 2.1.0:
import NidThirdPartyLogin

@UIApplicationMain
class AppDelegate: FlutterAppDelegate {
    override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
        if (NidOAuth.shared.handleURL(url) == true) { // If the URL was passed from the Naver app
          return true
        }
        
        // Handle URLs coming from other apps
        return false
    }
}
3. Migration Process
cd ios
pod deintegrate
pod install
flutter clean
flutter pub get

Usage

Types
NaverLoginResult
class NaverLoginResult {
  final NaverLoginStatus status;
  final NaverAccountResult? account;
}
NaverToken
class NaverToken {
  final String accessToken;
  final String refreshToken;
  final String tokenType;
  final String expiresAt;
  
  bool isValid();
}
NaverAccountResult
class NaverAccountResult {
  final String id;
  final String nickname;
  final String name;
  final String email;
  final String gender;
  final String age;
  final String birthday;
  final String birthyear;
  final String profileImage;
  final String mobile;
  final String mobileE164;
}
NaverLoginStatus
enum NaverLoginStatus {
  loggedIn,
  loggedOut,
  error
}
API Examples
Login
try {
  final NaverLoginResult res = await FlutterNaverLogin.logIn();
  if (res.status == NaverLoginStatus.loggedIn) {
    // Login successful
    final account = res.account;
    print('User name: ${account?.name}');
  }
} catch (error) {
  print('Login failed: $error');
}
Get Current Access Token
try {
  final NaverToken token = await FlutterNaverLogin.getCurrentAccessToken();
  if (token.isValid()) {
    print('Access Token: ${token.accessToken}');
    print('Refresh Token: ${token.refreshToken}');
    print('Token Type: ${token.tokenType}');
    print('Expires At: ${token.expiresAt}');
  }
} catch (error) {
  print('Failed to get token: $error');
}
Get Current Account
try {
  final NaverAccountResult account = await FlutterNaverLogin.getCurrentAccount();
  print('User name: ${account.name}');
  print('User email: ${account.email}');
  print('User profile: ${account.profileImage}');
} catch (error) {
  print('Failed to get account: $error');
}
Logout
try {
  final NaverLoginResult res = await FlutterNaverLogin.logOut();
  if (res.status == NaverLoginStatus.loggedOut) {
    // Logout successful
  }
} catch (error) {
  print('Logout failed: $error');
}
Logout and Delete Token
try {
  final NaverLoginResult res = await FlutterNaverLogin.logOutAndDeleteToken();
  if (res.status == NaverLoginStatus.loggedOut) {
    // Logout and token deletion successful
  }
} catch (error) {
  print('Logout and token deletion failed: $error');
}

Troubleshooting

iOS Issues
  1. CocoaPods Version Error

    • Solution: Update your Podfile to specify the minimum deployment target:
    platform :ios, '13.0' // https://github.com/naver/naveridlogin-sdk-ios-swift
    
  2. Build System Error

    • Solution: In Xcode, go to File > Project Settings and change Build System to "Legacy Build System"
  3. Linker Error

    • Solution: Clean the build folder and rebuild:
    cd ios
    pod deintegrate
    pod install
    
Android Issues
  1. Back Button Issue

    • Solution: Use the provided MainActivity code with shouldAutomaticallyHandleOnBackPressed
  2. Proguard Issues

    • Solution: Add the provided Proguard rules to your proguard-rules.pro file

Contributing

Feel free to contribute to this project by submitting issues or pull requests.

License

This project is licensed under the MIT License - see the LICENSE file for details.

yoonjaepark GitHub avatar
GitHub 작성자

yoonjaepark ↗

WemakepriceSeoul, Korea공식 웹사이트 ↗
언어DartKotlinSwiftRubyObjective-C

분류

이 저장소가 배포한 패키지

사용 중인 의존성

의존성 목록 4 개

  • flutter{"sdk":"flutter"}
  • plugin_platform_interface^2.0.2
  • flutter_test개발 의존성{"sdk":"flutter"}
  • flutter_lints개발 의존성^5.0.0

프로젝트에 맞는 저장소를 선택하려면?

사용 목적에 따라 검색하고 개발 활동을 비교한 뒤 원본 저장소에서 요구 사항을 확인하세요.

  1. 이름, 작성자 또는 설명으로 검색하고 기술 주제로 범위를 좁힙니다.
  2. 스타, 포크, 최근 푸시를 함께 비교하세요. 스타는 관심의 지표이며 품질을 보장하지 않습니다.
  3. 사용하기 전에 GitHub에서 README, 라이선스, Issues를 확인하세요.

출처 및 관리

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗