Skip to content

Commit 6eb4cb6

Browse files
committed
add link domain to actionCodeSetting
1 parent 51258b5 commit 6eb4cb6

File tree

4 files changed

+34
-2
lines changed

4 files changed

+34
-2
lines changed

src/main/java/com/google/firebase/auth/ActionCodeSettings.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ private ActionCodeSettings(Builder builder) {
5151
if (!Strings.isNullOrEmpty(builder.dynamicLinkDomain)) {
5252
properties.put("dynamicLinkDomain", builder.dynamicLinkDomain);
5353
}
54+
if (!Strings.isNullOrEmpty(builder.linkDomain)) {
55+
properties.put("linkDomain", builder.linkDomain);
56+
}
5457
if (!Strings.isNullOrEmpty(builder.iosBundleId)) {
5558
properties.put("iOSBundleId", builder.iosBundleId);
5659
}
@@ -83,7 +86,9 @@ public static final class Builder {
8386

8487
private String url;
8588
private boolean handleCodeInApp;
89+
// Deprecated, use linkDomain instead.
8690
private String dynamicLinkDomain;
91+
private String linkDomain;
8792
private String iosBundleId;
8893
private String androidPackageName;
8994
private String androidMinimumVersion;
@@ -135,12 +140,27 @@ public Builder setHandleCodeInApp(boolean handleCodeInApp) {
135140
*
136141
* @param dynamicLinkDomain Firebase Dynamic Link domain string.
137142
* @return This builder.
143+
* @deprecated Use {@link #setLinkDomain(String)} instead.
138144
*/
139145
public Builder setDynamicLinkDomain(String dynamicLinkDomain) {
140146
this.dynamicLinkDomain = dynamicLinkDomain;
141147
return this;
142148
}
143149

150+
/**
151+
* Sets the link domain to use for the current link if it is to be opened using
152+
* HandleCodeInApp, as multiple link domains can be configured per project. This
153+
* setting provides the ability to explicitly choose one. If none is provided, the default
154+
* Firebase Hosting domain will be used.
155+
*
156+
* @param linkDomain Link domain string.
157+
* @return This builder.
158+
*/
159+
public Builder setLinkDomain(String linkDomain) {
160+
this.linkDomain = linkDomain;
161+
return this;
162+
}
163+
144164
/**
145165
* Sets the bundle ID of the iOS app where the link should be handled if the
146166
* application is already installed on the device.

src/main/java/com/google/firebase/auth/AuthErrorCode.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ public enum AuthErrorCode {
5858
*/
5959
INVALID_DYNAMIC_LINK_DOMAIN,
6060

61+
/**
62+
* The provided hosting link domain is not configured or authorized for the current project.
63+
*/
64+
INVALID_HOSTING_LINK_DOMAIN,
65+
6166
/**
6267
* The specified ID token is invalid.
6368
*/

src/main/java/com/google/firebase/auth/internal/AuthErrorHandler.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ final class AuthErrorHandler extends AbstractHttpErrorHandler<FirebaseAuthExcept
7373
"The provided dynamic link domain is not "
7474
+ "configured or authorized for the current project",
7575
AuthErrorCode.INVALID_DYNAMIC_LINK_DOMAIN))
76+
.put(
77+
"INVALID_HOSTING_LINK_DOMAIN",
78+
new AuthError(
79+
ErrorCode.INVALID_ARGUMENT,
80+
"The provided hosting link domain is not "
81+
+ "configured or authorized for the current project",
82+
AuthErrorCode.INVALID_HOSTING_LINK_DOMAIN))
7683
.put(
7784
"PHONE_NUMBER_EXISTS",
7885
new AuthError(

src/test/java/com/google/firebase/auth/ActionCodeSettingsTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public void testAllSettings() {
6767
ActionCodeSettings settings = ActionCodeSettings.builder()
6868
.setUrl("https://example.com")
6969
.setHandleCodeInApp(true)
70-
.setDynamicLinkDomain("myapp.page.link")
70+
.setLinkDomain("myapp.custom.link")
7171
.setIosBundleId("com.example.ios")
7272
.setAndroidPackageName("com.example.android")
7373
.setAndroidMinimumVersion("6.0")
@@ -76,7 +76,7 @@ public void testAllSettings() {
7676
Map<String, Object> expected = ImmutableMap.<String, Object>builder()
7777
.put("continueUrl", "https://example.com")
7878
.put("canHandleCodeInApp", true)
79-
.put("dynamicLinkDomain", "myapp.page.link")
79+
.put("linkDomain", "myapp.custom.link")
8080
.put("iOSBundleId", "com.example.ios")
8181
.put("androidPackageName", "com.example.android")
8282
.put("androidMinimumVersion", "6.0")

0 commit comments

Comments
 (0)