benxu.AppPlatform.Firebase.Auth
3.0.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package benxu.AppPlatform.Firebase.Auth --version 3.0.0
NuGet\Install-Package benxu.AppPlatform.Firebase.Auth -Version 3.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="benxu.AppPlatform.Firebase.Auth" Version="3.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="benxu.AppPlatform.Firebase.Auth" Version="3.0.0" />
<PackageReference Include="benxu.AppPlatform.Firebase.Auth" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add benxu.AppPlatform.Firebase.Auth --version 3.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: benxu.AppPlatform.Firebase.Auth, 3.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package benxu.AppPlatform.Firebase.Auth@3.0.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=benxu.AppPlatform.Firebase.Auth&version=3.0.0
#tool nuget:?package=benxu.AppPlatform.Firebase.Auth&version=3.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
benxu.AppPlatform.Firebase.Auth
Firebase Authentication 實作套件 - 使用官方/社群套件 (Plugin.FirebaseAuth) 提供各平台的原生認證功能。
特色
- 真實 Firebase 整合:使用
Plugin.FirebaseAuth進行原生 API 呼叫。 - Google 登入:支援 Android/iOS 平台原生 Google 登入 (
GoogleSignInHelper)。 - Email/Password:完整的註冊、登入、密碼重設流程。
- 自動 Token 刷新:背景服務自動刷新 Access Token。
- 狀態同步:自動將認證狀態同步至
IAppStateManager。
支援平台
- ✅ Android (支援 Email/Password,Google 登入)
- ✅ iOS (支援 Email/Password,Google 登入)
安裝
安裝套件:
dotnet add package benxu.AppPlatform.Firebase.Auth平台設定:
- Android: 需將
google-services.json放置於Platforms/Android並設定 Build Action 為GoogleServicesJson。 - iOS: 需將
GoogleService-Info.plist放置於Platforms/iOS並設定 Build Action 為BundleResource。
- Android: 需將
使用方式
1. 註冊服務
在 MauiProgram.cs 中:
using benxu.AppPlatform.MAUI.Bootstrap.Extensions;
builder.UseAppPlatform(options =>
{
options.UseFirebaseAuth(auth =>
{
auth.EnableAutoTokenRefresh = true;
// Android Google 登入設定
auth.GoogleWebClientId = "YOUR_WEB_CLIENT_ID.apps.googleusercontent.com";
auth.GoogleRedirectUri = "com.googleusercontent.apps.YOUR_CLIENT_ID:/oauth2redirect";
});
});
2. 使用認證功能
@inject IAuthService AuthService
@code {
private async Task Login()
{
// Google 登入 (Android)
var result = await AuthService.SignInWithGoogleAsync();
// 或 Email 登入
// var result = await AuthService.SignInWithEmailAsync("user@example.com", "123456");
if (result.IsSuccess)
{
Console.WriteLine($"使用者: {result.Data.User.Email}");
}
}
}
注意事項
- 模擬模式 (Simulator Mode):目前尚未實作,設定
options.SimulatorMode = true目前不會啟用模擬服務,請使用真實裝置或模擬器進行測試。 - Google 登入:Android 與 iOS 皆已實作,使用 WebAuthenticator 進行 OAuth 流程。
依賴項目
Plugin.FirebaseAuthbenxu.AppPlatform.Core
授權
MIT License - Copyright (c) 2025 benxu
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0-android36.0 is compatible. net10.0-ios26.0 is compatible. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0-android36.0
- benxu.AppPlatform.Core (>= 3.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- Microsoft.Maui.Controls (>= 10.0.0)
- Plugin.FirebaseAuth (>= 4.1.0)
- Xamarin.AndroidX.Activity (>= 1.10.1.3)
- Xamarin.AndroidX.Activity.Ktx (>= 1.10.1.3)
- Xamarin.AndroidX.Collection (>= 1.5.0.3)
- Xamarin.AndroidX.Collection.Jvm (>= 1.5.0.3)
- Xamarin.AndroidX.Collection.Ktx (>= 1.5.0.3)
- Xamarin.Build.Download (>= 0.11.4)
-
net10.0-ios26.0
- benxu.AppPlatform.Core (>= 3.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- Microsoft.Maui.Controls (>= 10.0.0)
- Plugin.FirebaseAuth (>= 4.1.0)
- Xamarin.Build.Download (>= 0.11.4)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on benxu.AppPlatform.Firebase.Auth:
| Package | Downloads |
|---|---|
|
benxu.AppPlatform.MAUI.Bootstrap
Bootstrap package for benxu App Platform. Provides fluent API for one-line service registration and lifecycle management. |
GitHub repositories
This package is not used by any popular GitHub repositories.