English 中文(简体)
。 NET MAUI Push 带有防火基云层的信号
原标题:.NET MAUI Push Notifications with Firebase Cloud Mesaging
  • 时间:2023-11-15 11:59:29
  •  标签:
  • c#
  • .net
  • maui

我想利用火基云层的图像实施一个非常简单的推动通知系统。

MAUI项目以8版网络为基础。

I ve subsequently :this Guide for establishing the Project up。

当指南使用时,net6

So my .csproj file looks like this :

<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <TargetFrameworks>net8.0-android;net8.0-ios;</TargetFrameworks>
        <OutputType>Exe</OutputType>
        <RootNamespace>PushNotificationsTest</RootNamespace>
        <UseMaui>true</UseMaui>
        <SingleProject>true</SingleProject>
        <ImplicitUsings>enable</ImplicitUsings>

        <!-- Display name -->
        <ApplicationTitle>PushNotificationsTest</ApplicationTitle>

        <!-- App Identifier -->
        <ApplicationId>com.companyname.pushnotificationstest</ApplicationId>

        <!-- Versions -->
        <ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
        <ApplicationVersion>1</ApplicationVersion>

        <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier( $(TargetFramework) )) ==  ios ">11.0</SupportedOSPlatformVersion>
        <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier( $(TargetFramework) )) ==  android ">21.0</SupportedOSPlatformVersion>
        <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier( $(TargetFramework) )) ==  tizen ">6.5</SupportedOSPlatformVersion>
    </PropertyGroup>

    <ItemGroup>
        <!-- App Icon -->
        <MauiIcon Include="ResourcesAppIconappicon.svg" ForegroundFile="ResourcesAppIconappiconfg.svg" Color="#512BD4" />

        <!-- Splash Screen -->
        <MauiSplashScreen Include="ResourcesSplashsplash.svg" Color="#512BD4" BaseSize="128,128" />

        <!-- Images -->
        <MauiImage Include="ResourcesImages*" />
        <MauiImage Update="ResourcesImagesdotnet_bot.svg" BaseSize="168,208" />

        <!-- Custom Fonts -->
        <MauiFont Include="ResourcesFonts*" />

        <!-- Raw Assets (also remove the "ResourcesRaw" prefix) -->
        <MauiAsset Include="ResourcesRaw**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
    </ItemGroup>

    <ItemGroup Condition=" $(TargetFramework)  ==  net8.0-android ">
        <GoogleServicesJson Include="google-services.json" />
    </ItemGroup>
    
    <ItemGroup>
        <PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
        <PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
        <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0-rc.1.23419.4" />
        <PackageReference Include="Plugin.Firebase" Version="2.0.7" />
        <PackageReference Include="Plugin.FirebaseCrashlytics" Version="4.1.0" />
    </ItemGroup>

    <!-- Build Properties must be defined within these property groups to ensure successful publishing
       to the Mac App Store. See: https://aka.ms/maui-publish-app-store#define-build-properties-in-your-project-file -->
    <PropertyGroup Condition="$(TargetFramework.Contains( -maccatalyst )) and  $(Configuration)  ==  Debug ">
        <CodesignEntitlements>Platforms/MacCatalyst/Entitlements.Debug.plist</CodesignEntitlements>
    </PropertyGroup>

    <PropertyGroup Condition="$(TargetFramework.Contains( -maccatalyst )) and  $(Configuration)  ==  Release ">
        <CodesignEntitlements>Platforms/MacCatalyst/Entitlements.Release.plist</CodesignEntitlements>
        <UseHardenedRuntime>true</UseHardenedRuntime>
    </PropertyGroup>
</Project>

但是,当我想管理申请时,我有以下例外:

