zo0r / react-native-push-notification

React Native Local and Remote Notifications
MIT License
6.75k stars 2.05k forks source link

Fix for indirect notification activity start (trampoline) from blocked #2352

Open fcaldarelli opened 1 year ago

ChrisNg02655332 commented 1 year ago

Any process on this PR? I am currently facing with this issue

fcaldarelli commented 1 year ago

@ChrisNg02655332 if you Need urgently, use my fork package in meantime waiting for merge the pr

kartik8Zapkey commented 1 year ago

@ChrisNg02655332 if you Need urgently, use my fork package in meantime waiting for merge the pr

Still dont work it still says Indirect notification activity start (trampoline)

netzon-zerxa commented 1 year ago

This is also not working for me. It still gives me the same error message: "Indirect notification activity start (trampoline) from app blocked." 🥲

fcaldarelli commented 1 year ago

@kartik8Zapkey have you tried changes in my fork?

kartik8Zapkey commented 1 year ago

@fc

@kartik8Zapkey have you tried changes in my fork?

Yes i tried your fork , but still dont work. is anyone here for whom it is working ??

HirokiDaido commented 1 year ago

@fcaldarelli Your fork works fine in our project! Thank you! https://github.com/zo0r/react-native-push-notification/compare/master...fcaldarelli:react-native-push-notification:master

azhagar-magilhub commented 1 year ago

@fcaldarelli Your fork works fine in our project! Thank you! master...fcaldarelli:react-native-push-notification:master

how to pull this commit into my project

siddhant-maurya commented 1 year ago

We are blocked due to this error can someone please share any solutions

Ainias commented 1 year ago

This branch works, but the repo looks abandoned. I don't think it will be merged in soon.

I've created a pacth (usabale with patch-packe):

diff --git a/node_modules/react-native-push-notification/android/build.gradle b/node_modules/react-native-push-notification/android/build.gradle
index d6019f6..7022cd8 100644
--- a/node_modules/react-native-push-notification/android/build.gradle
+++ b/node_modules/react-native-push-notification/android/build.gradle
@@ -60,5 +60,6 @@ dependencies {
     implementation "$appCompatLibName:$supportLibVersion"
     implementation 'com.facebook.react:react-native:+'
     implementation 'me.leolin:ShortcutBadger:1.1.22@aar'
-    implementation "com.google.firebase:firebase-messaging:${safeExtGet('firebaseMessagingVersion', '21.1.0')}"
+    implementation "com.google.firebase:firebase-messaging:${safeExtGet('firebaseMessagingVersion', '23.1.2')}"
+    implementation "com.google.firebase:firebase-iid:21.1.0"
 }
Ben8823 commented 1 year ago

@fcaldarelli I've merged your changes in my project, but I'm still getting this error on Anroid 13: Indirect notification activity start (trampoline) from xxx blocked Any ideas what could be wrong?

fcaldarelli commented 1 year ago

@Ben8823 have you tried to clean e rebuild the project?

Ben8823 commented 1 year ago

@fcaldarelli yes I did run a gradle clean

fcaldarelli commented 1 year ago

@Ben8823 have you tried to link my repo as library: https://github.com/fcaldarelli/react-native-push-notification ?

Ben8823 commented 1 year ago

@fcaldarelli yes I'm using this in my package.json: "react-native-push-notification": "github:fcaldarelli/react-native-push-notification#c625b16e419631bc5c40d1df0919fb91162ac57" I also can see the changes made to the build.gradle in my node_modules.

Ben8823 commented 1 year ago

@fcaldarelli it turned out that the firebaseMessagingVersion was defined somewhere else in my project. removing that definition fixed the issue and your changes are working fine. thanks!

mikmedina commented 1 year ago

This branch works, but the repo looks abandoned. I don't think it will be merged in soon.

I've created a pacth (usabale with patch-packe):

diff --git a/node_modules/react-native-push-notification/android/build.gradle b/node_modules/react-native-push-notification/android/build.gradle
index d6019f6..7022cd8 100644
--- a/node_modules/react-native-push-notification/android/build.gradle
+++ b/node_modules/react-native-push-notification/android/build.gradle
@@ -60,5 +60,6 @@ dependencies {
     implementation "$appCompatLibName:$supportLibVersion"
     implementation 'com.facebook.react:react-native:+'
     implementation 'me.leolin:ShortcutBadger:1.1.22@aar'
-    implementation "com.google.firebase:firebase-messaging:${safeExtGet('firebaseMessagingVersion', '21.1.0')}"
+    implementation "com.google.firebase:firebase-messaging:${safeExtGet('firebaseMessagingVersion', '23.1.2')}"
+    implementation "com.google.firebase:firebase-iid:21.1.0"
 }

