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

[targetSdk 31 / Android 12] - Indirect notification activity start (trampoline) from <package-name> blocked #250

Closed
nishanttatva opened this issue Dec 1, 2021 · 16 comments

Comments

@nishanttatva
Copy link

nishanttatva commented Dec 1, 2021

(Accidental submit 🤦‍♂️ )
I'm facing an issue when displaying a local notification after receiving data-only message in the background (using react-native-firebase).
For android 12 devices, the app is not brought to foreground when tapping on notification. I need to press the app-icon to launch the app. Once the app is opened, it receives the notification and internal navigation works correctly.

On checking the logs and researching a bit about Android 12 notification changes, found that this error is thrown when I click on the notification.

Indirect notification activity start (trampoline) from blocked

Here's a screenshot of the logcat:
There's another error with notifee.hideNotificationDrawer(); but that's for another day(issue).

notifee-issue

Text file for your convienience

react-native info

System:
    OS: macOS 11.1
    CPU: (6) x64 Intel(R) Core(TM) i5-8400 CPU @ 2.80GHz
    Memory: 396.46 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.18.1 - ~/.nvm/versions/node/v14.18.1/bin/node
    Yarn: Not Found
    npm: 6.14.15 - ~/.nvm/versions/node/v14.18.1/bin/npm
    Watchman: 2021.11.15.00 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.11.2 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4
    Android SDK:
      API Levels: 25, 28, 29, 30, 31
      Build Tools: 28.0.3, 29.0.2, 30.0.2, 30.0.3, 31.0.0, 32.0.0
      System Images: android-30 | Google APIs Intel x86 Atom, android-31 | ARM 64 v8a, android-31 | Intel x86 Atom_64, android-31 | Google APIs Intel x86 Atom_64
      Android NDK: Not Found
  IDEs:
    Android Studio: 2020.3 AI-203.7717.56.2031.7784292
    Xcode: 12.5.1/12E507 - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.11 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.13.1 => 16.13.1 
    react-native: 0.63.2 => 0.63.2 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

package.json:

{
"dependencies": {
    "@notifee/react-native": "^4.0.0",
    "@react-native-async-storage/async-storage": "^1.15.4",
    "@react-native-community/art": "^1.2.0",
    "@react-native-community/blur": "^3.6.0",
    "@react-native-community/clipboard": "^1.5.1",
    "@react-native-community/netinfo": "^6.0.0",
    "@react-native-firebase/app": "^13.0.1",
    "@react-native-firebase/crashlytics": "^13.0.1",
    "@react-native-firebase/messaging": "^13.0.1",
    "@react-native-masked-view/masked-view": "^0.2.6",
    "@react-navigation/native": "^5.1.5",
    "@twotalltotems/react-native-otp-input": "^1.3.11",
    "axios": "^0.19.2",
    "lodash": "^4.17.21",
    "react": "16.13.1",
    "react-native": "0.63.2",
    "react-native-drop-shadow": "^0.0.2",,
    "react-native-exit-app": "^1.1.0",
    "react-native-fast-image": "^8.3.4",
    "react-native-fs": "^2.17.0",
    "react-native-gesture-handler": "^1.5.0",
    "react-native-image-crop-picker": "^0.36.2",
    "react-native-keychain": "6.1.1",
    "react-native-linear-gradient": "^2.4.0",
    "react-native-modal": "^11.10.0",
    "react-native-paper": "^4.8.1",
    "react-native-permissions": "^3.0.3",
    "react-native-reanimated": "^2.1.0",
    "react-native-responsive-fontsize": "^0.5.0",
    "react-native-restart": "^0.0.22",
    "react-native-safe-area-context": "^0.7.3",
    "react-native-screens": "^2.10.1",
    "react-native-vector-icons": "^8.1.0",
    "react-native-version-info": "^1.1.0",
    "react-native-video": "^2.3.1",
    "react-navigation": "^4.4.4",
    "reanimated-bottom-sheet": "*",
    "rn-fetch-blob": "^0.12.0",
    "validate.js": "0.13.1"
  }
}
@nishanttatva nishanttatva changed the title Indirect notification activity start (trampoline) from blocked Indirect notification activity start (trampoline) from <package-name> blocked Dec 1, 2021
@nishanttatva
Copy link
Author

Forgot to mention, this only happens when app is in background or kill state and only in Android 12. Other versions and iOS are working fine.

@mikehardy
Copy link
Contributor

