-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
onNotification is not called when a remote notification is pressed on Android #1378
Comments
same here |
Hi! |
@Dallas62 here it is
|
I'm also unable to get |
@Dallas62 I'm using Firebase to send remote notifications. |
There is conditional configuration in the documentation, look in the comments there is if else, remove those with GCM in the manifest |
@Dallas62 thank you for reviewing. I changed the content to the following, but it didn't help
|
Does something changed or nothing changed ? |
Not working, i tried example project
|
Hi @gibrandev <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService"/>
instead of: <receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="${applicationId}" />
</intent-filter>
</receiver> Thanks |
@Dallas62 i am sorry, not working same with this issues |
@Dallas62 the only change is that Could you please point out where i can find the example project. Can't find the ref to it in docs. Thank you! |
@anisimov74 In the |
@Dallas62 i tried an example project. It works with local notifications as expected. But it's only about local notification. Right? |
@anisimov74 Is your case fixed? |
Hi @anisimov74 @gibrandev |
@Dallas62 keep not working with this case, i have tested |
@Dallas62 I have the same problem with the latest version. |
same problem here, the |
I also notice that there is a difference between local and remote notification. When touching the |
Hi, |
I tested with :
|
with me fire
not fire on:
i've put the function configure() {
PushNotification.configure({
// (optional) Called when Token is generated (iOS and Android)
onRegister: this.onRegister, //this._onRegister.bind(this),
// (required) Called when a remote or local notification is opened or received
onNotification: this.onNotification, //this._onNotification,
// ANDROID ONLY: FCM Sender ID (optional - not required for local notifications, but is need to receive remote push notifications)
senderID,//from constant on module scope
// IOS ONLY (optional): default: all - Permissions to register.
/* permissions: {
alert: true,
badge: true,
sound: true,
}, */
// Should the initial notification be popped automatically
// default: true
popInitialNotification: true,
/**
* (optional) default: true
* - Specified if permissions (ios) and token (android and ios) will requested or not,
* - if not, you must call PushNotificationsHandler.requestPermissions() later
*/
requestPermissions: true,
});
} |
Hi @dhoncrisley |
my AndroidManifest.xml <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.MYPACKAGE">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="ongold" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService"/>
<service
android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<meta-data android:name="com.dieam.reactnativepushnotification.notification_channel_name"
android:value="Compra Daqui!"/>
<meta-data android:name="com.dieam.reactnativepushnotification.notification_channel_description"
android:value="Canal de Notificações Compra Daqui"/>
<meta-data android:name="com.dieam.reactnativepushnotification.notification_color"
android:resource="@android:color/white"/>
<provider android:name="androidx.core.content.FileProvider" android:authorities="${applicationId}.provider" android:enabled="true" android:exported="false" android:grantUriPermissions="true">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/provider_paths" />
</provider>
</application>
</manifest>
|
same problem onNotification does not call when I click the notification from the tray instead it reopens the app and onRegister get triggered |
Did you set |
Can you try with the version on Master ? |
@Dallas62 i have use example use react native 0.62.2, this issue is work perfect. |
Hi @gibrandev the example project, run with the version on master, can you try ? |
Can you provide updated AndroidManifest or a complete project to reproduce your issue ? |
@Dallas62 here my complete AndroidManifest <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dski.doctor">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application
android:largeHeap="true"
android:usesCleartextTraffic="true"
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme">
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/ic_stat_notification" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@color/base_color" />
<activity
android:name=".SplashActivity"
android:theme="@style/SplashTheme"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
android:theme="@style/Base.Theme.AppCompat">
</activity>
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:launchMode="singleTask"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize"
android:exported="true" />
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService"/>
<service
android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<meta-data android:name="com.dieam.reactnativepushnotification.notification_channel_name"
android:value="Example-Channel"/>
<meta-data android:name="com.dieam.reactnativepushnotification.notification_channel_description"
android:value="Super channel description"/>
<meta-data android:name="com.dieam.reactnativepushnotification.notification_color"
android:resource="@android:color/white"/>
</application>
</manifest>
|
You have two options:
|
@gibrandev I'm not sure have multiple activities is good for the project, |
@Dallas62 of course, I will make it ASAP, and give the report. |
@gibrandev Thanks ! 😃 |
@Dallas62 i have done testing with small project, work perfect. In my project use a |
@gibrandev I have a project with |
@Dallas62 my code is work now 😁, my problem in AndroidManifest you can compare with my comment in top. Thank you for your atention. 🙏 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dski.doctor">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application
android:largeHeap="true"
android:usesCleartextTraffic="true"
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme">
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/ic_stat_notification" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@color/base_color" />
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
android:theme="@style/Base.Theme.AppCompat">
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService"/>
<service
android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<meta-data android:name="com.dieam.reactnativepushnotification.notification_channel_name"
android:value="Example-Channel"/>
<meta-data android:name="com.dieam.reactnativepushnotification.notification_channel_description"
android:value="Super channel description"/>
<meta-data android:name="com.dieam.reactnativepushnotification.notification_color"
android:resource="@android:color/white"/>
</application>
</manifest> |
Nice ! |
@anisimov74 @dhoncrisley @gibrandev |
@Dallas62 still no Could you please take a look on my configuration? build.gradle:
settings.gradle:
app/build.gradle:
Manifest.xml:
MainApplication.java:
|
@Dallas62 I found this in Logcat logs:
|
With the latest version? |
@Dallas62 it's the example app from the repo
|
There is a new release 3.3.0, this should be better |
@Dallas62 I tried 3.3.0 in my app and posted my configuration above ^^. I have the same problem :( |
Did you set this: requestPermissions: true, |
@Dallas62 sure. I also tried to call it manually as you suggested with
|
Really strange, <service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService"/> |
@
Updated as described in the doc
|
senderID is not needed anymore but it's not the problem, did you set the google-service.json of Firebase ? |
|
Here the test commands:
# react-native-push-notification on git:master o [10:42:51]
$ cd example
# react-native-push-notification/example on git:master o [10:43:04]
$ rm -rf node_modules
# react-native-push-notification/example on git:master o [10:43:20]
$ cat package.json
{
"name": "example",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"@react-native-community/push-notification-ios": "^1.1.1",
"react": "16.11.0",
"react-native": "0.62.2",
"react-native-push-notification": "git+https://git@github.com/zo0r/react-native-push-notification.git"
},
"devDependencies": {
"@babel/core": "^7.9.0",
"@babel/runtime": "^7.9.2",
"@react-native-community/eslint-config": "^1.0.0",
"babel-jest": "^25.3.0",
"eslint": "^6.8.0",
"jest": "^25.3.0",
"metro-react-native-babel-preset": "^0.59.0",
"react-test-renderer": "16.11.0"
},
"jest": {
"preset": "react-native"
}
}
# react-native-push-notification/example on git:master o [10:43:30]
$ yarn
yarn install v1.12.3
[1/4] 🔍 Resolving packages...
[2/4] 🚚 Fetching packages...
[3/4] 🔗 Linking dependencies...
warning "react-native > react-devtools-core > ws@7.2.5" has unmet peer dependency "bufferutil@^4.0.1".
warning "react-native > react-devtools-core > ws@7.2.5" has unmet peer dependency "utf-8-validate@^5.0.2".
warning "@react-native-community/eslint-config > @typescript-eslint/eslint-plugin > tsutils@3.17.1" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".
warning "jest > @jest/core > jest-config > jest-environment-jsdom > jsdom@15.2.1" has unmet peer dependency "canvas@^2.5.0".
[4/4] 📃 Building fresh packages...
success Saved lockfile.
✨ Done in 49.21s.
# react-native-push-notification/example on git:master o [10:45:17]
$ react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 985 file(s) to forward-jetify. Using 16 workers...
info Starting JS server...
info Installing the app...
Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details
> Task :react-native-push-notification:compileDebugJavaWithJavac
> Task :app:stripDebugDebugSymbols UP-TO-DATE
Compatible side by side NDK version was not found.
> Task :app:installDebug
10:46:01 V/ddms: execute: running am get-config
10:46:02 V/ddms: execute 'am get-config' on 'emulator-5554' : EOF hit. Read: -1
10:46:02 V/ddms: execute: returning
Installing APK 'app-debug.apk' on 'Pixel_3a_API_29(AVD) - 10' for app:debug
10:46:02 D/app-debug.apk: Uploading app-debug.apk onto device 'emulator-5554'
10:46:02 D/Device: Uploading file onto device 'emulator-5554'
10:46:02 D/ddms: Reading file permision of react-native-push-notification/example/android/app/build/outputs/apk/debug/app-debug.apk as: rw-r--r-
-
10:46:02 V/ddms: execute: running pm install -r -t "/data/local/tmp/app-debug.apk"
10:46:03 V/ddms: execute 'pm install -r -t "/data/local/tmp/app-debug.apk"' on 'emulator-5554' : EOF hit. Read: -1
10:46:03 V/ddms: execute: returning
10:46:03 V/ddms: execute: running rm "/data/local/tmp/app-debug.apk"
10:46:03 V/ddms: execute 'rm "/data/local/tmp/app-debug.apk"' on 'emulator-5554' : EOF hit. Read: -1
10:46:03 V/ddms: execute: returning
Installed on 1 device.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.0.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 18s
48 actionable tasks: 27 executed, 21 up-to-date
info Connecting to the development server...
8081
info Starting the app on "emulator-5554"...
Starting: Intent { cmp=com.example/.MainActivity }
|
Unfortunately, I am facing the same issue as @anisimov74 after "upgrading" from master to 3.3.1. So I went back to the example and added the google-services.json as well as replacing the react-native-push-notification version in package.json with "3.3.1". Then I ran npm install and started the app, nothing was logged and no register token is shown. I saw that |
Thanks for the feedback, I think the initial issue is closed, the issue you discribed @MarcoStb1993 looks like: |
Hi,
onNotification
is not get called when i press a notification.The doc https://github.com/zo0r/react-native-push-notification#usage says that
onNotification
Called when a remote or local notification is opened or received.This callback is called twice when a notification is received:
1.
{collapse_key: "XX" foreground: true google.delivered_priority: "high" google.message_id: "0:1587387492329033%3a743ff23a743ff2" google.original_priority: "high" google.sent_time: 1587387492305 google.ttl: 2419200 id: "-1393396919" issueId: "XX" notification: body: "XX" sound: "default" tag: "XX" title: "XX" userInteraction: false}
2.
{foreground: true id: "-1409941121" issueId: "XX" message: "XX" title: "XX" userId: "XX" userInteraction: false}
Can anybody help me with this problem?
The text was updated successfully, but these errors were encountered: