Skip to content
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

createLocalNotification() on iOS won't display notification (show_in_foreground: true set) #223

Closed
DavideValdo opened this issue Jul 2, 2017 · 19 comments
Labels
plugin: messaging FCM only - ( messaging() ) - do not use for Notifications

Comments

@DavideValdo
Copy link

DavideValdo commented Jul 2, 2017

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.

@hamzauzumcu
Copy link

hamzauzumcu commented Jul 8, 2017

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
screen shot 2017-07-08 at 13 00 46

@chrisbianca
Copy link
Contributor

@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.

@chrisbianca
Copy link
Contributor

@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.

@leethree
Copy link

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.

@Shinichi52
Copy link

Shinichi52 commented Sep 14, 2017

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",

@sseyha
Copy link

sseyha commented Nov 10, 2017

@Shinichi52
What is the solution???
Help please...

@DavideValdo
Copy link
Author

#595

@kkkevinnn
Copy link

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

@thienlhh
Copy link

@hisokakei Your trick working well, it should be merged to new version. Thank you

@victorsferreira
Copy link

where is it documented?

@Shinichi52
Copy link

@sseyha i'm using react-native-fcm. it's working fine

@robert-stevens
Copy link

@hisokakei I've only added that flag after doing an initial build. Would I need to relink the plugin?

@kkkevinnn
Copy link

@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

@escobar5
Copy link

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
      });

@ferprez
Copy link

ferprez commented Feb 27, 2018

+1

@vulkandev
Copy link

+1 still struggling

@WaldoJeffers
Copy link

Me too :/ Any ideas? It works well on Android, but not on iOS

@Ehesp
Copy link
Member

Ehesp commented Mar 1, 2018

Guys please refer to #595

As it stands, we're re-working the entire side of messaging.

@chrisbianca
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: messaging FCM only - ( messaging() ) - do not use for Notifications
Projects
None yet
Development

No branches or pull requests