diff --git a/auth/src/android/auth_android.cc b/auth/src/android/auth_android.cc index e0a9a669cb..58b4c8ce8a 100644 --- a/auth/src/android/auth_android.cc +++ b/auth/src/android/auth_android.cc @@ -676,5 +676,9 @@ void DisableTokenAutoRefresh(AuthData* auth_data) {} void InitializeTokenRefresher(AuthData* auth_data) {} void DestroyTokenRefresher(AuthData* auth_data) {} +AuthError Auth::UseUserAccessGroup(const char* access_group) { + return kAuthErrorUnimplemented; +} + } // namespace auth } // namespace firebase diff --git a/auth/src/auth.cc b/auth/src/auth.cc index b1417f63f1..fc41e2c01c 100644 --- a/auth/src/auth.cc +++ b/auth/src/auth.cc @@ -373,5 +373,14 @@ AUTH_RESULT_FN(Auth, SignInWithEmailAndPassword, AuthResult) AUTH_RESULT_FN(Auth, CreateUserWithEmailAndPassword, AuthResult) +AuthError Auth::UseUserAccessGroup(const char* access_group) { + if (!auth_data_) return kAuthErrorUninitialized; +#if FIREBASE_PLATFORM_IOS + return UseUserAccessGroupInternal(auth_data_, access_group); +#else + return kAuthErrorUnimplemented; +#endif // FIREBASE_PLATFORM_IOS +} + } // namespace auth } // namespace firebase diff --git a/auth/src/desktop/auth_desktop.cc b/auth/src/desktop/auth_desktop.cc index dc9aca2950..10525890a4 100644 --- a/auth/src/desktop/auth_desktop.cc +++ b/auth/src/desktop/auth_desktop.cc @@ -632,6 +632,10 @@ void DestroyUserDataPersist(AuthData* auth_data) { auth_data->auth->RemoveAuthStateListener(auth_impl->user_data_persist.get()); } +AuthError Auth::UseUserAccessGroup(const char* access_group) { + return kAuthErrorUnimplemented; +} + void LoadFinishTriggerListeners(AuthData* auth_data) { MutexLock destructing_lock(auth_data->destructing_mutex); if (auth_data->destructing) { diff --git a/auth/src/include/firebase/auth.h b/auth/src/include/firebase/auth.h index f6809c4a57..fb8c3be530 100644 --- a/auth/src/include/firebase/auth.h +++ b/auth/src/include/firebase/auth.h @@ -497,6 +497,17 @@ class Auth { /// emulator. /// void UseEmulator(std::string host, uint32_t port); + + /// @brief Sets the user access group to use for data sharing. + /// + /// This method is only functional on iOS. On other platforms, it will + /// immediately return kAuthErrorUnimplemented. + /// + /// @param[in] access_group The access group to use. + /// + /// @return kAuthErrorNone on success, or an AuthError code if an error + /// occurred. + AuthError UseUserAccessGroup(const char* access_group); #endif //! defined(DOXYGEN), to hide the api from public documentation. /// Gets the App this auth object is connected to. diff --git a/auth/src/ios/auth_ios.mm b/auth/src/ios/auth_ios.mm index a0292ba3b8..e896d16853 100644 --- a/auth/src/ios/auth_ios.mm +++ b/auth/src/ios/auth_ios.mm @@ -608,5 +608,15 @@ void DisableTokenAutoRefresh(AuthData *auth_data) {} void InitializeTokenRefresher(AuthData *auth_data) {} void DestroyTokenRefresher(AuthData *auth_data) {} +AuthError UseUserAccessGroupInternal(AuthData* auth_data, const char* access_group) { + NSString* access_group_ns_string = access_group ? @(access_group) : nil; + NSError* error = nil; + BOOL success = [AuthImpl(auth_data) useUserAccessGroup:access_group_ns_string error:&error]; + if (!success) { + return AuthErrorFromNSError(error); + } + return kAuthErrorNone; +} + } // namespace auth } // namespace firebase diff --git a/auth/src/ios/common_ios.h b/auth/src/ios/common_ios.h index 797c73686e..7b43b70849 100644 --- a/auth/src/ios/common_ios.h +++ b/auth/src/ios/common_ios.h @@ -137,6 +137,9 @@ void SignInCallback(FIRUser *_Nullable user, NSError *_Nullable error, /// like user interaction errors, they are actually caused by bad provider ids. NSError *RemapBadProviderIDErrors(NSError *_Nonnull error); +// iOS-specific implementation of Auth::UseUserAccessGroup. +AuthError UseUserAccessGroupInternal(AuthData* auth_data, const char* access_group); + } // namespace auth } // namespace firebase