This worked for me, notifications were showing up but clicking them doesn't open the app before.

fcaldarelli commented 1 year ago

This branch works, but the repo looks abandoned. I don't think it will be merged in soon. I've created a pacth (usabale with patch-packe):

diff --git a/node_modules/react-native-push-notification/android/build.gradle b/node_modules/react-native-push-notification/android/build.gradle
index d6019f6..7022cd8 100644
--- a/node_modules/react-native-push-notification/android/build.gradle
+++ b/node_modules/react-native-push-notification/android/build.gradle
@@ -60,5 +60,6 @@ dependencies {
     implementation "$appCompatLibName:$supportLibVersion"
     implementation 'com.facebook.react:react-native:+'
     implementation 'me.leolin:ShortcutBadger:1.1.22@aar'
-    implementation "com.google.firebase:firebase-messaging:${safeExtGet('firebaseMessagingVersion', '21.1.0')}"
+    implementation "com.google.firebase:firebase-messaging:${safeExtGet('firebaseMessagingVersion', '23.1.2')}"
+    implementation "com.google.firebase:firebase-iid:21.1.0"
 }

This worked for me, notifications were showing up but clicking them doesn't open the app before.

@mikmedina avoid to use patch in node_modules, because it does not works in CI/CD and everytime you need to download node_modules.

ericowhadi commented 7 months ago

facing the same issue, I tried to exactly like Ben8823 "react-native-push-notification": "github:fcaldarelli/react-native-push-notification#c625b16e419631bc5c40d1df0919fb91162ac57", ./gradlew clean, verify dependencies to see if any other package would force a different version of firebase-messaging. But no luck, still having that trampoline issue. Anybody else facing this situation?

ericowhadi commented 7 months ago

