Skip to content

Commit 3f826e9

Browse files
authored
Add SetDebugToken, and Instance properties (#693)
1 parent fcdbf7f commit 3f826e9

File tree

4 files changed

+61
-43
lines changed

4 files changed

+61
-43
lines changed

app_check/src/AppAttestProviderFactory.cs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,22 @@ private void ThrowIfNull() {
4848
* Gets an instance of this class for installation into a
4949
* FirebaseAppCheck instance.
5050
*/
51-
public static AppAttestProviderFactory GetInstance() {
52-
if (s_factoryInstance != null) {
53-
return s_factoryInstance;
54-
}
51+
public static AppAttestProviderFactory Instance {
52+
get {
53+
if (s_factoryInstance != null) {
54+
return s_factoryInstance;
55+
}
5556

56-
// Get the C++ Factory, and wrap it
57-
AppAttestProviderFactoryInternal factoryInternal = AppAttestProviderFactoryInternal.GetInstance();
58-
// The returned factory can be null, if the platform isn't supported.
59-
if (factoryInternal == null) {
60-
throw new FirebaseException((int)AppCheckError.UnsupportedProvider,
61-
"App Attest is only supported on iOS+ platforms.");
57+
// Get the C++ Factory, and wrap it
58+
AppAttestProviderFactoryInternal factoryInternal = AppAttestProviderFactoryInternal.GetInstance();
59+
// The returned factory can be null, if the platform isn't supported.
60+
if (factoryInternal == null) {
61+
throw new FirebaseException((int)AppCheckError.UnsupportedProvider,
62+
"App Attest is only supported on iOS+ platforms.");
63+
}
64+
s_factoryInstance = new AppAttestProviderFactory(factoryInternal);
65+
return s_factoryInstance;
6266
}
63-
s_factoryInstance = new AppAttestProviderFactory(factoryInternal);
64-
return s_factoryInstance;
6567
}
6668

6769
/**

app_check/src/DebugAppCheckProviderFactory.cs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,17 @@ private void ThrowIfNull() {
5353
* Gets an instance of this class for installation into a
5454
* FirebaseAppCheck instance.
5555
*/
56-
public static DebugAppCheckProviderFactory GetInstance() {
57-
if (s_factoryInstance != null) {
56+
public static DebugAppCheckProviderFactory Instance {
57+
get {
58+
if (s_factoryInstance != null) {
59+
return s_factoryInstance;
60+
}
61+
62+
// Get the C++ Factory, and wrap it
63+
DebugAppCheckProviderFactoryInternal factoryInternal = DebugAppCheckProviderFactoryInternal.GetInstance();
64+
s_factoryInstance = new DebugAppCheckProviderFactory(factoryInternal);
5865
return s_factoryInstance;
5966
}
60-
61-
// Get the C++ Factory, and wrap it
62-
DebugAppCheckProviderFactoryInternal factoryInternal = DebugAppCheckProviderFactoryInternal.GetInstance();
63-
s_factoryInstance = new DebugAppCheckProviderFactory(factoryInternal);
64-
return s_factoryInstance;
6567
}
6668

6769
/**
@@ -80,6 +82,16 @@ public IAppCheckProvider CreateProvider(FirebaseApp app) {
8082
providerMap[app.Name] = provider;
8183
return provider;
8284
}
85+
86+
/**
87+
* Sets the Debug Token to use when communicating with the backend.
88+
* This should match a debug token set in the Firebase console for your
89+
* App.
90+
*/
91+
public void SetDebugToken(string token) {
92+
ThrowIfNull();
93+
factoryInternal.SetDebugToken(token);
94+
}
8395
}
8496

8597
}

app_check/src/DeviceCheckProviderFactory.cs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,22 @@ private void ThrowIfNull() {
4848
* Gets an instance of this class for installation into a
4949
* FirebaseAppCheck instance.
5050
*/
51-
public static DeviceCheckProviderFactory GetInstance() {
52-
if (s_factoryInstance != null) {
53-
return s_factoryInstance;
54-
}
51+
public static DeviceCheckProviderFactory Instance {
52+
get {
53+
if (s_factoryInstance != null) {
54+
return s_factoryInstance;
55+
}
5556

56-
// Get the C++ Factory, and wrap it
57-
DeviceCheckProviderFactoryInternal factoryInternal = DeviceCheckProviderFactoryInternal.GetInstance();
58-
// The returned factory can be null, if the platform isn't supported.
59-
if (factoryInternal == null) {
60-
throw new FirebaseException((int)AppCheckError.UnsupportedProvider,
61-
"Device Check is only supported on iOS+ platforms.");
57+
// Get the C++ Factory, and wrap it
58+
DeviceCheckProviderFactoryInternal factoryInternal = DeviceCheckProviderFactoryInternal.GetInstance();
59+
// The returned factory can be null, if the platform isn't supported.
60+
if (factoryInternal == null) {
61+
throw new FirebaseException((int)AppCheckError.UnsupportedProvider,
62+
"Device Check is only supported on iOS+ platforms.");
63+
}
64+
s_factoryInstance = new DeviceCheckProviderFactory(factoryInternal);
65+
return s_factoryInstance;
6266
}
63-
s_factoryInstance = new DeviceCheckProviderFactory(factoryInternal);
64-
return s_factoryInstance;
6567
}
6668

6769
/**

app_check/src/PlayIntegrityProviderFactory.cs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,22 @@ private void ThrowIfNull() {
4848
* Gets an instance of this class for installation into a
4949
* FirebaseAppCheck instance.
5050
*/
51-
public static PlayIntegrityProviderFactory GetInstance() {
52-
if (s_factoryInstance != null) {
53-
return s_factoryInstance;
54-
}
51+
public static PlayIntegrityProviderFactory Instance {
52+
get {
53+
if (s_factoryInstance != null) {
54+
return s_factoryInstance;
55+
}
5556

56-
// Get the C++ Factory, and wrap it
57-
PlayIntegrityProviderFactoryInternal factoryInternal = PlayIntegrityProviderFactoryInternal.GetInstance();
58-
// The returned factory can be null, if the platform isn't supported.
59-
if (factoryInternal == null) {
60-
throw new FirebaseException((int)AppCheckError.UnsupportedProvider,
61-
"Play Integrity is only supported on Android platforms.");
57+
// Get the C++ Factory, and wrap it
58+
PlayIntegrityProviderFactoryInternal factoryInternal = PlayIntegrityProviderFactoryInternal.GetInstance();
59+
// The returned factory can be null, if the platform isn't supported.
60+
if (factoryInternal == null) {
61+
throw new FirebaseException((int)AppCheckError.UnsupportedProvider,
62+
"Play Integrity is only supported on Android platforms.");
63+
}
64+
s_factoryInstance = new PlayIntegrityProviderFactory(factoryInternal);
65+
return s_factoryInstance;
6266
}
63-
s_factoryInstance = new PlayIntegrityProviderFactory(factoryInternal);
64-
return s_factoryInstance;
6567
}
6668

6769
/**

0 commit comments

Comments
 (0)