[Bug]: Notification not clickable
IeuanWalker opened this issue · comments
Component/Nuget
Push - Native (Shiny.Push)
What operating system(s) are effected?
- iOS (13+ supported)
- Mac Catalyst
- Android (8+ supported)
Version(s) of Operation Systems
Android 13
Hosting Model
- MAUI
- Native/Classic Xamarin
- Manual
Steps To Reproduce
When the device receives the notification, I tap on it -
- If the app is running the notification drawer automatically closes, the notification remains there and the OnEntry is never triggered
- If the app isn't running, the notification gets removed from the notification drawer when tapped, but the app never launches
I believe everything is set up correctly.
App
In the MauiProgram.cs -
// I initialise shiny
.UseShiny()
// Register my delegate and give it the default channel
builder.Services.AddPush<MyPushDelegate>(
#if ANDROID
new FirebaseConfig(
DefaultChannel: DefaultChannel()
)
#endif
);
#if ANDROID
static NotificationChannel? DefaultChannel()
{
if (OperatingSystem.IsAndroidVersionAtLeast(30))
{
return new NotificationChannel("default_channel", "Default Channel", NotificationImportance.Default)
{
LockscreenVisibility = NotificationVisibility.Public
};
}
return null;
}
#endif
MainActivity.cs, I've added the intent
[IntentFilter([Shiny.ShinyPushIntents.NotificationClickAction])]
AndroidManifest -
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true">
<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notification" />
</application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
</manifest>
Backend
In the backend I've set the ClickAction -
Message message = new()
{
Notification = new Notification
{
Title = notification.Title,
Body = notification.Message
},
Token = notification.Registration.FcmId,
Data = data,
Android = new AndroidConfig
{
Notification = new AndroidNotification
{
ClickAction = "SHINY_NOTIFICATION_CLICK"
}
},
};
notification.FcmId = await FirebaseMessaging.DefaultInstance.SendAsync(message);
Expected Behavior
When the notification is tapped on, it removes the notification from the list, launches the app, and triggers the OnEntry method
Actual Behavior
The notification remains in the notification list, the app never launches, and OnEntry is never triggered
Exception or Log output
No response
Code Sample
No response
Code of Conduct
- I have supplied a reproducible sample that is NOT FROM THE SHINY SAMPLES!
- I am a Sponsor OR I am using the LATEST stable/beta version from nuget (v3.0 stable - ALPHAS are not taking issues - Sponsors can still send v2 issues)
- I am Sponsor OR My GitHub account is 30+ days old
- I understand that if I am checking these boxes and I am not actually following what they are saying, I will be removed from this repository!
Please submit repros and do a little more digging before filing these.
SHINY_NOTIFICATION_CLICK is not correct
https://shinylib.net/client/push/faq/
[IntentFilter([Shiny.ShinyPushIntents.NotificationClickAction])] is missing values
https://shinylib.net/client/appbuilder/
Thanks @aritchie, working now.
SHINY_NOTIFICATION_CLICK is not correct
I copied this from the source code you linked earlier. It uses your the 'Shiny.Extensions.Push' Nuget, which in the src code sets the click action as SHINY_NOTIFICATION_CLICK
- https://github.com/shinyorg/apiservices/blob/d960b92b9048cce8e7e4f54d869c405aecf3e29a/src/Shiny.Extensions.Push.GoogleFirebase/ShinyAndroidIntentEvents.cs#L6C4-L6C88
[IntentFilter([Shiny.ShinyPushIntents.NotificationClickAction])] is missing values
I had this setup originally based on the docs, but as it wasn't working, I looked at the src code of this repo and saw it was set up differently - https://github.com/shinyorg/shiny/blob/a5e6b62deb5801acac11cbf687784e9d264979d4/samples/Sample.Maui/Platforms/Android/MainActivity.cs#L17C1-L19C4