what's your build.gradle targetSdk ? Does this happen when you target 31, or just run on 31, regardless of target?
Docs indicate should just be "target", which is not necessary yet (though we want it to work of course!) so I ask in order to prioritize triage here

Relevant new restriction:

n other words, after the user taps on a notification, or an action button within the notification, your app cannot call startActivity() inside of a service or broadcast receiver.

How to diagnose:

https://developer.android.com/about/versions/12/behavior-changes-12#identify-notification-trampolines

Remediation:

Update your app
If your app starts an activity from a service or broadcast receiver that acts as a notification trampoline, complete the following migration steps:

Create a PendingIntent object that is associated with the activity that users see after they tap on the notification.
Use the PendingIntent object that you created in the previous step as part of building your notification.
To identify the origin of the activity, in order to perform logging for example, use extras when posting the notification. For centralized logging, use ActivityLifecycleCallbacks or Jetpack lifecycle observers.

🤔

@mikehardy mikehardy changed the title Indirect notification activity start (trampoline) from <package-name> blocked [targetSdk 31 / Android 12] - Indirect notification activity start (trampoline) from <package-name> blocked Dec 1, 2021
@nishanttatva
Copy link
Author

what's your build.gradle targetSdk ? Does this happen when you target 31, or just run on 31, regardless of target?

SDK versions
buildToolsVersion = "31.0.0" minSdkVersion = 24 compileSdkVersion = 31 targetSdkVersion = 31

We were facing crashes on Android 12 devices when using a lower targetSdkVersion, so upgraded to 31. If its required we'll try to run a test with targetSdk=30 in an Android 12 device, would take some time though.

How to diagnose:
https://developer.android.com/about/versions/12/behavior-changes-12#identify-notification-trampolines

Yup, used the above docs to find the error log, (linked the same in my description). As mentioned, got the notification interaction logs to find the component which is using the trampolines. Attaching, if that's useful notif-interaction-logs.txt.

@mikehardy
Copy link
Contributor

