TobiasBuchholz / Plugin.Firebase

Wrapper around the native Android and iOS Firebase Xamarin SDKs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NotificationTapped not working in Killed State

huzaifa-saeed opened this issue · comments

I am using NotificationTapped in App.cs after InitializeComponent();
but NotificationTapped not invoking in any states.

Issue:
When i tap on notification in background and foreground state it redirect user to specific page using OnNewIntent, but in killed state it's not working. In killed state Intent is empty it just open app but not redirect user to specific page.

Hi, are you calling FirebaseCloudMessagingImplementation.OnNewIntent(intent) in your MainActivity.cs also from OnCreate(...) or only from OnNewIntent(...)? This might cause the problem.

Hi, I am calling FirebaseCloudMessagingImplementation.OnNewIntent(intent) in MainActivity.cs from both OnCreate(...) and OnNewIntent(...)

Any update regarding this?

No, handling the notification tap should function correctly, irrespective of the app's state. Could you please provide a small sample project, that demonstrates the issue?

Hi!
I've experiencied similar issues as in this thread, so I'll continue here.

Enclosed, please find a simple modification of Coop-Tim sample (feature/adame branch with 3.0.0 plugin). It is limited to Android only, and needs adjusting google-services.json and ApplicationId in csproj and in AndroidManifest.xml
The app logs its execution; log view is updated on button click (e.g., after notification was tapped).

I ran the app on mobile device and sent test notifications directly from Firebase console.

I tried several test paths, each with different app behaviour:

  1. App started -> notification appeared on tray -> notif. tapped -> notif. received (tapped event) with title/body - OK
  2. App not started -> not. appeared -> not. tapped -> app started (without usual .Net splash) -> notif. received but with empty Title/Body
  3. AppStarted -> notif. appeared -> app killed -> not. tapped -> not. received with Title/Body
  4. App not started -> 2 notif. appeared -> 1st tapped -> app started and notif. received without Title/Body -> 2nd tapped -> someting strange happened (second instance of app was almost started instead of not. tapped event)
  5. Added ClearTaskOnLaunch = true, LaunchMode = LaunchMode.SingleTask in MainActivity.cs (as in #264 (comment)) and repeated step 4) -> now second tap opens notification in the same app instance (by OnNewIntent -> not. tapped handler).

It looks that somehow when notification appears on device, it remembers the current state of the app (?)

Why there is such an inconsistent behaviour?
CoopTimSample.zip