The notification payload:
{ notification:
{ body: 'Test body',
sound: 'default',
title: 'Test',
badge: '4',
advertId: 'nmaQxRI89CzyBK4AnWH3',
click_action: 'fcm.Action.HELLO' },
data:
{ advert: '{"city":"Cluj-Napoca","currency":"RON","description":"-","images":["https://media1.lajumate.ro/media/i/new_details/2/836/8362622_iphone-5_1.jpg","https://media1.lajumate.ro/media/i/new_details/2/836/8362622_iphone-5_2.jpg"],"isRead":false,"link":"https://lajumate.ro/iphone-5-8362622.html","platform":"Test","price":3000,"searchId":"OmPnxYMm3sIO8oY2BSu6","status":"pending","timestamp":"2018-07-18T16:09:18.401Z","title":"Test"}',
advertId: 'nmaQxRI89CzyBK4AnWH3' } }
The application can receive notifications, but when the click is performed on a single notification, the app is not opened. If the click is performed on a group of notifications the app is opened. This issue appeared recently and only on Android devices. The getInitialNotification callback is not triggered when the app is killed and neither onNotifcationOpened when the app is in background. The problem is reproducible on the debug build on all Android devices, but on the release build on some devices the problem is not reproducible.
Application Target Platform:
Android
Development Operating System:
macOs High Sierra
Build Tools:
Android Studio 3.0.1
React Native
version:
0.55.4
React Native Firebase
Version:
4.0.7
Firebase
Module:
implementation(project(':react-native-firebase')) {
transitive = false
}
implementation 'com.google.android.gms:play-services-base:12.0.0'
implementation 'com.google.firebase:firebase-core:12.0.0'
implementation 'com.google.firebase:firebase-ads:12.0.0'
implementation 'com.google.firebase:firebase-auth:12.0.0'
implementation 'com.google.firebase:firebase-config:12.0.0'
implementation 'com.google.firebase:firebase-crash:12.0.0'
implementation 'com.google.firebase:firebase-messaging:12.0.0'
implementation 'com.google.firebase:firebase-perf:12.0.0'
implementation 'com.google.firebase:firebase-database:12.0.0'
implementation 'com.google.firebase:firebase-storage:12.0.0'
implementation 'com.google.firebase:firebase-firestore:12.0.0'
Are you using typescript
?
yes, version ^2.9.1
React Navigation
version:
^2.5.3
@razvantodea14 could we see your AndroidManifest
file contents?
Also, have you added the following: https://rnfirebase.io/docs/v4.3.x/messaging/android#Update-Android-Manifest ?
Loving react-native-firebase
and the support we provide? Please consider supporting us with any of the below:
React Native Firebase
and Invertase
on Twitter @Salakar This is the AndroidManifest file
`
android:versionCode="25"
android:versionName="1.2.7">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-sdk
android:minSdkVersion="21"
android:targetSdkVersion="26" />
<uses-feature
android:name="android.hardware.telephony"
android:required="true" />
<application
android:name=".MainApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:resizeableActivity="false"
android:theme="@style/AppTheme">
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/ic_stat_n" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@color/colorAccent" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="@string/notification_channel"/>
<activity
android:name=".MainActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:launchMode="singleTop"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<service android:name="io.invertase.firebase.messaging.RNFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service android:name="io.invertase.firebase.messaging.RNFirebaseInstanceIdService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
</application>
`
Same here. Did you solve?
I'm trying, any news I post here.
Some track.
When sending through firebase console, my app do open when I press it.
When sending through my php API (that sends to firebase), my app DO NOT open.
I compared the incoming information and noticed that from firebase console the click_action
propertie came undefined
and I'm setting it from my API. So I removed it to test and now my app is opening.
Why do a click_action
propertie influence this behavior?
"react": "^16.4.2",
"react-native": "^0.54.4",
"react-native-firebase": "^4.3.8",
Android 7.0, Samsung S7 Edge.
When sending through firebase console, my app do open when I press it.
When sending through my php API (that sends to firebase), my app DO NOT open.
I have the same issue and try removing the click_action
from request, hope it's working. But I also wonder why click_action
(maybe) is the problem. 馃
@vendramini and @hoantp click_action
was the problem in our case to.
If you're using a custom click_action
/ defining one then you need to add a custom intent-filter in your AndroidManifest
file; e.g. in @razvantodea14 case above something like the below example should work inside the main activity section:
<activity
android:name=".MainActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:launchMode="singleTop"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="fcm.Action.HELLO" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
On Android it's generally best practice to name your actions with a prefix of your package name, e.g.
com.mycool.app.SUPER_ACTION
.
The default behaviour without a click action is to launch the MainActivity (uses android.intent.action.MAIN
as the default action I believe) - which is why removing it works in the cases above as the MAIN
intent filter is setup in the AndroidManifest as part of the setup guide.
Will close this issue now - thanks for posting it.
Loving react-native-firebase
and the support we provide? Please consider supporting us with any of the below:
React Native Firebase
and Invertase
on Twitter Understood.
My previous library (react-native-fcm) works differently.
Thank you!
@Salakar, thank you.
But in case when I have a lots of click_actions
, for example
fcm.action.companyName1
fcm.action.companyName2
fcm.action.companyName3
...
can I defined in manifest something like pattern for actions, maybe you know ?
I face this issue currently I'm using
"react-native": "0.57.6",
"react-native-firebase": "5.2.0",
I was add this in my manifest file
<service android:name="io.invertase.firebase.messaging.RNFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
It's only happen for android, app not opened when click notification,
on iOS it's work
anyone can help?
Most helpful comment
If you're using a custom
click_action
/ defining one then you need to add a custom intent-filter in yourAndroidManifest
file; e.g. in @razvantodea14 case above something like the below example should work inside the main activity section:The default behaviour without a click action is to launch the MainActivity (uses
android.intent.action.MAIN
as the default action I believe) - which is why removing it works in the cases above as theMAIN
intent filter is setup in the AndroidManifest as part of the setup guide.Will close this issue now - thanks for posting it.
Loving
react-native-firebase
and the support we provide? Please consider supporting us with any of the below:React Native Firebase
andInvertase
on Twitter