Why not just paste the text in 🤔 ? This is a rich text environment :-)

    BUFFER NotifInteractionLog:
    ============================================================================
    12-01 13:58:10.050 D NotifActivityStarter: (1/4) onNotificationClicked: 0|com.test.app|1672791959|null|10527
    12-01 13:58:10.050 D NotifActivityStarter: (2/4) handleNotificationClickAfterKeyguardDismissed: 0|com.test.app|1672791959|null|10527
    12-01 13:58:10.050 D NotifActivityStarter: (3/4) handleNotificationClickAfterPanelCollapsed: 0|com.test.app|1672791959|null|10527
    12-01 13:58:10.051 I NotifActivityStarter: (4/4) Starting Intent { act=app.notifee.core.ReceiverService.PRESS_INTENT cmp=com.test.app/app.notifee.core.ReceiverService (has extras) } for notification 0|com.test.app|1672791959|null|10527
    12-01 13:58:38.995 D NotificationClicker: CLICK 0|com.test.app|0|FCM-Notification:76633144|10527 (channel=fcm_fallback_notification_channel)
    12-01 13:58:38.995 D NotifActivityStarter: (1/4) onNotificationClicked: 0|com.test.app|0|FCM-Notification:76633144|10527
    12-01 13:58:38.998 D NotifActivityStarter: (2/4) handleNotificationClickAfterKeyguardDismissed: 0|com.test.app|0|FCM-Notification:76633144|10527
    12-01 13:58:38.998 D NotifActivityStarter: (3/4) handleNotificationClickAfterPanelCollapsed: 0|com.test.app|0|FCM-Notification:76633144|10527
    12-01 13:58:38.998 I NotifActivityStarter: (4/4) Starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x14000000 pkg=com.test.app cmp=com.test.app/.MainActivity (has extras) } for notification 0|com.test.app|0|FCM-Notification:76633144|10527
    12-01 13:59:41.879 D NotificationClicker: CLICK 0|com.test.app|-984514957|null|10527 (channel=101)
    12-01 13:59:41.880 D NotifActivityStarter: (1/4) onNotificationClicked: 0|com.test.app|-984514957|null|10527
    12-01 13:59:41.880 D NotifActivityStarter: (2/4) handleNotificationClickAfterKeyguardDismissed: 0|com.test.app|-984514957|null|10527
    12-01 13:59:41.880 D NotifActivityStarter: (3/4) handleNotificationClickAfterPanelCollapsed: 0|com.test.app|-984514957|null|10527
    12-01 13:59:41.880 I NotifActivityStarter: (4/4) Starting Intent { act=app.notifee.core.ReceiverService.PRESS_INTENT cmp=com.test.app/app.notifee.core.ReceiverService (has extras) } for notification 0|com.test.app|-984514957|null|10527
    12-01 14:00:37.874 D NotificationClicker: CLICK 0|com.test.app|-275744664|null|10527 (channel=101)
    12-01 14:00:37.875 D NotifActivityStarter: (1/4) onNotificationClicked: 0|com.test.app|-275744664|null|10527
    12-01 14:00:37.875 D NotifActivityStarter: (2/4) handleNotificationClickAfterKeyguardDismissed: 0|com.test.app|-275744664|null|10527
    12-01 14:00:37.875 D NotifActivityStarter: (3/4) handleNotificationClickAfterPanelCollapsed: 0|com.test.app|-275744664|null|10527
    12-01 14:00:37.875 I NotifActivityStarter: (4/4) Starting Intent { act=app.notifee.core.ReceiverService.PRESS_INTENT cmp=com.test.app/app.notifee.core.ReceiverService (has extras) } for notification 0|com.test.app|-275744664|null|10527
    12-01 14:01:42.814 D ActionClickLogger: ACTION CLICK 0|com.test.app|2046362430|null|10527 (channel=101) for pending intent Intent { act=app.notifee.core.ReceiverService.ACTION_PRESS_INTENT cmp=com.test.app/app.notifee.core.ReceiverService (has extras) }
    12-01 14:01:42.817 D ActionClickLogger:   [Action click] Launching intent Intent { act=app.notifee.core.ReceiverService.ACTION_PRESS_INTENT cmp=com.test.app/app.notifee.core.ReceiverService (has extras) } via default handler (for 0|com.test.app|2046362430|null|10527)
    12-01 14:03:05.566 D NotificationClicker: CLICK 0|com.test.app|-665721741|null|10527 (channel=101)
    12-01 14:03:05.566 D NotifActivityStarter: (1/4) onNotificationClicked: 0|com.test.app|-665721741|null|10527
    12-01 14:03:05.567 D NotifActivityStarter: (2/4) handleNotificationClickAfterKeyguardDismissed: 0|com.test.app|-665721741|null|10527
    12-01 14:03:05.567 D NotifActivityStarter: (3/4) handleNotificationClickAfterPanelCollapsed: 0|com.test.app|-665721741|null|10527
    12-01 14:03:05.567 I NotifActivityStarter: (4/4) Starting Intent { act=app.notifee.core.ReceiverService.PRESS_INTENT cmp=com.test.app/app.notifee.core.ReceiverService (has extras) } for notification 0|com.test.app|-665721741|null|10527
    12-01 14:03:32.484 D NotificationClicker: CLICK 0|com.test.app|941909978|null|10527 (channel=101)
    12-01 14:03:32.484 D NotifActivityStarter: (1/4) onNotificationClicked: 0|com.test.app|941909978|null|10527
    12-01 14:03:32.484 D NotifActivityStarter: (2/4) handleNotificationClickAfterKeyguardDismissed: 0|com.test.app|941909978|null|10527
    12-01 14:03:32.484 D NotifActivityStarter: (3/4) handleNotificationClickAfterPanelCollapsed: 0|com.test.app|941909978|null|10527
    12-01 14:03:32.484 I NotifActivityStarter: (4/4) Starting Intent { act=app.notifee.core.ReceiverService.PRESS_INTENT cmp=com.test.app/app.notifee.core.ReceiverService (has extras) } for notification 0|com.test.app|941909978|null|10527
    12-01 14:32:26.379 D NotificationClicker: CLICK 0|com.test.app|-617607735|null|10528 (channel=101)
    12-01 14:32:26.379 D NotifActivityStarter: (1/4) onNotificationClicked: 0|com.test.app|-617607735|null|10528
    12-01 14:32:26.380 D NotifActivityStarter: (2/4) handleNotificationClickAfterKeyguardDismissed: 0|com.test.app|-617607735|null|10528
    12-01 14:32:26.380 D NotifActivityStarter: (3/4) handleNotificationClickAfterPanelCollapsed: 0|com.test.app|-617607735|null|10528
    12-01 14:32:26.380 I NotifActivityStarter: (4/4) Starting Intent { act=app.notifee.core.ReceiverService.PRESS_INTENT cmp=com.test.app/app.notifee.core.ReceiverService (has extras) } for notification 0|com.test.app|-617607735|null|10528
    12-01 15:08:40.205 D NotificationClicker: CLICK 0|com.test.app|2040867036|null|10530 (channel=101)
    12-01 15:08:40.205 D NotifActivityStarter: (1/4) onNotificationClicked: 0|com.test.app|2040867036|null|10530
    12-01 15:08:40.206 D NotifActivityStarter: (2/4) handleNotificationClickAfterKeyguardDismissed: 0|com.test.app|2040867036|null|10530
    12-01 15:08:40.206 D NotifActivityStarter: (3/4) handleNotificationClickAfterPanelCollapsed: 0|com.test.app|2040867036|null|10530
    12-01 15:08:40.206 I NotifActivityStarter: (4/4) Starting Intent { act=app.notifee.core.ReceiverService.PRESS_INTENT cmp=com.test.app/app.notifee.core.ReceiverService (has extras) } for notification 0|com.test.app|2040867036|null|10530