after deep investigation, I have no clue why updating firebase would solve the issue. I can only intuit may be the target version of android that was used to validate it is working or not was under the threashold of the trampoline feature. On paper, when reading what this feature is, it should not be possible if you target an modern SDK that fall under the trampoline feature, to invokeApp or deeplink from the onAction in background task. That is the whole purpose of this feature -> forbid us to do so. So google is asking that instead of doing trampoline (that's the way they call this action of defering the invokeApp via a background task, to directly configure the action to open a deepLink, bypassing the middleman, and therefore making the action more responsive. So I patched the code in my fork to now allow passing actions with associated deepLink, syntax mybutton>com.mydeeplync://qwerty . If you don't use that syntax, the code behave as before (generates an onAction), so that you can have button that perform background task and does not need to invoke main app, or for buttons that needs to invoke main app, use that new syntax. BTW, I also included in my fork a fix to ReplyInput that is also broken in latest version of SDK that require MUTABLE flag to be set instead of IMMUTABLE. Note that ReplyInput only support legacy onAction generation, meaning you cannot use the deepLink feature with ReplyInput. https://github.com/ericowhadi/react-native-push-notification/blob/master/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationHelper.java

anshif10 commented 2 months ago

Any process on this PR? I am currently facing with this issue

This branch works, but the repo looks abandoned. I don't think it will be merged in soon.

I've created a pacth (usabale with patch-packe):

diff --git a/node_modules/react-native-push-notification/android/build.gradle b/node_modules/react-native-push-notification/android/build.gradle
index d6019f6..7022cd8 100644
--- a/node_modules/react-native-push-notification/android/build.gradle
+++ b/node_modules/react-native-push-notification/android/build.gradle
@@ -60,5 +60,6 @@ dependencies {
     implementation "$appCompatLibName:$supportLibVersion"
     implementation 'com.facebook.react:react-native:+'
     implementation 'me.leolin:ShortcutBadger:1.1.22@aar'
-    implementation "com.google.firebase:firebase-messaging:${safeExtGet('firebaseMessagingVersion', '21.1.0')}"
+    implementation "com.google.firebase:firebase-messaging:${safeExtGet('firebaseMessagingVersion', '23.1.2')}"
+    implementation "com.google.firebase:firebase-iid:21.1.0"
 }

@fcaldarelli (https://github.com/fcaldarelli) Not working for me .Still have the issue. My app is not opening notification actions above android 12,12+ devices

In log cat "Indirect notification activity start (trampoline) from com.app.tb blocked"

java.lang.RuntimeException: Unable to start receiver com.dieam.reactnativepushnotification.modules.RNPushNotificationActions: java.lang.SecurityException

Background activity launch blocked [callingPackage: com.app.tb; callingUid: 10208; appSwitchState: 2; callingUidHasAnyVisibleWindow: false; callingUidProcState: RECEIVER; isCallingUidPersistentSystemProcess: false; balAllowedByPiSender: BackgroundStartPrivileges[allowsBackgroundActivityStarts=false, allowsBackgroundForegroundServiceStarts=true, originatingToken=null]; realCallingPackage: com.app.tb; realCallingUid: 10208; realCallingUidHasAnyVisibleWindow: false; realCallingUidProcState: RECEIVER; isRealCallingUidPersistentSystemProcess: false; originatingPendingIntent: null; backgroundStartPrivileges: BackgroundStartPrivileges[allowsBackgroundActivityStarts=false, allowsBackgroundForegroundServiceStarts=false, originatingToken=null]; intent: Intent { flg=0x10000000 cmp=com.app.tb/.MainActivity (has extras) }; callerApp: ProcessRecord{c36be3 26555:com.app.tb/u0a208}; inVisibleTask: false]

{ "name": "xxx", "version": "0.0.1", "private": true, "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "lint": "eslint .", "start": "react-native start", "test": "jest" }, "dependencies": { "@firebase/messaging": "^0.12.10", "@react-native-async-storage/async-storage": "^1.23.1", "@react-native-community/cli-platform-ios": "^11.3.5", "@react-native-community/netinfo": "^9.4.1", "@react-native-community/progress-view": "^1.4.1", "@react-native-community/push-notification-ios": "^1.11.0", "@react-native-cookies/cookies": "^6.2.1", "@react-native-firebase/app": "^16.5.1", "@react-native-firebase/messaging": "^16.5.1", "@react-native/gradle-plugin": "^0.74.85", "@react-navigation/drawer": "^6.5.7", "@react-navigation/native": "^6.1.7", "@react-navigation/native-stack": "^6.9.13", "@reduxjs/toolkit": "^1.9.5", "axios": "^1.2.3", "crypto-js": "^4.1.1", "deprecated-react-native-prop-types": "^4.2.3", "package": "^1.0.1", "react": "18.2.0", "react-native": "0.72.5", "react-native-base64": "^0.2.1", "react-native-camera": "^4.2.1", "react-native-date-picker": "^4.3.3", "react-native-device-info": "^10.7.0", "react-native-fs": "^2.20.0", "react-native-gesture-handler": "^2.16.2", "react-native-gradle-plugin": "^0.71.19", "react-native-linear-gradient": "^2.7.3", "react-native-permissions": "^3.10.1", "react-native-push-notification": "^8.1.1", "react-native-qrcode-scanner": "^1.5.5", "react-native-reanimated": "^3.4.1", "react-native-restart": "^0.0.27", "react-native-safe-area-context": "^4.6.4", "react-native-screens": "^3.22.1", "react-native-simple-toast": "^3.3.1", "react-native-snackbar": "^2.6.2", "react-native-splash-screen": "^3.3.0", "react-native-toast-message": "^2.2.0", "react-native-webview": "^11.26.1", "react-redux": "^8.1.1", "redux": "^4.2.1", "redux-persist": "^6.0.0", "toggle-switch-react-native": "^3.3.0" }, "reactNativePermissionsIOS": [ "Camera", "MediaLibrary", "Microphone", "Notifications", "PhotoLibrary", "PhotoLibraryAddOnly" ], "devDependencies": { "@babel/core": "^7.20.0", "@babel/preset-env": "^7.20.0", "@babel/runtime": "^7.20.0", "@react-native/eslint-config": "^0.72.2", "@react-native/metro-config": "^0.72.7", "@tsconfig/react-native": "^3.0.0", "@types/crypto-js": "^4.1.1", "@types/metro-config": "^0.76.3", "@types/react": "^18.0.24", "@types/react-native-push-notification": "^8.1.1", "@types/react-test-renderer": "^18.0.0", "babel-jest": "^29.2.1", "eslint": "^8.19.0", "jest": "^29.2.1", "metro-react-native-babel-preset": "0.76.5", "prettier": "^2.4.1", "react-test-renderer": "18.2.0", "typescript": "4.8.4" }, "engines": { "node": ">=16" }, "resolutions": { "react-native-permissions": "^3.8.0" }, "overrides": { "react-native-qrcode-scanner": { "react-native-permissions": "^3.8.0" } } }

anshif10 commented 1 month ago

@fcaldarelli Hello, can anyone please help me? I'm getting an error on Android 12+ apps when clicking actions (accept, reject):

"Indirect notification activity start (trampoline) from com.pickyassist.tb blocked"

Here is my package.json:

"dependencies": { "@react-native-async-storage/async-storage": "^1.24.0", "@react-native-community/cli-platform-ios": "^11.3.5", "@react-native-community/netinfo": "^9.4.1", "@react-native-community/progress-view": "^1.4.1", "@react-native-community/push-notification-ios": "^1.11.0", "@react-native-cookies/cookies": "^6.2.1", "@react-native-firebase/app": "^20.3.0", "@react-native-firebase/messaging": "^20.3.0", "@react-native/gradle-plugin": "^0.74.85", "@react-navigation/drawer": "^6.7.2", "@react-navigation/native": "^6.1.18", "@react-navigation/native-stack": "^6.10.1", "@reduxjs/toolkit": "^1.9.5", "axios": "^1.7.2", "crypto-js": "^4.1.1", "deprecated-react-native-prop-types": "^4.2.3", "package": "^1.0.1", "react": "18.2.0", "react-native": "0.74.3", "react-native-base64": "^0.2.1", "react-native-battery-optimization-check": "^1.0.8", "react-native-camera": "^4.2.1", "react-native-date-picker": "^4.3.3", "react-native-device-info": "^11.1.0", "react-native-fs": "^2.20.0", "react-native-gesture-handler": "^2.16.2", "react-native-gradle-plugin": "^0.71.19", "react-native-linear-gradient": "^2.7.3", "react-native-notifications": "^5.1.0", "react-native-permissions": "^3.10.1", "react-native-push-notification": "github:fcaldarelli/react-native-push-notification#c625b16e419631bc5c40d1df0919fb91162ac57", "react-native-qrcode-scanner": "^1.5.5", "react-native-reanimated": "^3.4.1", "react-native-restart": "^0.0.27", "react-native-safe-area-context": "^4.6.4", "react-native-screens": "^3.22.1", "react-native-simple-toast": "^3.3.1", "react-native-snackbar": "^2.6.2", "react-native-splash-screen": "^3.3.0", "react-native-toast-message": "^2.2.0", "react-native-webview": "^11.26.1", "react-redux": "^8.1.1", "redux": "^4.2.1", "redux-persist": "^6.0.0", "toggle-switch-react-native": "^3.3.0" },

There is no issue if I click on the notification, but when clicking on the notification action, I get this trampoline issue.

How i resolve this issue ?

My android/app/build.gradle dependencies { // The version of react-native is set by the React Native Gradle Plugin implementation 'com.facebook.fresco:fresco:2.5.0' // or the appropriate version implementation 'androidx.multidex:multidex:2.0.1'

implementation(platform("com.google.firebase:firebase-bom:32.8.0"))
implementation project(':react-native-notifications')

implementation 'com.google.firebase:firebase-messaging'
implementation 'com.google.firebase:firebase-analytics'

implementation("com.facebook.react:react-android")
implementation project(':react-native-camera')
 // Firebase Cloud Messaging (Java)
implementation 'com.google.firebase:firebase-messaging'

implementation 'com.google.firebase:firebase-perf'

implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'

if (hermesEnabled.toBoolean()) {
    implementation("com.facebook.react:hermes-android")
} else {
    implementation jscFlavor
}

}

i can see the changes on node_modules/react-native-push-notification/android/build.gradle dependencies { // Use either AndroidX library names or old/support library names based on major version of support lib def supportLibVersion = safeExtGet('supportLibVersion', '27.1.1') def supportLibMajorVersion = supportLibVersion.split('\.')[0] as int def appCompatLibName = (supportLibMajorVersion < 20) ? "androidx.appcompat:appcompat" : "com.android.support:appcompat-v7"

implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
implementation "$appCompatLibName:$supportLibVersion"
implementation 'com.facebook.react:react-native:+'
implementation 'me.leolin:ShortcutBadger:1.1.22@aar'
implementation "com.google.firebase:firebase-messaging:${safeExtGet('firebaseMessagingVersion', '23.1.2')}"
implementation "com.google.firebase:firebase-iid:21.1.0"

}