This code works correctly on Android:
firebase.database().ref('gifts').on('child_added', (snap) => {
gift = snap.val();
firebase.messaging().createLocalNotification({
body: gift.name,
show_in_foreground: true
})
})
On iOS, i just get this warning from React Native:
messaging_notification_received
with no listeners registered.
.onMessage(message) works fine
When I build the .xcworkspace, I can get this from XCode's console:
2017-07-02 18:47:52.015430+0200 appname[1081:1020773] You've implemented -[<UIApplicationDelegate> application:didReceiveRemoteNotification:fetchCompletionHandler:], but you still need to add "remote-notification" to the list of your supported UIBackgroundModes in your Info.plist.
EDIT: Added flag to plist, message disappeared but nothing changes:
Also i noticed:
2017-07-02 19:32:36.452674+0200 app[1086:1026966] [Firebase/Messaging][I-FCM001000] FIRMessaging Remote Notifications proxy enabled, will swizzle remote notification receiver handlers. Add "FirebaseAppDelegateProxyEnabled" to your Info.plist and set it to NO
2017-07-02 19:32:36.453 app[1086] <Notice> [Firebase/Messaging][I-FCM001000] FIRMessaging Remote Notifications proxy enabled, will swizzle remote notification receiver handlers. Add "FirebaseAppDelegateProxyEnabled" to your Info.plist and set it to NO
Still, notifications sent by triggering FCM via cURL just work when app is in the background.
I am getting the same error.
ED陌T: i solved the error. I have forgotten to turn push notification status on
Make sure you give permissions like below
@DavideValdo The fact that you're getting messaging_notification_received
as an error means that the notification is triggering, it's just not displaying via the OS. Try adding a title
parameter to your notification and see whether this works?
As an aside, show_in_foreground
is Android specific functionality and should only be required for remote notifications. It's also something we're considering removing from RNFirebase Messaging but before we do, we'll explain how to do something similar in your own code.
@DavideValdo I'm going to assume that this is no longer an issue and close it. Please let me know if that is not the case.
I'm getting the same error from React Native on iOS:
Sending `messaging_notification_received` with no listeners registered.
The local message I sent is like this:
{
body: 'My Notification Message',
id: '1503311359441',
local_notification: true,
show_in_foreground: true,
title: 'My Notification Title',
_notificationType: 'local_notification',
}
It works fine on Android, and message from remote works on iOS too.
I has the same issue on IOS. On android working fine. I'm using "react-native-firebase": "2.1.4","react": "16.0.0-alpha.12" and "react-native": "0.47.2",
@Shinichi52
What is the solution???
Help please...
A quick hack to this issue
adding below flag during create local notification
if([details objectForKey:@"show_in_foreground"] != nil) {
if([(NSNumber *)details[@"show_in_foreground"] boolValue] == YES) {
[content setValue:@YES forKeyPath:@"shouldAlwaysAlertWhileAppIsForeground"];
}
}
You may refer to full code in this branch ios-foreground-notif
@hisokakei Your trick working well, it should be merged to new version. Thank you
where is it documented?
@sseyha i'm using react-native-fcm. it's working fine
@hisokakei I've only added that flag after doing an initial build. Would I need to relink the plugin?
@uppercase-army you need to rebuild your app to make it work as it changed native code.
The change is merged to master too. You may upgrade your library to master
The version I'm using contains the code that @hisokakei posted, still my local notification wont show up when in foreground, any ideas?
this is my notification object:
messaging.createLocalNotification({
body: 'message',
title: 'title',
local_notification: true,
priority: 'high',
show_in_foreground: true
});
+1
+1 still struggling
Me too :/ Any ideas? It works well on Android, but not on iOS
Guys please refer to https://github.com/invertase/react-native-firebase/issues/595
As it stands, we're re-working the entire side of messaging.
Good news, the long awaited alpha of our messaging and notifications overhaul is now available!!
Check out the release notes here: https://github.com/invertase/react-native-firebase/releases/tag/v4.0.0-alpha.1
If you have any comments and suggestions or want to report an issue, come find us on Discord
Most helpful comment
I has the same issue on IOS. On android working fine. I'm using "react-native-firebase": "2.1.4","react": "16.0.0-alpha.12" and "react-native": "0.47.2",