You should have no problem with targetSdk30 / compileSdk31, I don't believe targetSdk 31 is ready yet in the ecosystem in general, certainly not here, for example you will see silent failures to schedule alarms until this is resolved: #239

I do really appreciate the digging though, I did use your link directly :-)

This will likely require some time to resolve, I certainly don't have the time now and won't for months. Luckily the targetSdkVersion cutovers on Play store are November 1, so there's 11 months to go.

@nishanttatva
Copy link
Author

Why not just paste the text in thinking ? This is a rich text environment :-)

Hate scrolling through huge error logs in issue comments 😛 , sorry about that.

You should have no problem with targetSdk30 / compileSdk31

Okay will try out this config and report back here.

@mikehardy
Copy link
Contributor

Not sure about all maintainers but at least myself, I like having it all visible in one space. Can always use the markdown details feature to make it collapsible. I never expect people to have the ability to open attachments (think: mobile notification reading offline) so I try to keep it all up in a text trail. I may be old school though

Definitely curious for reports on how targetSdkVersion 30 went

@nishanttatva
Copy link
Author

nishanttatva commented Dec 7, 2021

Sorry for taking so long! But yes, setting targetSdkVersion=30 did the trick! The above error doesn't occur and tapping on the notification opens the app correctly.

@mikehardy I'm going to close this issue, but some libraries have moved to targetSdk31 (eg. react-native-bootsplash), so might need to do those changes later on (or sooner?). I might try to do those changes and open a PR for it, once I get the chance.

Thanks!

@mikehardy
Copy link
Contributor

There is a big difference between compile, target, and min on those SDK versions.

Compile 31 is early for most, but needed for some. And it's definitely needed in this module. It implies using JDK11, as a related item.

Target 31 is very early, and too early for this module yet. It will take time. No modules for a target though, that should remain under control of the app. Google enforces target 30. Will not require target 30 until Nov 1, 2022.

We already support target 30 though. No problem

minSdkVersion is limited by ability to remain compatible and moves about same speed as target. Currently 21 is where we are at, same as react-native current I think.

@mikehardy
Copy link
Contributor

I think this needs to stay open, there is a workaround of using targetSdkVersion 30, but we will eventually (by Nov 1, 2022) need to support targetSdkVersion 31

@alexanderdavide
Copy link

If notifee actually requires compileSdkVersion 31, I suspect there are features that don't work on targetSdkVersion 30. Is my assumption correct? Running my app on the lower targetSdkVersion 30 as a workaround for the notification problem, what features of notifee would not work? Is there a source I can use to find such compatibilities out myself?

@mikehardy
Copy link
Contributor

notifee does require compile of 31
notifee currently requires target of 30 to work correctly
We are tracking all of the issues with a label: android 12

@alexanderdavide
Copy link

@mikehardy
Wouldn't it be nice to have the compatibility label in the docs on the website?

@mikehardy
Copy link
Contributor

Not sure where you would like it? Could be a help though. There's an edit button at top right of each page if you want to propose something

@seventhmoon
Copy link

seventhmoon commented Jan 25, 2022

I think this needs to stay open, there is a workaround of using targetSdkVersion 30, but we will eventually (by Nov 1, 2022) need to support targetSdkVersion 31

Not by Nov 1.
Nov is usually the deadline for existing apps on Play.
For new apps, it usually a few months early.
https://developer.android.com/google/play/requirements/target-sdk

I think SDK / Library should target latest version of Android ASAP, so it will not become a blocker for app developer.

@mikehardy
Copy link
Contributor

@seventhmoon a reasonable point - that said, it is in progress, there is no intention to delay for example #301

@helenaford
Copy link
Member

Fixed in latest release (v4.1.0).

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

No branches or pull requests

5 participants