[Bug]: Shiny Push Notification - Delegate On Entry
nickdavidbhs 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
Execute the App.
Send to background.
Push the Firebase Notification.
Tap the notification on device
Expected Behavior
The app to run.
Activate the android Intent.
Run the method OnEntry from the delegate
Actual Behavior
The app runs
There is no intent.
So, no OnEntry called
Exception or Log output
No Exception
Code Sample
Here a link to a GitHub with the project:
https://github.com/nickdavidbhs/My-Shiny.git
The project works good in iPhone running the calls with Apns.
On Android the OnReceived method works good. Only this call fails.
For security reasons removed the google service json, due to the api key.
And renamed the App Id to com.Shiny.Implementation
Relevant things:
This Is my Android Main Activity
`using Android.App;
using Android.Content.PM;
using Android.OS;
using Firebase;
namespace Shiny_Implementation;
[Activity(
Theme = "@style/MainTheme",
MainLauncher = true,
ConfigurationChanges =
ConfigChanges.ScreenSize |
ConfigChanges.Orientation |
ConfigChanges.UiMode |
ConfigChanges.ScreenLayout |
ConfigChanges.SmallestScreenSize |
ConfigChanges.Density)]
[IntentFilter(
new[] {
Shiny.ShinyPushIntents.NotificationClickAction
},
Categories = new[] {
"android.intent.category.DEFAULT"
}
)]
public class MainActivity : MauiAppCompatActivity
{
protected override void OnCreate(Bundle? savedInstanceState)
{
base.OnCreate(savedInstanceState);
FirebaseApp.InitializeApp(this);
}
}`
As can be seen, I have the click action for the intent and the category.
The Android Manifest
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.Shiny.Implementation" android:versionCode="1" android:versionName="1.0"> <application android:allowBackup="true" android:icon="@mipmap/appicon" android:supportsRtl="true" android:label="Shiny-Implementation"> <meta-data android:name="com.google.firebase.messaging.default_notification_channel_id" android:value="shinyImplement" /> </application> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.POST_NOTIFICATIONS" /> <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="33" /> </manifest>
Can be seen that there is a channel id set.
For the other side, my API call:
In postman the next call for firebase api:
https://fcm.googleapis.com/v1/projects/[project id]/messages:send
{
"message":{
"token":"cWZzsWBkR6qH-PjhDvcB6F:APA91bE2mUtc0Rkwj7vymIXadWoPfN7kiV_AGJeCCCdb8OhBU-WrCwxLVX594SxH0z1PBRNZcgP6lUxDltw3SOHdAMtbgmtZ2__lutBB7aNRWdVvjz8m6YeYjuXC_nbxZtHLCcHK5HUZ",
"data":{
"senderId": "testing",
"latitud": "a",
"longitud": "b"
},
"notification":{
"body":"Body",
"title":"Title"
},
"android":{
"notification":{
"sound": "notification.wav",
"default_sound": false,
"click_action":"SHINY_PUSH_NOTIFICATION_CLICK",
"channel_id":"shinyImplement"
}
}
}
}
As it was recently updated the click action goes inside the android group, inside of notification.
Link of the documentation:
https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#AndroidNotification
I hope I made a mistake, but if not would like to know why is the OnReceived not being called as is as the documentation says
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!
There was a default value for the intent that I believe I missed in 3.3.2. You can give 3.3.3-beta a try, revert to 3.3.0 or set a default intent in your AddPush statement using #if ANDROID compiler directives. Please view the source if you don't understand the final option
Amazing, worked good on Beta 3.3.3