Error JAVA0000 java.exe: Error in C:Usersmdavidovic.nugetpackagesxamarin.androidx.collection.jvm1.3.0.1uildTransitive
et6.0-android31.0....jarandroidx.collection.collection-jvm.jar:androidx/collection/ArraySetKt.class:
Type androidx.collection.ArraySetKt is defined multiple times: C:Usersmdavidovic.nugetpackagesxamarin.androidx.collection.jvm1.3.0.1uildTransitive
et6.0-android31.0....jarandroidx.collection.collection-jvm.jar:androidx/collection/ArraySetKt.class, C:Usersmdavidovic.nugetpackagesxamarin.androidx.collection.ktx1.2.0.9uildTransitive
et6.0-android31.0....jarandroidx.collection.collection-ktx.jar:androidx/collection/ArraySetKt.class
Compilation failed
java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: C:Usersmdavidovic.nugetpackagesxamarin.androidx.collection.jvm1.3.0.1uildTransitive
et6.0-android31.0....jarandroidx.collection.collection-jvm.jar
androidx/collection/ArraySetKt.class
    at com.android.tools.r8.utils.R0.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:126)
    at com.android.tools.r8.D8.main(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:5)
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: C:Usersmdavidovic.nugetpackagesxamarin.androidx.collection.jvm1.3.0.1uildTransitive
et6.0-android31.0....jarandroidx.collection.collection-jvm.jar:androidx/collection/ArraySetKt.class
    at Version.fakeStackEntry(Version_8.1.56.java:0)
    at com.android.tools.r8.M.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:5)
    at com.android.tools.r8.utils.R0.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:81)
    at com.android.tools.r8.utils.R0.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:32)
    at com.android.tools.r8.utils.R0.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:31)
    at com.android.tools.r8.utils.R0.b(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:2)
    at com.android.tools.r8.D8.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:26)
    at com.android.tools.r8.D8.b(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:13)
    at com.android.tools.r8.D8.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:24)
    at com.android.tools.r8.utils.R0.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:113)
    ... 1 more
Caused by: com.android.tools.r8.utils.b: Type androidx.collection.ArraySetKt is defined multiple times: C:Usersmdavidovic.nugetpackagesxamarin.androidx.collection.jvm1.3.0.1uildTransitive
et6.0-android31.0....jarandroidx.collection.collection-jvm.jar:androidx/collection/ArraySetKt.class, C:Usersmdavidovic.nugetpackagesxamarin.androidx.collection.ktx1.2.0.9uildTransitive
et6.0-android31.0....jarandroidx.collection.collection-ktx.jar:androidx/collection/ArraySetKt.class
    at com.android.tools.r8.utils.O2.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:21)
    at com.android.tools.r8.utils.O2.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:26)
    at com.android.tools.r8.utils.A2.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:44)
    at com.android.tools.r8.utils.A2.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:10)
    at java.base/java.util.concurrent.ConcurrentHashMap.merge(ConcurrentHashMap.java:2048)
    at com.android.tools.r8.utils.A2.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:6)
    at com.android.tools.r8.graph.b4$a.e(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:7)
    at com.android.tools.r8.dex.c.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:58)
    at com.android.tools.r8.dex.c.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:9)
    at com.android.tools.r8.dex.c.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:8)
    at com.android.tools.r8.D8.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:29)
    at com.android.tools.r8.D8.d(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:17)
    at com.android.tools.r8.D8.c(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:1)
    at com.android.tools.r8.utils.R0.a(R8_8.1.56_756d1f50f618dd1c39c000f11defb367a21e9e866e3401b884be16c0950f6f79:28)
    ... 6 more

0>------- Finished building project: PushNotificationsTest. Succeeded: False. Errors: 1. Warnings: 3

我一直在寻找解决办法,但我没有看到任何人使用MAUI。 NET 8用于推动通知书。

谁能帮助我?

页: 1

我将这部法典从.csproj档案中删除,因为错误与它相同或没有:

<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>

我尝试删除双眼和切片,清理整个解决办法,但似乎没有帮助。

I ve还试图在上通过@moljac安装“Xamarin.AndroidX.Fragment.Ktx” nuget ,但错误是相同的......

最佳回答

几天前,我就有了这个确切的问题,尽管有不同的净版本。

我想,我要回顾一下我是如何解决的。

<PackageReference Include="Xamarin.AndroidX.Preference" Version="1.2.1.2" />
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.10.0.1" />

在你重建之前,你也许必须清理。

问题回答

一、执行一揽子计划的条件:

<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>

Target Net6.0-android, 您为净8.0-android

但是,由于净额8比较新,可能不会奏效?





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签