https://thenicesj.tistory.com/81
소셜로그인 android/ios (naver / kakao / google) in flutter
naver 로그인 구현 android https://thenicesj.tistory.com/18 [sociallogin] naver login구현_android 요즘엔 회원가입 로그인 절차보다 소셜로그인에 많이 의존을 하곤 한다. 실제로 소셜 로그인으로 했을때 접..
thenicesj.tistory.com
이번엔 naver login ios 구현이다.
역시 https://pub.dev/packages/flutter_naver_login
flutter_naver_login | Flutter Package
A Flutter plugin for using the native Naver Login SDKs on Android and iOS.
pub.dev
사이트를 참조하도록 한다.
- 시작하려면 네이버 developers사이트에서 ios 환경 추가
https://developers.naver.com/apps/#/list
애플리케이션 - NAVER Developers
developers.naver.com
거기엔 다운로드url과 url schema를 적어야하는데
- 나중에 배포를 할시에는 다운받을수 있는 url을 적고(appstore가 되겠지?) url스키마 이름을 적어준다.
이미 안드로이드에서 다 설정을 해놔서 ios부분만 설정을 하면 된다.
ios폴더에 들어가면 Podfile 에서 맨윗부분 주석에 ios버전이 9로 되어있는데
- 안드로이드 minsdk 설정한것처럼 12로 올려준다.
- 다음은 Info.plist 파일 변경과 AppDelegate.m파일만 변경해주면 된다.
Info.plist 파일 먼저 설명하면
네이버 developers에서도 코드를 참조 하라는 사이트인
https://github.com/yoonjaepark/flutter_naver_login/blob/master/example/ios/Runner/Info.plist
에 들어가면 다음과 같이 코드가 되어있다.
나는 그대로 옮겼다.
<?xml version="1.0" encoding="UTF-8"?>
http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
///<string>ios</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>$(FLUTTER_BUILD_NAME)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
/// <string>ios</string>
<key>CFBundleURLSchemes</key>
<array>
/// <string>ios</string>
</array>
</dict>
</array>
<key>CFBundleVersion</key>
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>naversearchapp</string>
<string>naversearchthirdlogin</string>
</array>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>naver.com</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
<key>naver.net</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
</dict>
</dict>
<key>UIBackgroundModes</key>
<array>
<string>fetch</string>
<string>remote-notification</string>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>kConsumerKey</key>
///<string>client_id</string>
<key>kConsumerSecret</key>
///<string>client_secret</string>
<key>kServiceAppName</key>
///<string>ios</string>
<key>kServiceAppUrlScheme</key>
///<string>ios</string>
</dict>
</plist>
엄청 길지만
앞부분에 주석처럼 ///달아준 7곳만 변경하면 된다.
위에 3개는 앱네임을 작성했고 아래 4곳은 네이버 developers에서 알맞게 변경하면 된다.
다음은 두번째 변경할 AppDelegate.m파일이다.
원래는 swift로 작성하려고 했으나 readme에 있는 코드를 적용해도 잘 되질 않아서....일단은 object-c로 구현했다.
readme에서 처럼 임포트 하고 코드 적어주면 되는데 최종 코드는
이렇게 된다.
이렇게 하면 ios에서도 가능하다.
'IT > Flutter' 카테고리의 다른 글
[sociallogin] kakao login구현_android (2) | 2021.11.25 |
---|---|
[sociallogin] google login구현_ios (2) | 2021.11.25 |
[sociallogin] google login구현_android (4) | 2021.11.25 |
[sociallogin] naver login구현_android (4) | 2021.11.25 |
flutter 외부 이미지 사용법 (6) | 2021.11.23 |
댓글