Skip to content

Commit fdb205d

Browse files
authored
BREAKING CHANGE: Deprecating old APIs in Auth (#699)
* Initial change for Auth Google/IO changes to just fix the compiler error (#680) Initial change to make sure Unity SDK can compile against C++ Auth feature branch. Integration test is expected to be broken since it is pointing to C++ main and Unity integration test is not update. This change includes: - Update SWIG postprocess to rename deprecated functions which returns a `Task` - Remove `PhoneAuthProvider.MaxTimeoutMs` - Wire the following function to new C++ impl - `Firebase.Auth.FirebaseAuth.CurrentUser` - `Firebase.Auth.FirebaseUser.ProviderData` - Deprecated the following function - Firebase.Auth.FirebaseAuth.SignInWithCustomTokenAsync_DEPRECATED - Firebase.Auth.FirebaseAuth.SignInWithCredentialAsync_DEPRECATED - Firebase.Auth.FirebaseAuth.SignInAndRetrieveDataWithCredentialAsync_DEPRECATED - Firebase.Auth.FirebaseAuth.SignInAnonymouslyAsync_DEPRECATED - Firebase.Auth.FirebaseAuth.SignInWithEmailAndPasswordAsync_DEPRECATED - Firebase.Auth.FirebaseAuth.CreateUserWithEmailAndPasswordAsync_DEPRECATED - Firebase.Auth.FirebaseAuth.SignInWithProviderAsync_DEPRECATED - Firebase.Auth.FirebaseUser.ReauthenticateWithProviderAsync_DEPRECATED - Firebase.Auth.FirebaseUser.LinkWithProviderAsync_DEPRECATED - Added C# impl for new `PhoneAuthOptions` class - Placeholder impl for `PhoneAuthListenerImpl.OnVerificationCompleted(PhoneAuthCredential)` * Remaining Auth deprecated APIs for Google I/O (#684) Rename and deprecated the following methods - `FirebaseUser.LinkAndRetrieveDataWithCredentialAsync_DEPRECATED()` - `FirebaseUser.LinkWithCredentialAsync_DEPRECATED()` - `FirebaseUser.ReauthenticateAndRetrieveDataAsync_DEPRECATED()` - `FirebaseUser.UnlinkAsync_DEPRECATED()` - `FirebaseUser.UpdatePhoneNumberCredentialAsync_DEPRECATED()` - `PhoneAuthProvider.VerificationCompleted_DEPRECATED` - `PhoneAuthProvider.VerifyPhoneNumber()` - `PhoneAuthProvider.GetCredential_DEPRECATED()`
1 parent 41ee580 commit fdb205d

File tree

9 files changed

+426
-164
lines changed

9 files changed

+426
-164
lines changed

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,13 @@ else()
153153
set(DESKTOP OFF)
154154
endif()
155155

156+
if(APPLE)
157+
# GHA macOS build treats deprecation warning as error (-Werror,-Wdeprecated-declarations)
158+
# This is a quick way to suppress the warning so that the build won't fail.
159+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations")
160+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
161+
endif()
162+
156163
# Define the Python executable before including the subprojects
157164
find_program(FIREBASE_PYTHON_EXECUTABLE
158165
NAMES python3 python

auth/src/PhoneAuthProvider.cs

Lines changed: 55 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ namespace Firebase.Auth {
2525
///
2626
/// This class is not supported on tvOS and Desktop platforms.
2727
///
28-
/// The verification flow results in a Credential that can be used to,
28+
/// The verification flow results in a @ref PhoneAuthCredential that can be
29+
/// used to,
2930
/// * Sign in to an existing phone number account/sign up with a new
3031
/// phone number
3132
/// * Link a phone number to a current user. This provider will be added to
@@ -43,37 +44,32 @@ namespace Firebase.Auth {
4344
/// phone number. App receives verification id via @ref CodeSent.
4445
/// - User receives SMS and enters verification code in app's GUI.
4546
/// - App uses user's verification code to call
46-
/// @ref PhoneAuthProvider::GetCredential.
47+
/// @ref PhoneAuthProvider.GetCredential.
4748
///
4849
/// (2) SMS is automatically retrieved (Android only).
49-
/// - App calls @ref VerifyPhoneNumber with `timeout_ms` > 0.
50+
/// - App calls @ref VerifyPhoneNumber with `autoVerifyTimeOutMs` > 0.
5051
/// - Auth server sends the verification code via SMS to the provided
5152
/// phone number.
5253
/// - SMS arrives and is automatically retrieved by the operating system.
53-
/// Credential is automatically created and passed to the app via
54-
/// @ref VerificationCompleted.
54+
/// @ref PhoneAuthCredential is automatically created and passed to the
55+
/// app via @ref VerificationCompleted.
5556
///
5657
/// (3) Phone number is instantly verified (Android only).
5758
/// - App calls @ref VerifyPhoneNumber.
5859
/// - The operating system validates the phone number without having to
59-
/// send an SMS. Credential is automatically created and passed to
60-
/// the app via @ref VerificationCompleted.
60+
/// send an SMS. @ref PhoneAuthCredential is automatically created and
61+
/// passed to the app via @ref VerificationCompleted.
62+
///
63+
/// Note: Both @ref VerificationCompleted_DEPRECATED and
64+
/// @ref VerificationCompleted will be triggered upon completion. Developer
65+
/// should only use only one of them to prevent duplicated event handling.
6166
public sealed class PhoneAuthProvider : global::System.IDisposable {
62-
/// Maximum value of `autoVerifyTimeOutMs` in @ref VerifyPhoneNumber.
63-
/// @ref VerifyPhoneNumber will automatically clamp values to this amount.
64-
///
65-
/// @deprecated This value is no longer used to clamp
66-
/// `autoVerifyTimeOutMs` in @ref VerifyPhoneNumber. The range is
67-
/// determined by the underlying SDK, ex. <a href="/docs/reference/android/com/google/firebase/auth/PhoneAuthOptions.Builder"><code>PhoneAuthOptions.Build</code> in Android SDK</a>
68-
[System.Obsolete("PhoneAuthProvider.MaxTimeoutMs is deprecated. This value no longer affects PhoneAuthProvider.VerifyPhoneNumber()")]
69-
public static uint MaxTimeoutMs {
70-
get {
71-
return PhoneAuthProviderInternal.kMaxTimeoutMs;
72-
}
73-
}
74-
67+
/// @deprecated This is a deprecated delegate. Please use @ref
68+
/// VerificationCompleted instead.
69+
//
7570
/// Callback used when phone number auto-verification succeeded.
76-
public delegate void VerificationCompleted(Credential credential);
71+
[System.Obsolete("Please use `VerificationCompleted(PhoneAuthCredential)` instead", false)]
72+
public delegate void VerificationCompleted_DEPRECATED(Credential credential);
7773
/// Callback used when phone number verification fails.
7874
public delegate void VerificationFailed(string error);
7975
/// Callback used when a verification code is sent to the given number.
@@ -86,7 +82,7 @@ public delegate void CodeSent(string verificationId,
8682

8783
// Class to hold the delegates the user provides to the verification flow.
8884
private class PhoneAuthDelegates {
89-
public VerificationCompleted verificationCompleted;
85+
public VerificationCompleted_DEPRECATED verificationCompleted;
9086
public VerificationFailed verificationFailed;
9187
public CodeSent codeSent;
9288
public CodeAutoRetrievalTimeOut timeOut;
@@ -103,7 +99,7 @@ private class PhoneAuthDelegates {
10399
/// when the C++ library indicates a callback.
104100
///
105101
/// @return The unique identifier for the cached callbacks.
106-
private static int SaveCallbacks(VerificationCompleted verificationCompleted,
102+
private static int SaveCallbacks(VerificationCompleted_DEPRECATED verificationCompleted,
107103
VerificationFailed verificationFailed,
108104
CodeSent codeSent,
109105
CodeAutoRetrievalTimeOut timeOut) {
@@ -120,8 +116,8 @@ private static int SaveCallbacks(VerificationCompleted verificationCompleted,
120116
return uid;
121117
}
122118

123-
[MonoPInvokeCallback(typeof(PhoneAuthProviderInternal.VerificationCompletedDelegate))]
124-
private static void VerificationCompletedHandler(int callbackId,
119+
[MonoPInvokeCallback(typeof(PhoneAuthProviderInternal.VerificationCompletedDelegate_DEPRECATED))]
120+
private static void VerificationCompleted_DEPRECATEDHandler(int callbackId,
125121
System.IntPtr credential) {
126122
ExceptionAggregator.Wrap(() => {
127123
Credential c = new Credential(credential, true);
@@ -179,10 +175,10 @@ private static void TimeOutHandler(int callbackId, string verificationId) {
179175
});
180176
}
181177

182-
private static PhoneAuthProviderInternal.VerificationCompletedDelegate
183-
verificationCompletedDelegate =
184-
new PhoneAuthProviderInternal.VerificationCompletedDelegate(
185-
VerificationCompletedHandler);
178+
private static PhoneAuthProviderInternal.VerificationCompletedDelegate_DEPRECATED
179+
verificationCompletedDelegate_DEPRECATED =
180+
new PhoneAuthProviderInternal.VerificationCompletedDelegate_DEPRECATED(
181+
VerificationCompleted_DEPRECATEDHandler);
186182
private static PhoneAuthProviderInternal.VerificationFailedDelegate
187183
verificationFailedDelegate =
188184
new PhoneAuthProviderInternal.VerificationFailedDelegate(
@@ -200,13 +196,17 @@ private static PhoneAuthProviderInternal.TimeOutDelegate
200196
private static void InitializeCallbacks() {
201197
if (!callbacksInitialized) {
202198
callbacksInitialized = true;
203-
PhoneAuthProviderInternal.SetCallbacks(verificationCompletedDelegate,
199+
PhoneAuthProviderInternal.SetCallbacks(verificationCompletedDelegate_DEPRECATED,
204200
verificationFailedDelegate,
205201
codeSentDelegate,
206202
timeOutDelegate);
207203
}
208204
}
209205

206+
/// @deprecated This is a deprecated method. Please use @ref
207+
/// VerifyPhoneNumber(PhoneAuthOptions, VerificationCompleted, VerificationFailed, CodeSent,
208+
/// CodeAutoRetrievalTimeOut) instead.
209+
///
210210
/// Start the phone number authentication operation.
211211
///
212212
/// @note The verificationCompleted callback is never invoked on iOS since auto-validation is
@@ -232,15 +232,20 @@ private static void InitializeCallbacks() {
232232
/// @param[in] verificationFailed Phone number verification failed with an
233233
/// error. For example, quota exceeded or unknown phone number format.
234234
/// Provided with a description of the error.
235+
[System.Obsolete("Please use `VerifyPhoneNumber(PhoneAuthOptions, VerificationCompleted, VerificationFailed, CodeSent, CodeAutoRetrievalTimeOut)` instead", false)]
235236
public void VerifyPhoneNumber(string phoneNumber, uint autoVerifyTimeOutMs,
236237
ForceResendingToken forceResendingToken,
237-
VerificationCompleted verificationCompleted,
238+
VerificationCompleted_DEPRECATED verificationCompleted,
238239
VerificationFailed verificationFailed) {
239240
VerifyPhoneNumber(phoneNumber, autoVerifyTimeOutMs, forceResendingToken,
240241
verificationCompleted, verificationFailed,
241242
null, null);
242243
}
243244

245+
/// @deprecated This is a deprecated method. Please use @ref
246+
/// VerifyPhoneNumber(PhoneAuthOptions, VerificationCompleted, VerificationFailed, CodeSent,
247+
/// CodeAutoRetrievalTimeOut) instead.
248+
///
244249
/// Start the phone number authentication operation.
245250
///
246251
/// @note The verificationCompleted callback is never invoked on iOS since auto-validation is
@@ -270,16 +275,21 @@ public void VerifyPhoneNumber(string phoneNumber, uint autoVerifyTimeOutMs,
270275
/// number. Provided with the verification id to pass along to
271276
/// `GetCredential` along with the sent code, and a token to use if
272277
/// the user requests another SMS message be sent.
278+
[System.Obsolete("Please use `VerifyPhoneNumber(PhoneAuthOptions, VerificationCompleted, VerificationFailed, CodeSent, CodeAutoRetrievalTimeOut)` instead", false)]
273279
public void VerifyPhoneNumber(string phoneNumber, uint autoVerifyTimeOutMs,
274280
ForceResendingToken forceResendingToken,
275-
VerificationCompleted verificationCompleted,
281+
VerificationCompleted_DEPRECATED verificationCompleted,
276282
VerificationFailed verificationFailed,
277283
CodeSent codeSent) {
278284
VerifyPhoneNumber(phoneNumber, autoVerifyTimeOutMs, forceResendingToken,
279285
verificationCompleted, verificationFailed,
280286
codeSent, null);
281287
}
282288

289+
/// @deprecated This is a deprecated method. Please use @ref
290+
/// VerifyPhoneNumber(PhoneAuthOptions, VerificationCompleted, VerificationFailed, CodeSent,
291+
/// CodeAutoRetrievalTimeOut) instead.
292+
///
283293
/// Start the phone number authentication operation.
284294
///
285295
/// @note The verificationCompleted callback is never invoked on iOS since auto-validation is
@@ -305,16 +315,21 @@ public void VerifyPhoneNumber(string phoneNumber, uint autoVerifyTimeOutMs,
305315
/// @param[in] verificationFailed Phone number verification failed with an
306316
/// error. For example, quota exceeded or unknown phone number format.
307317
/// Provided with a description of the error.
318+
[System.Obsolete("Please use `VerifyPhoneNumber(PhoneAuthOptions, VerificationCompleted, VerificationFailed, CodeSent, CodeAutoRetrievalTimeOut)` instead", false)]
308319
public void VerifyPhoneNumber(string phoneNumber, uint autoVerifyTimeOutMs,
309320
ForceResendingToken forceResendingToken,
310-
VerificationCompleted verificationCompleted,
321+
VerificationCompleted_DEPRECATED verificationCompleted,
311322
VerificationFailed verificationFailed,
312323
CodeAutoRetrievalTimeOut codeAutoRetrievalTimeOut) {
313324
VerifyPhoneNumber(phoneNumber, autoVerifyTimeOutMs, forceResendingToken,
314325
verificationCompleted, verificationFailed,
315326
null, codeAutoRetrievalTimeOut);
316327
}
317328

329+
/// @deprecated This is a deprecated method. Please use @ref
330+
/// VerifyPhoneNumber(PhoneAuthOptions, VerificationCompleted, VerificationFailed, CodeSent,
331+
/// CodeAutoRetrievalTimeOut) instead.
332+
///
318333
/// Start the phone number authentication operation.
319334
///
320335
/// @note On iOS the verificationCompleted callback is never invoked and the
@@ -347,9 +362,10 @@ public void VerifyPhoneNumber(string phoneNumber, uint autoVerifyTimeOutMs,
347362
/// the user requests another SMS message be sent.
348363
/// @param[in] codeAutoRetrievalTimeOut The timeout specified has expired.
349364
/// Provided with the verification id for the transaction that timed out.
365+
[System.Obsolete("Please use `VerifyPhoneNumber(PhoneAuthOptions, VerificationCompleted, VerificationFailed, CodeSent, CodeAutoRetrievalTimeOut)` instead", false)]
350366
public void VerifyPhoneNumber(string phoneNumber, uint autoVerifyTimeOutMs,
351367
ForceResendingToken forceResendingToken,
352-
VerificationCompleted verificationCompleted,
368+
VerificationCompleted_DEPRECATED verificationCompleted,
353369
VerificationFailed verificationFailed,
354370
CodeSent codeSent,
355371
CodeAutoRetrievalTimeOut codeAutoRetrievalTimeOut) {
@@ -403,6 +419,8 @@ public static PhoneAuthProvider GetInstance(FirebaseAuth auth) {
403419
}
404420
}
405421

422+
/// @deprecated This is a deprecated method. Please use @ref GetCredential instead.
423+
///
406424
/// Generate a credential for the given phone number.
407425
///
408426
/// @param[in] verification_id The id returned when sending the verification
@@ -412,9 +430,10 @@ public static PhoneAuthProvider GetInstance(FirebaseAuth auth) {
412430
/// received in the SMS sent by @ref VerifyPhoneNumber.
413431
///
414432
/// @returns New Credential.
415-
public Credential GetCredential(string verificationId,
433+
[System.Obsolete("Please use `PhoneAuthCredential GetCredential(string, string)` instead", false)]
434+
public Credential GetCredential_DEPRECATED(string verificationId,
416435
string verificationCode) {
417-
return InternalProvider.GetCredential(verificationId, verificationCode);
436+
return InternalProvider.GetCredential_DEPRECATED(verificationId, verificationCode);
418437
}
419438
}
420439

0 commit comments

Comments
 (0)