GooglePlayServicesComponents icon indicating copy to clipboard operation
GooglePlayServicesComponents copied to clipboard

Push Notifications are not getting triggered on Android 12 and latest.

Open sirishaveeralapalli opened this issue 2 years ago • 6 comments

Xamarin.Android Version (eg: 6.0): 5.0.0.2578

Operating System & Version (eg: Mac OSX 10.11): Ventura 13.1

Xamarin.Firebase.Messaging

Version : 123.1.1.1

Describe your Issue

When trying to trigger a "test send" notification from Microsoft Azure notification hub, the result says that the notification has been sent successfully, but the Android devices with OS 12 and latest don't seem to get any notifications. However, the Android devices with OS version less than 11 are getting the notifications.

Relevant information

Add relevant project settings from *.csproj file:

Packages used:

<PackageReference Include="Xamarin.Forms" Version="5.0.0.2578" />
    <PackageReference Include="Xamarin.Essentials" Version="1.7.5" />
	<PackageReference Include="Xamarin.AndroidX.Lifecycle.LiveData" Version="2.6.1" />
    <PackageReference Include="Xamarin.AndroidX.Browser" Version="1.5.0" />
    <PackageReference Include="Xamarin.Google.Android.Material" Version="1.8.0" />
    <PackageReference Include="Xamarin.AndroidX.Legacy.Support.V4" Version="1.0.0.16" /> 
    <PackageReference Include="Newtonsoft.Json">
      <Version>13.0.3</Version>
    </PackageReference>
    <PackageReference Include="AndHUD">
      <Version>1.4.2</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.Azure.NotificationHubs.Android">
      <Version>1.1.4.1</Version>
    </PackageReference>
    <PackageReference Include="OxyPlot.Core">
      <Version>2.0.0</Version>
    </PackageReference>
    <PackageReference Include="OxyPlot.Xamarin.Android">
      <Version>1.0.0</Version>
    </PackageReference>
    <PackageReference Include="Plugin.Permissions">
      <Version>6.0.1</Version>
    </PackageReference>
    <PackageReference Include="Microsoft.AppCenter.Crashes">
      <Version>5.0.1</Version>
    </PackageReference>
    <PackageReference Include="Microsoft.AppCenter.Analytics">
      <Version>5.0.1</Version>
    </PackageReference>
    <PackageReference Include="Microsoft.Identity.Client">
      <Version>4.52.0</Version>
    </PackageReference>
    <PackageReference Include="Plugin.CurrentActivity">
      <Version>2.1.0.4</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.Google.Dagger">
      <Version>2.44.2.1</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.Firebase.Messaging">
      <Version>123.1.1.1</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.Android.Support.v4">
      <Version>28.0.0.3</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.AndroidX.Core">
      <Version>1.9.0.2</Version>
    </PackageReference>
    <PackageReference Include="OxyPlot.Xamarin.Forms">
      <Version>1.0.0</Version>
    </PackageReference>

Build settings (tools)

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>portable</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release</OutputPath>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <AndroidManagedSymbols>true</AndroidManagedSymbols>
    <AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
    <AndroidPackageFormat>apk</AndroidPackageFormat>
<AndroidLinkMode>None</AndroidLinkMode>
  </PropertyGroup>

NOTE: Please DO NOT submit screenshot images. Images are not searchable!

Minimal Repro Code Sample

If you want to speed up investigation and bug fixing: please provide minimal repro sample for tests.

Steps to Reproduce (with link to sample solution if possible):

-> Login to the application -> In the relevant notification hub, click on test send -> Provide the tag expression -> Click on "Test Send" -> Observe that the result says " The Push Notification has been sent successfully ". -> But your device doesn't receive any.

Include any relevant Exception Stack traces, build logs, adb logs:

sirishaveeralapalli avatar Apr 13 '23 10:04 sirishaveeralapalli

I have similar problems with version 123.0.0.7 with Release profile.

The Debug build profile DOES work for me for some reason. Please fix this.

jkommeren avatar Apr 13 '23 17:04 jkommeren

I think you need to grant/add permissions.

Something like:

https://github.com/Samples-Playgrounds/Samples.MAUI/blob/main/samples/issues-repro-samples/12291/Sample.Issue_12291.PostNotifications/Platforms/Android/AndroidManifest.xml#L6

moljac avatar Apr 18 '23 13:04 moljac

We have already enable this. Screenshot 2023-04-19 at 10 40 19 AM

sirishaveeralapalli avatar Apr 19 '23 05:04 sirishaveeralapalli

You need to realize that these are only bindings against the android libraries here. Unless one of the bindings is wrong, there aren't going to be any sort of bugs that can be fixed here.

Even if you've added android.permissions.POST_NOTIFICATIONS to your manifest, you still have to request the permission. That particular permission is only required for ANDROID 13 (API 33+). For what it's worth, this binding is working just fine and I use it in my library Shiny without issue.

aritchie avatar Apr 19 '23 07:04 aritchie

Hmm. Well in my case at least the application asks for permission to show notifications and the user is prompted at first startup.

Also the portal test notifications do show up when the app is running in the background. In my case at least.

Could this be a signing issue? 🤔

jkommeren avatar Apr 19 '23 08:04 jkommeren

Update: turns out Trimming in release mode in Maui .net 7 was my issue. After disabling it in csproj it works again.

< PublishTrimmed>False< /PublishTrimmed>

(Remove spaces)

Still unsure which component broke due to the Trimming. Will report back if I find more.

jkommeren avatar May 21 '23 15:05 jkommeren