No Description

FIRUser.h 25KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. /*
  2. * Copyright 2017 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <Foundation/Foundation.h>
  17. #import "FIRAuth.h"
  18. #import "FIRAuthDataResult.h"
  19. #import "FIRUserInfo.h"
  20. @class FIRAuthTokenResult;
  21. @class FIRPhoneAuthCredential;
  22. @class FIRUserProfileChangeRequest;
  23. @class FIRUserMetadata;
  24. @protocol FIRAuthUIDelegate;
  25. NS_ASSUME_NONNULL_BEGIN
  26. /** @typedef FIRAuthTokenCallback
  27. @brief The type of block called when a token is ready for use.
  28. @see FIRUser.getIDTokenWithCompletion:
  29. @see FIRUser.getIDTokenForcingRefresh:withCompletion:
  30. @param token Optionally; an access token if the request was successful.
  31. @param error Optionally; the error which occurred - or nil if the request was successful.
  32. @remarks One of: `token` or `error` will always be non-nil.
  33. */
  34. typedef void (^FIRAuthTokenCallback)(NSString *_Nullable token, NSError *_Nullable error)
  35. NS_SWIFT_NAME(AuthTokenCallback);
  36. /** @typedef FIRAuthTokenResultCallback
  37. @brief The type of block called when a token is ready for use.
  38. @see FIRUser.getIDTokenResultWithCompletion:
  39. @see FIRUser.getIDTokenResultForcingRefresh:withCompletion:
  40. @param tokenResult Optionally; an object containing the raw access token string as well as other
  41. useful data pertaining to the token.
  42. @param error Optionally; the error which occurred - or nil if the request was successful.
  43. @remarks One of: `token` or `error` will always be non-nil.
  44. */
  45. typedef void (^FIRAuthTokenResultCallback)(FIRAuthTokenResult *_Nullable tokenResult,
  46. NSError *_Nullable error)
  47. NS_SWIFT_NAME(AuthTokenResultCallback);
  48. /** @typedef FIRUserProfileChangeCallback
  49. @brief The type of block called when a user profile change has finished.
  50. @param error Optionally; the error which occurred - or nil if the request was successful.
  51. */
  52. typedef void (^FIRUserProfileChangeCallback)(NSError *_Nullable error)
  53. NS_SWIFT_NAME(UserProfileChangeCallback);
  54. /** @typedef FIRSendEmailVerificationCallback
  55. @brief The type of block called when a request to send an email verification has finished.
  56. @param error Optionally; the error which occurred - or nil if the request was successful.
  57. */
  58. typedef void (^FIRSendEmailVerificationCallback)(NSError *_Nullable error)
  59. NS_SWIFT_NAME(SendEmailVerificationCallback);
  60. /** @class FIRUser
  61. @brief Represents a user. Firebase Auth does not attempt to validate users
  62. when loading them from the keychain. Invalidated users (such as those
  63. whose passwords have been changed on another client) are automatically
  64. logged out when an auth-dependent operation is attempted or when the
  65. ID token is automatically refreshed.
  66. @remarks This class is thread-safe.
  67. */
  68. NS_SWIFT_NAME(User)
  69. @interface FIRUser : NSObject <FIRUserInfo>
  70. /** @property anonymous
  71. @brief Indicates the user represents an anonymous user.
  72. */
  73. @property(nonatomic, readonly, getter=isAnonymous) BOOL anonymous;
  74. /** @property emailVerified
  75. @brief Indicates the email address associated with this user has been verified.
  76. */
  77. @property(nonatomic, readonly, getter=isEmailVerified) BOOL emailVerified;
  78. /** @property refreshToken
  79. @brief A refresh token; useful for obtaining new access tokens independently.
  80. @remarks This property should only be used for advanced scenarios, and is not typically needed.
  81. */
  82. @property(nonatomic, readonly, nullable) NSString *refreshToken;
  83. /** @property providerData
  84. @brief Profile data for each identity provider, if any.
  85. @remarks This data is cached on sign-in and updated when linking or unlinking.
  86. */
  87. @property(nonatomic, readonly, nonnull) NSArray<id<FIRUserInfo>> *providerData;
  88. /** @property metadata
  89. @brief Metadata associated with the Firebase user in question.
  90. */
  91. @property(nonatomic, readonly, nonnull) FIRUserMetadata *metadata;
  92. /** @fn init
  93. @brief This class should not be instantiated.
  94. @remarks To retrieve the current user, use `FIRAuth.currentUser`. To sign a user
  95. in or out, use the methods on `FIRAuth`.
  96. */
  97. - (instancetype)init NS_UNAVAILABLE;
  98. /** @fn updateEmail:completion:
  99. @brief Updates the email address for the user. On success, the cached user profile data is
  100. updated.
  101. @remarks May fail if there is already an account with this email address that was created using
  102. email and password authentication.
  103. @param email The email address for the user.
  104. @param completion Optionally; the block invoked when the user profile change has finished.
  105. Invoked asynchronously on the main thread in the future.
  106. @remarks Possible error codes:
  107. + `FIRAuthErrorCodeInvalidRecipientEmail` - Indicates an invalid recipient email was
  108. sent in the request.
  109. + `FIRAuthErrorCodeInvalidSender` - Indicates an invalid sender email is set in
  110. the console for this action.
  111. + `FIRAuthErrorCodeInvalidMessagePayload` - Indicates an invalid email template for
  112. sending update email.
  113. + `FIRAuthErrorCodeEmailAlreadyInUse` - Indicates the email is already in use by another
  114. account.
  115. + `FIRAuthErrorCodeInvalidEmail` - Indicates the email address is malformed.
  116. + `FIRAuthErrorCodeRequiresRecentLogin` - Updating a user’s email is a security
  117. sensitive operation that requires a recent login from the user. This error indicates
  118. the user has not signed in recently enough. To resolve, reauthenticate the user by
  119. invoking reauthenticateWithCredential:completion: on FIRUser.
  120. @remarks See `FIRAuthErrors` for a list of error codes that are common to all FIRUser methods.
  121. */
  122. - (void)updateEmail:(NSString *)email completion:(nullable FIRUserProfileChangeCallback)completion
  123. NS_SWIFT_NAME(updateEmail(to:completion:));
  124. /** @fn updatePassword:completion:
  125. @brief Updates the password for the user. On success, the cached user profile data is updated.
  126. @param password The new password for the user.
  127. @param completion Optionally; the block invoked when the user profile change has finished.
  128. Invoked asynchronously on the main thread in the future.
  129. @remarks Possible error codes:
  130. + `FIRAuthErrorCodeOperationNotAllowed` - Indicates the administrator disabled
  131. sign in with the specified identity provider.
  132. + `FIRAuthErrorCodeRequiresRecentLogin` - Updating a user’s password is a security
  133. sensitive operation that requires a recent login from the user. This error indicates
  134. the user has not signed in recently enough. To resolve, reauthenticate the user by
  135. invoking reauthenticateWithCredential:completion: on FIRUser.
  136. + `FIRAuthErrorCodeWeakPassword` - Indicates an attempt to set a password that is
  137. considered too weak. The NSLocalizedFailureReasonErrorKey field in the NSError.userInfo
  138. dictionary object will contain more detailed explanation that can be shown to the user.
  139. @remarks See `FIRAuthErrors` for a list of error codes that are common to all FIRUser methods.
  140. */
  141. - (void)updatePassword:(NSString *)password
  142. completion:(nullable FIRUserProfileChangeCallback)completion
  143. NS_SWIFT_NAME(updatePassword(to:completion:));
  144. #if TARGET_OS_IOS
  145. /** @fn updatePhoneNumberCredential:completion:
  146. @brief Updates the phone number for the user. On success, the cached user profile data is
  147. updated.
  148. @param phoneNumberCredential The new phone number credential corresponding to the phone number
  149. to be added to the Firebase account, if a phone number is already linked to the account this
  150. new phone number will replace it.
  151. @param completion Optionally; the block invoked when the user profile change has finished.
  152. Invoked asynchronously on the main thread in the future.
  153. @remarks Possible error codes:
  154. + `FIRAuthErrorCodeRequiresRecentLogin` - Updating a user’s phone number is a security
  155. sensitive operation that requires a recent login from the user. This error indicates
  156. the user has not signed in recently enough. To resolve, reauthenticate the user by
  157. invoking reauthenticateWithCredential:completion: on FIRUser.
  158. @remarks See `FIRAuthErrors` for a list of error codes that are common to all FIRUser methods.
  159. */
  160. - (void)updatePhoneNumberCredential:(FIRPhoneAuthCredential *)phoneNumberCredential
  161. completion:(nullable FIRUserProfileChangeCallback)completion;
  162. #endif
  163. /** @fn profileChangeRequest
  164. @brief Creates an object which may be used to change the user's profile data.
  165. @remarks Set the properties of the returned object, then call
  166. `FIRUserProfileChangeRequest.commitChangesWithCallback:` to perform the updates atomically.
  167. @return An object which may be used to change the user's profile data atomically.
  168. */
  169. - (FIRUserProfileChangeRequest *)profileChangeRequest NS_SWIFT_NAME(createProfileChangeRequest());
  170. /** @fn reloadWithCompletion:
  171. @brief Reloads the user's profile data from the server.
  172. @param completion Optionally; the block invoked when the reload has finished. Invoked
  173. asynchronously on the main thread in the future.
  174. @remarks May fail with a `FIRAuthErrorCodeRequiresRecentLogin` error code. In this case
  175. you should call `FIRUser.reauthenticateWithCredential:completion:` before re-invoking
  176. `FIRUser.updateEmail:completion:`.
  177. @remarks See `FIRAuthErrors` for a list of error codes that are common to all API methods.
  178. */
  179. - (void)reloadWithCompletion:(nullable FIRUserProfileChangeCallback)completion;
  180. /** @fn reauthenticateWithCredential:completion:
  181. @brief Renews the user's authentication tokens by validating a fresh set of credentials supplied
  182. by the user and returns additional identity provider data.
  183. @param credential A user-supplied credential, which will be validated by the server. This can be
  184. a successful third-party identity provider sign-in, or an email address and password.
  185. @param completion Optionally; the block invoked when the re-authentication operation has
  186. finished. Invoked asynchronously on the main thread in the future.
  187. @remarks If the user associated with the supplied credential is different from the current user,
  188. or if the validation of the supplied credentials fails; an error is returned and the current
  189. user remains signed in.
  190. @remarks Possible error codes:
  191. + `FIRAuthErrorCodeInvalidCredential` - Indicates the supplied credential is invalid.
  192. This could happen if it has expired or it is malformed.
  193. + `FIRAuthErrorCodeOperationNotAllowed` - Indicates that accounts with the
  194. identity provider represented by the credential are not enabled. Enable them in the
  195. Auth section of the Firebase console.
  196. + `FIRAuthErrorCodeEmailAlreadyInUse` - Indicates the email asserted by the credential
  197. (e.g. the email in a Facebook access token) is already in use by an existing account,
  198. that cannot be authenticated with this method. Call fetchProvidersForEmail for
  199. this user’s email and then prompt them to sign in with any of the sign-in providers
  200. returned. This error will only be thrown if the "One account per email address"
  201. setting is enabled in the Firebase console, under Auth settings. Please note that the
  202. error code raised in this specific situation may not be the same on Web and Android.
  203. + `FIRAuthErrorCodeUserDisabled` - Indicates the user's account is disabled.
  204. + `FIRAuthErrorCodeWrongPassword` - Indicates the user attempted reauthentication with
  205. an incorrect password, if credential is of the type EmailPasswordAuthCredential.
  206. + `FIRAuthErrorCodeUserMismatch` - Indicates that an attempt was made to
  207. reauthenticate with a user which is not the current user.
  208. + `FIRAuthErrorCodeInvalidEmail` - Indicates the email address is malformed.
  209. @remarks See `FIRAuthErrors` for a list of error codes that are common to all API methods.
  210. */
  211. - (void)reauthenticateWithCredential:(FIRAuthCredential *)credential
  212. completion:(nullable FIRAuthDataResultCallback)completion;
  213. /** @fn reauthenticateAndRetrieveDataWithCredential:completion:
  214. @brief Please use linkWithCredential:completion: for Objective-C
  215. or link(withCredential:completion:) for Swift instead.
  216. */
  217. - (void)reauthenticateAndRetrieveDataWithCredential:(FIRAuthCredential *)credential
  218. completion:(nullable FIRAuthDataResultCallback)completion
  219. DEPRECATED_MSG_ATTRIBUTE( "Please use reauthenticateWithCredential:completion: for"
  220. " Objective-C or reauthenticate(withCredential:completion:)"
  221. " for Swift instead.");
  222. /** @fn reauthenticateWithProvider:UIDelegate:completion:
  223. @brief Renews the user's authentication using the provided auth provider instance.
  224. @param provider An instance of an auth provider used to initiate the reauthenticate flow.
  225. @param UIDelegate Optionally an instance of a class conforming to the FIRAuthUIDelegate
  226. protocol, this is used for presenting the web context. If nil, a default FIRAuthUIDelegate
  227. will be used.
  228. @param completion Optionally; a block which is invoked when the reauthenticate flow finishes, or
  229. is canceled. Invoked asynchronously on the main thread in the future.
  230. */
  231. - (void)reauthenticateWithProvider:(id<FIRFederatedAuthProvider>)provider
  232. UIDelegate:(nullable id<FIRAuthUIDelegate>)UIDelegate
  233. completion:(nullable FIRAuthDataResultCallback)completion
  234. NS_SWIFT_NAME(reauthenticate(with:uiDelegate:completion:))
  235. API_AVAILABLE(ios(8.0));
  236. /** @fn getIDTokenResultWithCompletion:
  237. @brief Retrieves the Firebase authentication token, possibly refreshing it if it has expired.
  238. @param completion Optionally; the block invoked when the token is available. Invoked
  239. asynchronously on the main thread in the future.
  240. @remarks See `FIRAuthErrors` for a list of error codes that are common to all API methods.
  241. */
  242. - (void)getIDTokenResultWithCompletion:(nullable FIRAuthTokenResultCallback)completion
  243. NS_SWIFT_NAME(getIDTokenResult(completion:));
  244. /** @fn getIDTokenResultForcingRefresh:completion:
  245. @brief Retrieves the Firebase authentication token, possibly refreshing it if it has expired.
  246. @param forceRefresh Forces a token refresh. Useful if the token becomes invalid for some reason
  247. other than an expiration.
  248. @param completion Optionally; the block invoked when the token is available. Invoked
  249. asynchronously on the main thread in the future.
  250. @remarks The authentication token will be refreshed (by making a network request) if it has
  251. expired, or if `forceRefresh` is YES.
  252. @remarks See `FIRAuthErrors` for a list of error codes that are common to all API methods.
  253. */
  254. - (void)getIDTokenResultForcingRefresh:(BOOL)forceRefresh
  255. completion:(nullable FIRAuthTokenResultCallback)completion
  256. NS_SWIFT_NAME(getIDTokenResult(forcingRefresh:completion:));
  257. /** @fn getIDTokenWithCompletion:
  258. @brief Retrieves the Firebase authentication token, possibly refreshing it if it has expired.
  259. @param completion Optionally; the block invoked when the token is available. Invoked
  260. asynchronously on the main thread in the future.
  261. @remarks See `FIRAuthErrors` for a list of error codes that are common to all API methods.
  262. */
  263. - (void)getIDTokenWithCompletion:(nullable FIRAuthTokenCallback)completion
  264. NS_SWIFT_NAME(getIDToken(completion:));
  265. /** @fn getIDTokenForcingRefresh:completion:
  266. @brief Retrieves the Firebase authentication token, possibly refreshing it if it has expired.
  267. @param forceRefresh Forces a token refresh. Useful if the token becomes invalid for some reason
  268. other than an expiration.
  269. @param completion Optionally; the block invoked when the token is available. Invoked
  270. asynchronously on the main thread in the future.
  271. @remarks The authentication token will be refreshed (by making a network request) if it has
  272. expired, or if `forceRefresh` is YES.
  273. @remarks See `FIRAuthErrors` for a list of error codes that are common to all API methods.
  274. */
  275. - (void)getIDTokenForcingRefresh:(BOOL)forceRefresh
  276. completion:(nullable FIRAuthTokenCallback)completion;
  277. /** @fn linkAndRetrieveDataWithCredential:completion:
  278. @brief Please use linkWithCredential:completion: for Objective-C
  279. or link(withCredential:completion:) for Swift instead.
  280. */
  281. - (void)linkAndRetrieveDataWithCredential:(FIRAuthCredential *)credential
  282. completion:(nullable FIRAuthDataResultCallback)completion
  283. DEPRECATED_MSG_ATTRIBUTE("Please use linkWithCredential:completion: for Objective-C "
  284. "or link(withCredential:completion:) for Swift instead.");
  285. /** @fn linkWithCredential:completion:
  286. @brief Associates a user account from a third-party identity provider with this user and
  287. returns additional identity provider data.
  288. @param credential The credential for the identity provider.
  289. @param completion Optionally; the block invoked when the unlinking is complete, or fails.
  290. Invoked asynchronously on the main thread in the future.
  291. @remarks Possible error codes:
  292. + `FIRAuthErrorCodeProviderAlreadyLinked` - Indicates an attempt to link a provider of a
  293. type already linked to this account.
  294. + `FIRAuthErrorCodeCredentialAlreadyInUse` - Indicates an attempt to link with a
  295. credential that has already been linked with a different Firebase account.
  296. + `FIRAuthErrorCodeOperationNotAllowed` - Indicates that accounts with the identity
  297. provider represented by the credential are not enabled. Enable them in the Auth section
  298. of the Firebase console.
  299. @remarks This method may also return error codes associated with updateEmail:completion: and
  300. updatePassword:completion: on FIRUser.
  301. @remarks See `FIRAuthErrors` for a list of error codes that are common to all FIRUser methods.
  302. */
  303. - (void)linkWithCredential:(FIRAuthCredential *)credential
  304. completion:(nullable FIRAuthDataResultCallback)completion;
  305. /** @fn linkWithProvider:UIDelegate:completion:
  306. @brief link the user with the provided auth provider instance.
  307. @param provider An instance of an auth provider used to initiate the link flow.
  308. @param UIDelegate Optionally an instance of a class conforming to the FIRAuthUIDelegate
  309. protocol, this is used for presenting the web context. If nil, a default FIRAuthUIDelegate
  310. will be used.
  311. @param completion Optionally; a block which is invoked when the link flow finishes, or
  312. is canceled. Invoked asynchronously on the main thread in the future.
  313. */
  314. - (void)linkWithProvider:(id<FIRFederatedAuthProvider>)provider
  315. UIDelegate:(nullable id<FIRAuthUIDelegate>)UIDelegate
  316. completion:(nullable FIRAuthDataResultCallback)completion
  317. NS_SWIFT_NAME(link(with:uiDelegate:completion:))
  318. API_AVAILABLE(ios(8.0));
  319. /** @fn unlinkFromProvider:completion:
  320. @brief Disassociates a user account from a third-party identity provider with this user.
  321. @param provider The provider ID of the provider to unlink.
  322. @param completion Optionally; the block invoked when the unlinking is complete, or fails.
  323. Invoked asynchronously on the main thread in the future.
  324. @remarks Possible error codes:
  325. + `FIRAuthErrorCodeNoSuchProvider` - Indicates an attempt to unlink a provider
  326. that is not linked to the account.
  327. + `FIRAuthErrorCodeRequiresRecentLogin` - Updating email is a security sensitive
  328. operation that requires a recent login from the user. This error indicates the user
  329. has not signed in recently enough. To resolve, reauthenticate the user by invoking
  330. reauthenticateWithCredential:completion: on FIRUser.
  331. @remarks See `FIRAuthErrors` for a list of error codes that are common to all FIRUser methods.
  332. */
  333. - (void)unlinkFromProvider:(NSString *)provider
  334. completion:(nullable FIRAuthResultCallback)completion;
  335. /** @fn sendEmailVerificationWithCompletion:
  336. @brief Initiates email verification for the user.
  337. @param completion Optionally; the block invoked when the request to send an email verification
  338. is complete, or fails. Invoked asynchronously on the main thread in the future.
  339. @remarks Possible error codes:
  340. + `FIRAuthErrorCodeInvalidRecipientEmail` - Indicates an invalid recipient email was
  341. sent in the request.
  342. + `FIRAuthErrorCodeInvalidSender` - Indicates an invalid sender email is set in
  343. the console for this action.
  344. + `FIRAuthErrorCodeInvalidMessagePayload` - Indicates an invalid email template for
  345. sending update email.
  346. + `FIRAuthErrorCodeUserNotFound` - Indicates the user account was not found.
  347. @remarks See `FIRAuthErrors` for a list of error codes that are common to all FIRUser methods.
  348. */
  349. - (void)sendEmailVerificationWithCompletion:(nullable FIRSendEmailVerificationCallback)completion;
  350. /** @fn sendEmailVerificationWithActionCodeSettings:completion:
  351. @brief Initiates email verification for the user.
  352. @param actionCodeSettings An `FIRActionCodeSettings` object containing settings related to
  353. handling action codes.
  354. @remarks Possible error codes:
  355. + `FIRAuthErrorCodeInvalidRecipientEmail` - Indicates an invalid recipient email was
  356. sent in the request.
  357. + `FIRAuthErrorCodeInvalidSender` - Indicates an invalid sender email is set in
  358. the console for this action.
  359. + `FIRAuthErrorCodeInvalidMessagePayload` - Indicates an invalid email template for
  360. sending update email.
  361. + `FIRAuthErrorCodeUserNotFound` - Indicates the user account was not found.
  362. + `FIRAuthErrorCodeMissingIosBundleID` - Indicates that the iOS bundle ID is missing when
  363. a iOS App Store ID is provided.
  364. + `FIRAuthErrorCodeMissingAndroidPackageName` - Indicates that the android package name
  365. is missing when the `androidInstallApp` flag is set to true.
  366. + `FIRAuthErrorCodeUnauthorizedDomain` - Indicates that the domain specified in the
  367. continue URL is not whitelisted in the Firebase console.
  368. + `FIRAuthErrorCodeInvalidContinueURI` - Indicates that the domain specified in the
  369. continue URI is not valid.
  370. */
  371. - (void)sendEmailVerificationWithActionCodeSettings:(FIRActionCodeSettings *)actionCodeSettings
  372. completion:(nullable FIRSendEmailVerificationCallback)
  373. completion;
  374. /** @fn deleteWithCompletion:
  375. @brief Deletes the user account (also signs out the user, if this was the current user).
  376. @param completion Optionally; the block invoked when the request to delete the account is
  377. complete, or fails. Invoked asynchronously on the main thread in the future.
  378. @remarks Possible error codes:
  379. + `FIRAuthErrorCodeRequiresRecentLogin` - Updating email is a security sensitive
  380. operation that requires a recent login from the user. This error indicates the user
  381. has not signed in recently enough. To resolve, reauthenticate the user by invoking
  382. reauthenticateWithCredential:completion: on FIRUser.
  383. @remarks See `FIRAuthErrors` for a list of error codes that are common to all FIRUser methods.
  384. */
  385. - (void)deleteWithCompletion:(nullable FIRUserProfileChangeCallback)completion;
  386. @end
  387. /** @class FIRUserProfileChangeRequest
  388. @brief Represents an object capable of updating a user's profile data.
  389. @remarks Properties are marked as being part of a profile update when they are set. Setting a
  390. property value to nil is not the same as leaving the property unassigned.
  391. */
  392. NS_SWIFT_NAME(UserProfileChangeRequest)
  393. @interface FIRUserProfileChangeRequest : NSObject
  394. /** @fn init
  395. @brief Please use `FIRUser.profileChangeRequest`
  396. */
  397. - (instancetype)init NS_UNAVAILABLE;
  398. /** @property displayName
  399. @brief The user's display name.
  400. @remarks It is an error to set this property after calling
  401. `FIRUserProfileChangeRequest.commitChangesWithCallback:`
  402. */
  403. @property(nonatomic, copy, nullable) NSString *displayName;
  404. /** @property photoURL
  405. @brief The user's photo URL.
  406. @remarks It is an error to set this property after calling
  407. `FIRUserProfileChangeRequest.commitChangesWithCallback:`
  408. */
  409. @property(nonatomic, copy, nullable) NSURL *photoURL;
  410. /** @fn commitChangesWithCompletion:
  411. @brief Commits any pending changes.
  412. @remarks This method should only be called once. Once called, property values should not be
  413. changed.
  414. @param completion Optionally; the block invoked when the user profile change has been applied.
  415. Invoked asynchronously on the main thread in the future.
  416. */
  417. - (void)commitChangesWithCompletion:(nullable FIRUserProfileChangeCallback)completion;
  418. @end
  419. NS_ASSUME_NONNULL_END