shinyorg / shiny

.NET Framework for Backgrounding & Device Hardware Services (iOS, Android, & Catalyst)
https://shinylib.net
MIT License
1.43k stars 227 forks source link

[Bug]: Shiny Push Notification - Delegate On Entry #1443

Closed nickdavidbhs closed 5 months ago

nickdavidbhs commented 5 months ago

Component/Nuget

Push - Native (Shiny.Push)

What operating system(s) are effected?

Version(s) of Operation Systems

Android 13

Hosting Model

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

` 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 Images as evidence: image image image 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 - [X] I have supplied a reproducible sample that is NOT FROM THE SHINY SAMPLES! - [X] 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) - [X] I am Sponsor OR My GitHub account is 30+ days old - [X] 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!
aritchie commented 5 months ago

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

nickdavidbhs commented 5 months ago

Amazing, worked good on Beta 3.3.3