Pacote do SQLite
- Adicione o pacote
sqlite-net-pcl
e suas dependências:
Lista de pacotes após inseridos:
Código<PackageReference Include="sqlite-net-pcl" Version="1.8.116" /> <PackageReference Include="SQLitePCLRaw.bundle_green" Version="2.1.2" /> <PackageReference Include="SQLitePCLRaw.core" Version="2.1.2" /> <PackageReference Include="SQLitePCLRaw.provider.dynamic_cdecl" Version="2.1.2" /> <PackageReference Include="SQLitePCLRaw.provider.sqlite3" Version="2.1.2" />
No iOS é necessário definir o provedor do SQLite no arquivo
AppDelegate.cs:
Códigoprotected override MauiApp CreateMauiApp() { raw.SetProvider(new SQLite3Provider_sqlite3()); return MauiProgram.CreateMauiApp(); }
Pacote do Firebase
Adicione o pacote Plugin.Firebase ( >= 1.2.0) no nuget. Depois os arquivos
GoogleService-Info.plist
egoogle-services.json
à pasta raiz do projeto e inclua-os no arquivo .csproj dessa forma:Código<ItemGroup Condition="'$(TargetFramework)' == 'net6.0-android'"> <GoogleServicesJson Include="google-services.json" /> </ItemGroup> <ItemGroup Condition="'$(TargetFramework)' == 'net6.0-ios'"> <BundleResource Include="GoogleService-Info.plist" /> </ItemGroup>
Coloque a chamada de inicialização no arquivo
MauiProgram.cs (linha 15)
:Código#if IOS using Plugin.Firebase.iOS; #else using Plugin.Firebase.Android; #endif public static class MauiProgram { public static MauiApp CreateMauiApp() { return MauiApp .CreateBuilder() .UseMauiApp<App>() ... .RegisterFirebaseServices() .Build(); } private static MauiAppBuilder RegisterFirebaseServices(this MauiAppBuilder builder) { builder.ConfigureLifecycleEvents(events => { #if IOS events.AddiOS(iOS => iOS.FinishedLaunching((app, launchOptions) => { CrossFirebase.Initialize(app, launchOptions, CreateCrossFirebaseSettings()); return false; })); #else events.AddAndroid(android => android.OnCreate((activity, state) => CrossFirebase.Initialize(activity, state, CreateCrossFirebaseSettings()))); #endif }); builder.Services.AddSingleton(_ => CrossFirebaseAuth.Current); return builder; } private static CrossFirebaseSettings CreateCrossFirebaseSettings() { return new CrossFirebaseSettings(isAuthEnabled: true); } }
Adicione o seguinte
ItemGroup
ao arquivo.csproj
para evitar erros de compilação:Código<ItemGroup Condition="'$(TargetFramework)' == 'net6.0-android'"> <PackageReference Include="Xamarin.Kotlin.StdLib.Jdk7" Version="1.7.10" ExcludeAssets="build;buildTransitive" /> <PackageReference Include="Xamarin.Kotlin.StdLib.Jdk8" Version="1.7.10" ExcludeAssets="build;buildTransitive" /> </ItemGroup>
Visão Geral
Import HTML Content
Conteúdo das Ferramentas
Tarefas