benxu.AppPlatform.Firebase.Auth
3.0.2
dotnet add package benxu.AppPlatform.Firebase.Auth --version 3.0.2
NuGet\Install-Package benxu.AppPlatform.Firebase.Auth -Version 3.0.2
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.2" />
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.2" />
<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.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: benxu.AppPlatform.Firebase.Auth, 3.0.2"
#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.2
#: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.2
#tool nuget:?package=benxu.AppPlatform.Firebase.Auth&version=3.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
benxu.AppPlatform.Firebase.Auth
Firebase Authentication 實作套件 - 使用 Plugin.Firebase.Auth v4.0.0 提供各平台的原生認證功能。
特色
- 真實 Firebase 整合:使用
Plugin.Firebase.Authv4.0.0 進行原生 API 呼叫。 - Google 登入:整合原生 Firebase SDK 實現跨平台 Google 登入(Android: Xamarin.Firebase.Auth,iOS: AdamE.Firebase.iOS.Auth)。
- Email/Password 登入:完整支援 Firebase Email/Password 認證,包含註冊、登入、密碼重設流程。
- 自動 Token 刷新:背景服務自動刷新 Access Token,確保無縫使用體驗。
- 狀態同步:自動將認證狀態同步至
IAppStateManager,與應用程式狀態管理整合。 - 狀態持久化:應用程式重啟後自動恢復登入狀態。
支援平台
- ✅ Android (完整支援 Email/Password,Google 登入使用原生 SDK)
- ✅ iOS (完整支援 Email/Password,Google 登入使用原生 SDK,最低版本 iOS 15.0)
安裝
安裝套件:
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,且必須指定LogicalName="GoogleService-Info.plist"。 - iOS 初始化: 在
AppDelegate.cs的FinishedLaunching方法中呼叫Firebase.Core.App.Configure()。
- 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}");
}
}
}
注意事項
- Plugin.Firebase.Auth v4.0.0 變更:Google/Facebook/Apple 認證提供者已移除內建支援,本套件已整合原生 Firebase SDK 實現 Google 登入功能。
- Google 登入:Android 與 iOS 皆已實作,使用 WebAuthenticator 進行 OAuth 流程,並透過原生 SDK 完成 Firebase 認證。
- iOS 最低版本:iOS 15.0+(Plugin.Firebase v4.0.0 要求)
依賴項目
Plugin.Firebase.Auth(v4.0.0)Plugin.Firebase.Core(v4.0.0)Xamarin.Firebase.Auth(Android 原生 SDK)AdamE.Firebase.iOS.Auth(iOS 原生 SDK)benxu.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.2)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- Microsoft.Maui.Controls (>= 10.0.0)
- Plugin.Firebase.Auth (>= 4.0.0)
- Plugin.Firebase.Core (>= 4.0.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)
- Xamarin.Firebase.Auth (>= 124.0.0)
-
net10.0-ios26.0
- AdamE.Firebase.iOS.Auth (>= 12.5.0.4)
- benxu.AppPlatform.Core (>= 3.0.2)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- Microsoft.Maui.Controls (>= 10.0.0)
- Plugin.Firebase.Auth (>= 4.0.0)
- Plugin.Firebase.Core (>= 4.0.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.