Visitar URL original
feat(auth): support for `linkDomain` in `ActionCodeSettings` (#17099) · firebase/flutterfire@090cdb2 · GitHub
Skip to content

Commit 090cdb2

Browse files
feat(auth): support for linkDomain in ActionCodeSettings (#17099)
Co-authored-by: russellwheatley <russellwheatley85@gmail.com>
1 parent ca28c30 commit 090cdb2

20 files changed

Lines changed: 131 additions & 15 deletions

File tree

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ generated_plugins.cmake
4848
build/
4949
.flutter-plugins
5050
.flutter-plugins-dependencies
51+
.cxx/
5152

5253
.project
5354
.classpath

‎docs/auth/email-link-auth.md‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ To initiate the authentication flow, present an interface that prompts the user
5656

5757
* `handleCodeInApp`: Set to `true`. The sign-in operation has to always be completed in the app unlike other out of band email actions (password reset and email verifications). This is because, at the end of the flow, the user is expected to be signed in and their Auth state persisted within the app.
5858

59-
* `dynamicLinkDomain`: When multiple custom dynamic link domains are defined for a project, specify which one to use when the link is to be opened via a specified mobile app (for example, `example.page.link`). Otherwise the first domain is automatically selected.
59+
* `dynamicLinkDomain`: (Deprecated, use `linkDomain`) When multiple custom dynamic link domains are defined for a project, specify which one to use when the link is to be opened via a specified mobile app (for example, `example.page.link`). Otherwise the first domain is automatically selected.
60+
61+
* `linkDomain`: The optional custom Firebase Hosting domain to use when the link is to be opened via a specified mobile app. The domain must be configured in Firebase Hosting and owned by the project. This cannot be a default Hosting domain (`web.app` or `firebaseapp.com`). This replaces the deprecated `dynamicLinkDomain` setting.
6062

6163
```dart
6264
var acs = ActionCodeSettings(
@@ -73,9 +75,9 @@ To initiate the authentication flow, present an interface that prompts the user
7375
androidMinimumVersion: '12');
7476
```
7577
76-
1. Ask the user for their email.
78+
2. Ask the user for their email.
7779
78-
1. Send the authentication link to the user's email, and save the user's email in case the user completes the email sign-in on the same device.
80+
3. Send the authentication link to the user's email, and save the user's email in case the user completes the email sign-in on the same device.
7981
8082
```dart
8183
var emailAuth = 'someemail@domain.com';

‎docs/auth/passing-state-in-email-actions.md‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,14 @@ following parameters:
105105
<tr>
106106
<td><code>dynamicLinkDomain</code></td>
107107
<td>String</td>
108-
<td>Sets the dynamic link domain (or subdomain) to use for the current link
108+
<td>(Deprecated, use `linkDomain`) Sets the dynamic link domain (or subdomain) to use for the current link
109109
if it is to be opened using Firebase Dynamic Links. As multiple dynamic
110110
link domains can be configured per project, this field provides the
111111
ability to explicitly choose one. If none is provided, the first domain
112112
is used by default.</td>
113+
<td><code>linkDomain</code></td>
114+
<td>String</td>
115+
<td>The optional custom Firebase Hosting domain to use when the link is to be opened via a specified mobile app. The domain must be configured in Firebase Hosting and owned by the project. This cannot be a default Hosting domain (`web.app` or `firebaseapp.com`). This replaces the deprecated `dynamicLinkDomain` setting.</td>
113116
</tr>
114117
</table>
115118

‎packages/firebase_auth/firebase_auth/android/src/main/java/io/flutter/plugins/firebase/auth/GeneratedAndroidFirebaseAuth.java‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1406,6 +1406,16 @@ public void setAndroidMinimumVersion(@Nullable String setterArg) {
14061406
this.androidMinimumVersion = setterArg;
14071407
}
14081408

1409+
private @Nullable String linkDomain;
1410+
1411+
public @Nullable String getLinkDomain() {
1412+
return linkDomain;
1413+
}
1414+
1415+
public void setLinkDomain(@Nullable String setterArg) {
1416+
this.linkDomain = setterArg;
1417+
}
1418+
14091419
/** Constructor is non-public to enforce null safety; use Builder. */
14101420
PigeonActionCodeSettings() {}
14111421

@@ -1467,6 +1477,14 @@ public static final class Builder {
14671477
return this;
14681478
}
14691479

1480+
private @Nullable String linkDomain;
1481+
1482+
@CanIgnoreReturnValue
1483+
public @NonNull Builder setLinkDomain(@Nullable String setterArg) {
1484+
this.linkDomain = setterArg;
1485+
return this;
1486+
}
1487+
14701488
public @NonNull PigeonActionCodeSettings build() {
14711489
PigeonActionCodeSettings pigeonReturn = new PigeonActionCodeSettings();
14721490
pigeonReturn.setUrl(url);
@@ -1476,20 +1494,22 @@ public static final class Builder {
14761494
pigeonReturn.setAndroidPackageName(androidPackageName);
14771495
pigeonReturn.setAndroidInstallApp(androidInstallApp);
14781496
pigeonReturn.setAndroidMinimumVersion(androidMinimumVersion);
1497+
pigeonReturn.setLinkDomain(linkDomain);
14791498
return pigeonReturn;
14801499
}
14811500
}
14821501

14831502
@NonNull
14841503
ArrayList<Object> toList() {
1485-
ArrayList<Object> toListResult = new ArrayList<Object>(7);
1504+
ArrayList<Object> toListResult = new ArrayList<Object>(8);
14861505
toListResult.add(url);
14871506
toListResult.add(dynamicLinkDomain);
14881507
toListResult.add(handleCodeInApp);
14891508
toListResult.add(iOSBundleId);
14901509
toListResult.add(androidPackageName);
14911510
toListResult.add(androidInstallApp);
14921511
toListResult.add(androidMinimumVersion);
1512+
toListResult.add(linkDomain);
14931513
return toListResult;
14941514
}
14951515

@@ -1509,6 +1529,8 @@ ArrayList<Object> toList() {
15091529
pigeonResult.setAndroidInstallApp((Boolean) androidInstallApp);
15101530
Object androidMinimumVersion = __pigeon_list.get(6);
15111531
pigeonResult.setAndroidMinimumVersion((String) androidMinimumVersion);
1532+
Object linkDomain = __pigeon_list.get(7);
1533+
pigeonResult.setLinkDomain((String) linkDomain);
15121534
return pigeonResult;
15131535
}
15141536
}

‎packages/firebase_auth/firebase_auth/android/src/main/java/io/flutter/plugins/firebase/auth/PigeonParser.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,10 @@ static ActionCodeSettings getActionCodeSettings(
258258
builder.setDynamicLinkDomain(pigeonActionCodeSettings.getDynamicLinkDomain());
259259
}
260260

261+
if (pigeonActionCodeSettings.getLinkDomain() != null) {
262+
builder.setLinkDomain(pigeonActionCodeSettings.getLinkDomain());
263+
}
264+
261265
builder.setHandleCodeInApp(pigeonActionCodeSettings.getHandleCodeInApp());
262266

263267
if (pigeonActionCodeSettings.getAndroidPackageName() != null) {

‎packages/firebase_auth/firebase_auth/example/android/app/build.gradle‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@ android {
3030
namespace = "io.flutter.plugins.firebase.auth.example"
3131
compileSdk = flutter.compileSdkVersion
3232
ndkVersion = flutter.ndkVersion
33-
3433
compileOptions {
3534
sourceCompatibility = JavaVersion.VERSION_1_8
3635
targetCompatibility = JavaVersion.VERSION_1_8
3736
}
37+
kotlinOptions {
38+
jvmTarget = JavaVersion.VERSION_1_8
39+
}
3840

3941
defaultConfig {
4042
applicationId = "io.flutter.plugins.firebase.auth.example"

‎packages/firebase_auth/firebase_auth/example/android/settings.gradle‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ pluginManagement {
1818

1919
plugins {
2020
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
21-
id "com.android.application" version "8.1.0" apply false
21+
id "com.android.application" version "8.2.1" apply false
2222
// START: FlutterFire Configuration
2323
id "com.google.gms.google-services" version "4.3.15" apply false
2424
// END: FlutterFire Configuration
25-
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
25+
id "org.jetbrains.kotlin.android" version "1.9.0" apply false
2626
}
2727

2828
include ":app"

‎packages/firebase_auth/firebase_auth/ios/firebase_auth/Sources/firebase_auth/PigeonParser.m‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ + (FIRActionCodeSettings *_Nullable)parseActionCodeSettings:
133133
codeSettings.dynamicLinkDomain = settings.dynamicLinkDomain;
134134
}
135135

136+
if (settings.linkDomain != nil) {
137+
codeSettings.linkDomain = settings.linkDomain;
138+
}
139+
136140
codeSettings.handleCodeInApp = settings.handleCodeInApp;
137141

138142
if (settings.iOSBundleId != nil) {

‎packages/firebase_auth/firebase_auth/ios/firebase_auth/Sources/firebase_auth/firebase_auth_messages.g.m‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,8 @@ + (instancetype)makeWithUrl:(NSString *)url
508508
iOSBundleId:(nullable NSString *)iOSBundleId
509509
androidPackageName:(nullable NSString *)androidPackageName
510510
androidInstallApp:(BOOL)androidInstallApp
511-
androidMinimumVersion:(nullable NSString *)androidMinimumVersion {
511+
androidMinimumVersion:(nullable NSString *)androidMinimumVersion
512+
linkDomain:(nullable NSString *)linkDomain {
512513
PigeonActionCodeSettings *pigeonResult = [[PigeonActionCodeSettings alloc] init];
513514
pigeonResult.url = url;
514515
pigeonResult.dynamicLinkDomain = dynamicLinkDomain;
@@ -517,6 +518,7 @@ + (instancetype)makeWithUrl:(NSString *)url
517518
pigeonResult.androidPackageName = androidPackageName;
518519
pigeonResult.androidInstallApp = androidInstallApp;
519520
pigeonResult.androidMinimumVersion = androidMinimumVersion;
521+
pigeonResult.linkDomain = linkDomain;
520522
return pigeonResult;
521523
}
522524
+ (PigeonActionCodeSettings *)fromList:(NSArray *)list {
@@ -528,6 +530,7 @@ + (PigeonActionCodeSettings *)fromList:(NSArray *)list {
528530
pigeonResult.androidPackageName = GetNullableObjectAtIndex(list, 4);
529531
pigeonResult.androidInstallApp = [GetNullableObjectAtIndex(list, 5) boolValue];
530532
pigeonResult.androidMinimumVersion = GetNullableObjectAtIndex(list, 6);
533+
pigeonResult.linkDomain = GetNullableObjectAtIndex(list, 7);
531534
return pigeonResult;
532535
}
533536
+ (nullable PigeonActionCodeSettings *)nullableFromList:(NSArray *)list {
@@ -542,6 +545,7 @@ - (NSArray *)toList {
542545
self.androidPackageName ?: [NSNull null],
543546
@(self.androidInstallApp),
544547
self.androidMinimumVersion ?: [NSNull null],
548+
self.linkDomain ?: [NSNull null],
545549
];
546550
}
547551
@end

‎packages/firebase_auth/firebase_auth/ios/firebase_auth/Sources/firebase_auth/include/Public/firebase_auth_messages.g.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,14 +199,16 @@ typedef NS_ENUM(NSUInteger, ActionCodeInfoOperation) {
199199
iOSBundleId:(nullable NSString *)iOSBundleId
200200
androidPackageName:(nullable NSString *)androidPackageName
201201
androidInstallApp:(BOOL)androidInstallApp
202-
androidMinimumVersion:(nullable NSString *)androidMinimumVersion;
202+
androidMinimumVersion:(nullable NSString *)androidMinimumVersion
203+
linkDomain:(nullable NSString *)linkDomain;
203204
@property(nonatomic, copy) NSString *url;
204205
@property(nonatomic, copy, nullable) NSString *dynamicLinkDomain;
205206
@property(nonatomic, assign) BOOL handleCodeInApp;
206207
@property(nonatomic, copy, nullable) NSString *iOSBundleId;
207208
@property(nonatomic, copy, nullable) NSString *androidPackageName;
208209
@property(nonatomic, assign) BOOL androidInstallApp;
209210
@property(nonatomic, copy, nullable) NSString *androidMinimumVersion;
211+
@property(nonatomic, copy, nullable) NSString *linkDomain;
210212
@end
211213

212214
@interface PigeonFirebaseAuthSettings : NSObject

0 commit comments

Comments
 (0)