-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Closed
Labels
plugin: messagingFCM only - ( messaging() ) - do not use for NotificationsFCM only - ( messaging() ) - do not use for Notifications
Description
I have an app which uses react-native-firebase. I followed the initialisation steps provided for installing the app and for cloud messaging. Now when I use firebase console to send notification to a single user (haven't tried sending to a bunch, but I guess result would be the same), I receive the notification if the app is open, otherwise not. I read somewhere that when app is closed, one doesn't receive notification in the code, rather user see's a notification in notification bar and when clicked on, it invokes getInitialNotification().
- Target Platform : iOS
- Development Operating System: macOS Sierra
- Build tools: Xcode 8.2.1
- React Native version 0.45.1
- RNFirebase Version 2.0.4
Podfile:
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'FroogalMerchant' do
pod "Yoga", :path => "../node_modules/react-native/ReactCommon/yoga"
pod 'React', :path => '../node_modules/react-native', :subspecs => [
'BatchedBridge',
'Core',
'RCTText',
'RCTWebSocket',
'RCTNetwork',
]
pod 'Firebase/Core'
pod 'RNFirebase', :path => '../node_modules/react-native-firebase'
pod 'Firebase/Analytics'
pod 'Firebase/Messaging'
target 'FroogalMerchantTests' do
inherit! :search_paths
# Pods for testing
end
endNotification Listener component
import React, {Component} from 'react'
import {View, Platform} from 'react-native'
import firebase from '../utils/Firebase.js'
export default class NotificationListener extends Component {
componentWillMount() {
firebase.messaging().onMessage((message) => console.log('message', message));
// This gets logged only when the app is open
// Nothing happens when app is closed, no notification is shown either
firebase.messaging().getInitialNotification()
.then((notification) => {
console.log('Notification which opened the app: ', notification);
});
// This is never called
}
render() {
return (
<View style={{width: '100%', height: '100%'}}>
{this.props.children}
</View>
);
}
}Notification I am sending:
{
"registration_ids" : [""],
"notification": {
"title" : "Hi",
"body" : "Heyy"
},
"priority": "high"
}
esutton
Metadata
Metadata
Assignees
Labels
plugin: messagingFCM only - ( messaging() ) - do not use for NotificationsFCM only - ( messaging() ) - do not use for Notifications