You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am able to receive notification in all conditions - i. app in foreground, ii. app in background or iii. app in killed state, however I am unable to launch my application on tap of notification in android. In iOS, app is getting launched on tap of notification, as expected.
Here is related code snippet :
'channelId',
'Channel Name',
firebase.notifications.Android.Importance.Max
).setDescription('A natural description of the channel');
firebase.notifications().android.createChannel(channel);
// the listener returns a function you can use to unsubscribe
this.unsubscribeFromNotificationListener = firebase.notifications().onNotification((notification) => {
if (Platform.OS === 'android') {
const localNotification = new firebase.notifications.Notification({
sound: 'default',
show_in_foreground: true,
})
.setNotificationId(notification.notificationId)
.setTitle(notification.title)
.setSubtitle(notification.subtitle)
.setBody(notification.body)
.setData(notification.data)
.android.setChannelId('channelId')
.android.setPriority(firebase.notifications.Android.Priority.High)
firebase.notifications()
.displayNotification(localNotification)
.catch(err => console.log(err));
} else if (Platform.OS === 'ios') {
const localNotification = new firebase.notifications.Notification()
.setNotificationId(notification.notificationId)
.setTitle(notification.title)
.setSubtitle(notification.subtitle)
.setBody(notification.body)
.setData(notification.data)
.ios.setBadge(notification.ios.badge);
firebase.notifications()
.displayNotification(localNotification)
.catch(err => console.log(err));
}
});
apply plugin: "com.android.application"importcom.android.build.OutputFile
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"def enableSeparateBuildPerCPUArchitecture =falsedef enableProguardInReleaseBuilds =false
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "com.abcd"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
missingDimensionStrategy "RNN.reactNativeVersion", "reactNative57"
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false// If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
signingConfigs {
release {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant->
variant.outputs.each { output->// For each separate APK per architecture, set a unique version code as described here:// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splitsdef versionCodes = ["armeabi-v7a":1, "x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi !=null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) *1048576+ defaultConfig.versionCode
}
}
}
}
dependencies {
implementation project(':react-native-secure-key-store')
implementation project(':react-native-svg')
implementation project(':react-native-vector-icons')
implementation project(':react-native-firebase')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+"// From node_modules
implementation project(':react-native-navigation')
implementation 'com.android.support:design:25.4.0'
implementation "com.google.firebase:firebase-core:16.0.8"
implementation 'com.google.firebase:firebase-auth:16.2.1'
implementation "com.google.firebase:firebase-messaging:17.6.0"
implementation "com.google.firebase:firebase-invites:16.0.6"
implementation "com.google.firebase:firebase-database:16.1.0"
}
// Run this once to be able to run the application with BUCK// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetailsdetails->def requested = details.requested
if (requested.group =='com.android.support'&& requested.name !='multidex') {
details.useVersion "${rootProject.ext.supportLibVersion}"
}
}
}
apply plugin: 'com.google.gms.google-services'
android/settings.gradle:
rootProject.name ='PropertiesPublisherNew'
include ':react-native-secure-key-store'
project(':react-native-secure-key-store').projectDir =newFile(rootProject.projectDir, '../node_modules/react-native-secure-key-store/android')
include ':react-native-firebase'
project(':react-native-firebase').projectDir =newFile(rootProject.projectDir, '../node_modules/react-native-firebase/android')
include ':react-native-svg'
project(':react-native-svg').projectDir =newFile(rootProject.projectDir, '../node_modules/react-native-svg/android')
include ':react-native-vector-icons'
project(':react-native-vector-icons').projectDir =newFile(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')
include ':app'
include ':react-native-navigation'
project(':react-native-navigation').projectDir =newFile(rootProject.projectDir, '../node_modules/react-native-navigation/lib/android/app/')
react-native-firebase version you're using that has this issue:
5.3.1
Firebase module(s) you're using that has the issue:
e.g. Instance ID
Are you using TypeScript?
Y/N
Think react-native-firebase is great? Please consider supporting all of the project maintainers and contributors by donating via our Open Collective where all contributors can submit expenses. [Learn More]
I think this is the same thing that bit me. Splash screen is your launch activity and it's eating your notification tap. Easy to fix, check the related code I posted: crazycodeboy/react-native-splash-screen#289 (comment)
Issue
Describe your issue here
Unable to open android application on tap of firebase notification in react-native
I am integrating firebase push notification in my app using react-native-firebase https://github.com/invertase/react-native-firebase.
I am able to receive notification in all conditions - i. app in foreground, ii. app in background or iii. app in killed state, however I am unable to launch my application on tap of notification in android. In iOS, app is getting launched on tap of notification, as expected.
Here is related code snippet :
Firebase Configuration
Project Files
iOS
Click To Expand
ios/Podfile
:# N/A
AppDelegate.m
:// N/A
Android
Click To Expand
Have you converted to AndroidX?
android/gradle.settings
jetifier=true
for Android compatibility?jetifier
for react-native compatibility?android/build.gradle
:android/app/build.gradle
:android/settings.gradle
:MainApplication.java
:AndroidManifest.xml
:Environment
Click To Expand
react-native info
output:react-native-firebase
version you're using that has this issue:5.3.1
Firebase
module(s) you're using that has the issue:e.g. Instance ID
TypeScript
?Y/N
Think
react-native-firebase
is great? Please consider supporting all of the project maintainers and contributors by donating via our Open Collective where all contributors can submit expenses. [Learn More]React Native Firebase
andInvertase
on Twitter for updates on the library.The text was updated successfully, but these errors were encountered: