1- #if ! UNITY_EDITOR && ( UNITY_IOS || UNITY_TVOS )
1+ #if ( ( UNITY_IOS || UNITY_TVOS || UNITY_STANDALONE_OSX ) && ! UNITY_EDITOR )
22#define APPLE_AUTH_MANAGER_NATIVE_IMPLEMENTATION_AVAILABLE
33#endif
44
@@ -21,7 +21,7 @@ public static bool IsCurrentPlatformSupported
2121 get
2222 {
2323#if APPLE_AUTH_MANAGER_NATIVE_IMPLEMENTATION_AVAILABLE
24- return PInvoke . AppleAuth_IOS_IsCurrentPlatformSupported ( ) ;
24+ return PInvoke . AppleAuth_IsCurrentPlatformSupported ( ) ;
2525#else
2626 return false ;
2727#endif
@@ -60,7 +60,7 @@ public void QuickLogin(
6060 successCallback ( response . AppleIDCredential ) ;
6161 } ) ;
6262
63- PInvoke . AppleAuth_IOS_QuickLogin ( requestId , nonce ) ;
63+ PInvoke . AppleAuth_QuickLogin ( requestId , nonce ) ;
6464#else
6565 throw new Exception ( "AppleAuthManager is not supported in this platform" ) ;
6666#endif
@@ -90,7 +90,7 @@ public void LoginWithAppleId(
9090 successCallback ( response . AppleIDCredential ) ;
9191 } ) ;
9292
93- PInvoke . AppleAuth_IOS_LoginWithAppleId ( requestId , ( int ) loginOptions , nonce ) ;
93+ PInvoke . AppleAuth_LoginWithAppleId ( requestId , ( int ) loginOptions , nonce ) ;
9494#else
9595 throw new Exception ( "AppleAuthManager is not supported in this platform" ) ;
9696#endif
@@ -113,7 +113,7 @@ public void GetCredentialState(
113113 successCallback ( response . CredentialState ) ;
114114 } ) ;
115115
116- PInvoke . AppleAuth_IOS_GetCredentialState ( requestId , userId ) ;
116+ PInvoke . AppleAuth_GetCredentialState ( requestId , userId ) ;
117117#else
118118 throw new Exception ( "AppleAuthManager is not supported in this platform" ) ;
119119#endif
@@ -168,7 +168,7 @@ public static event Action<string> NativeCredentialsRevoked
168168 if ( _nativeCredentialsRevoked == null )
169169 {
170170 _credentialsRevokedCallbackId = AddMessageCallback ( false , payload => _nativeCredentialsRevoked . Invoke ( payload ) ) ;
171- PInvoke . AppleAuth_IOS_RegisterCredentialsRevokedCallbackId ( _credentialsRevokedCallbackId ) ;
171+ PInvoke . AppleAuth_RegisterCredentialsRevokedCallbackId ( _credentialsRevokedCallbackId ) ;
172172 }
173173
174174 _nativeCredentialsRevoked += value ;
@@ -185,7 +185,7 @@ public static event Action<string> NativeCredentialsRevoked
185185 {
186186 RemoveMessageCallback ( _credentialsRevokedCallbackId ) ;
187187 _credentialsRevokedCallbackId = 0U ;
188- PInvoke . AppleAuth_IOS_RegisterCredentialsRevokedCallbackId ( 0U ) ;
188+ PInvoke . AppleAuth_RegisterCredentialsRevokedCallbackId ( 0U ) ;
189189 }
190190 }
191191 }
@@ -226,7 +226,7 @@ public static uint AddMessageCallback(bool isSingleUse, Action<string> messageCa
226226 {
227227 if ( ! _initialized )
228228 {
229- PInvoke . AppleAuth_IOS_SetupNativeMessageHandlerCallback ( PInvoke . NativeMessageHandlerCallback ) ;
229+ PInvoke . AppleAuth_SetupNativeMessageHandlerCallback ( PInvoke . NativeMessageHandlerCallback ) ;
230230 _initialized = true ;
231231 }
232232
@@ -277,6 +277,12 @@ public Entry(bool isSingleUseCallback, Action<string> messageCallback)
277277
278278 private static class PInvoke
279279 {
280+ #if UNITY_IOS || UNITY_TVOS
281+ private const string DllName = "__Internal" ;
282+ #elif UNITY_STANDALONE_OSX
283+ private const string DllName = "MacOSAppleAuthManager" ;
284+ #endif
285+
280286 public delegate void NativeMessageHandlerCallbackDelegate ( uint requestId , string payload ) ;
281287
282288 [ AOT . MonoPInvokeCallback ( typeof ( NativeMessageHandlerCallbackDelegate ) ) ]
@@ -294,23 +300,23 @@ public static void NativeMessageHandlerCallback(uint requestId, string payload)
294300 }
295301 }
296302
297- [ System . Runtime . InteropServices . DllImport ( "__Internal" ) ]
298- public static extern bool AppleAuth_IOS_IsCurrentPlatformSupported ( ) ;
303+ [ System . Runtime . InteropServices . DllImport ( DllName ) ]
304+ public static extern bool AppleAuth_IsCurrentPlatformSupported ( ) ;
299305
300- [ System . Runtime . InteropServices . DllImport ( "__Internal" ) ]
301- public static extern void AppleAuth_IOS_SetupNativeMessageHandlerCallback ( NativeMessageHandlerCallbackDelegate callback ) ;
306+ [ System . Runtime . InteropServices . DllImport ( DllName ) ]
307+ public static extern void AppleAuth_SetupNativeMessageHandlerCallback ( NativeMessageHandlerCallbackDelegate callback ) ;
302308
303- [ System . Runtime . InteropServices . DllImport ( "__Internal" ) ]
304- public static extern void AppleAuth_IOS_GetCredentialState ( uint requestId , string userId ) ;
309+ [ System . Runtime . InteropServices . DllImport ( DllName ) ]
310+ public static extern void AppleAuth_GetCredentialState ( uint requestId , string userId ) ;
305311
306- [ System . Runtime . InteropServices . DllImport ( "__Internal" ) ]
307- public static extern void AppleAuth_IOS_LoginWithAppleId ( uint requestId , int loginOptions , string nonceCStr ) ;
312+ [ System . Runtime . InteropServices . DllImport ( DllName ) ]
313+ public static extern void AppleAuth_LoginWithAppleId ( uint requestId , int loginOptions , string nonceCStr ) ;
308314
309- [ System . Runtime . InteropServices . DllImport ( "__Internal" ) ]
310- public static extern void AppleAuth_IOS_QuickLogin ( uint requestId , string nonceCStr ) ;
315+ [ System . Runtime . InteropServices . DllImport ( DllName ) ]
316+ public static extern void AppleAuth_QuickLogin ( uint requestId , string nonceCStr ) ;
311317
312- [ System . Runtime . InteropServices . DllImport ( "__Internal" ) ]
313- public static extern void AppleAuth_IOS_RegisterCredentialsRevokedCallbackId ( uint callbackId ) ;
318+ [ System . Runtime . InteropServices . DllImport ( DllName ) ]
319+ public static extern void AppleAuth_RegisterCredentialsRevokedCallbackId ( uint callbackId ) ;
314320 }
315321#endif
316322 }
0 commit comments