Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android app does not open when clicking the push notification while the app is killed #161

Open
Adi007z opened this issue Feb 1, 2022 · 4 comments

Comments

@Adi007z
Copy link

Adi007z commented Feb 1, 2022

Bug Report

When app is killed by the user, clicking on the push notification will not properly open the app.
Yes, the app opens correctly when clicking the notification while the app is in background, but it is not working if the app is actually killed.

Expected Behaviour

App should open when clicking the notification.

Actual Behaviour

App does not open when clicking the notification.

Reproduce Scenario (including but not limited to)

Steps to Reproduce

  1. Kill the app (not backgrounded, kill it from app manager).
  2. Send a test notification to your phone.
  3. Tap the notification

Platform and Version (eg. Android 5.0 or iOS 9.2.1)

Cordova-Android version 10

(Android) Device Vendor (e.g. Samsung, HTC, Sony...)

Android (tested on emulator and on physical Samsung 21+)

Sample Push Data Payload

{
  "registration_ids": ["........................"],
  "data": {
    "title": "My Title",
    "message": "My message",
    "foreground": true
  }
}

Issue found in code:

At file: PushHandlerActivity.kt
https://github.com/havesource/cordova-plugin-push/blob/master/src/android/com/adobe/phonegap/push/PushHandlerActivity.kt
Search for this condition:
if (!PushPlugin.isActive && foreground && inline)

In this case described by me, when you tap the notification (while app is killed), the "inline" variable from this "if" condition will be always "false", so it will print the following message from the code:
Log.d(TAG, "Don't Want Main Activity")

Instead, in order for the app to open, the code should call:
forceMainActivityReload(false)

In order for this forceMainActivityReload(false) to be called, the "inline" variable from the "if" condition has to be removed or has to be "true".

@RiteshAryal
Copy link

RiteshAryal commented Feb 7, 2022

Here, I've the same issue - could somebody please suggest the best way to resolve it.

In fact, I can make it work if I send the notification payload as below; which I obviously do not want because it would need to change other push sender service. Further it will also break existing (working) notification icon on the tray.

  "notification": {
    "title": "Test Notification",
    "body": "This offer expires at 11:30 or whatever",
    "notId": 10
  },
  "data": {
    "surveyID": "ewtawgreg-gragrag-rgarhthgbad"
  }
}

@pparadelis
Copy link

pparadelis commented Feb 15, 2022

We face the exact same issue. Adi007z's solution seems to work.

@ajitsb
Copy link

ajitsb commented Feb 24, 2022

Yes faced the same issues. Seems some issue with the last commit files

@pascalspadone
Copy link

I've had this issue too, and tracked it to PushHandlerActivity.kt too (should have searched the issue tracker first 😅 )

Just wanted to add that the cause seems to be adressed by #160, so the bug should be fixed in the next release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants