반응형
애플 SDK 설치
- 코드 작성
using System.Collections;
using System.Text;
#if UNITY_IOS
using AppleAuth;
using AppleAuth.Native;
using AppleAuth.Enums;
using AppleAuth.Interfaces;
using AppleAuth.Extensions;
#endif
using UnityEngine;
public class AppleLogin : MonoBehaviour
{
#if UNITY_IOS
private const string AppleUserIdKey = "AppleUserId";
private IAppleAuthManager _appleAuthManager;
#endif
void Awake()
{
#if UNITY_IOS
IOSActivate();
#endif
}
#if UNITY_IOS
private void IOSActivate() //애플 로그인 초기화
{
if (AppleAuthManager.IsCurrentPlatformSupported)
{
var deserializer = new PayloadDeserializer();
_appleAuthManager = new AppleAuthManager(deserializer);
}
StartCoroutine(AppleAuthUpdate());
}
IEnumerator AppleAuthUpdate()
{
while (true)
{
_appleAuthManager?.Update();
yield return null;
}
}
#endif
#if UNITY_IOS
public void OnClickAppleLogin() //애플 로그인 버튼
{
Debug.Log("애플 로그인 시도");
SignInWithApple();
}
void SignInWithApple()
{
var loginArgs = new AppleAuthLoginArgs(LoginOptions.IncludeEmail | LoginOptions.IncludeFullName);
_appleAuthManager.LoginWithAppleId(
loginArgs,
credential =>
{
Debug.Log("Apple Login Success!");
}, error =>
{
var authorizationErrorCode = error.GetAuthorizationErrorCode();
});
}
#endif
}
반응형
'개발 > C#' 카테고리의 다른 글
유니티 C# 베터리 잔량 가져오기 Battery 간단 사용법 (0) | 2022.08.25 |
---|---|
유니티 C# 로컬 푸시 알림 Local Push Notification 간단 구현 (0) | 2022.08.17 |
유니티 C# 부모 자식 오브젝트 가져오기 GetChild 간단 사용법 (0) | 2022.08.17 |
유니티 C# 리소스 로드 Resource.Load 함수 간단 사용법 (0) | 2022.08.17 |
유니티 C# 비속어 필터 적용 inputfield 간단 사용법 (0) | 2022.07.14 |
유니티 C# 디버그 로그 종류 Debug.Log 간단 사용법 (0) | 2022.07.13 |
유니티 C# 자주 사용하는 연산자 Operator 모음 (0) | 2022.07.13 |
유니티 C# 구글 스프레드 시트 Google Sheet 간단 사용법 (0) | 2022.07.13 |
댓글