evollu / react-native-fcm

react native module for firebase cloud messaging and local notification
MIT License
1.73k stars 682 forks source link

I don't receive notification when I have locked mobile screen. #490

Open juvasquezg opened 7 years ago

juvasquezg commented 7 years ago

Hi,

I don't receive notification when I have locked mobile screen.

I'm not checking this repo every day since it is fairly stable now. If you have found a bug or need immediate attention please [AT]me

Please include following information for better support

What version of RN and react-native-fcm are you running?

"react-native-fcm": "7.5.1"

What device are you using? (e.g iOS9 emulator, Android 6 device)?

Huawei P7 - Android 5.1 lollipop

Is your app running in foreground, background or not running?

locked screen

OS

Android

React Native

react-native 0.42

Advanced: Have you tried adding break point in native handlers to see if message gets delivered? can share a project with issue?

I have

componentDidMount() {
    // if redux persist is not active fire startup action
    FCM.requestPermissions();
    FCM.getFCMToken()
      .then(token => {
        console.log(token)
      })

    FCM.on(FCMEvent.Notification, async (notif) => {
      console.log(notif)
      if (notif && notif.local_notification) {
        return
      }
      FCM.presentLocalNotification({
        vibrate: 500,
        title: notif.title,
        body: notif.body,
        priority: "high",
        show_in_foreground: true
      })
      if (Platform.OS === 'ios') {
        switch (notif._notificationType) {
          case NotificationType.Remote:
            notif.finish(RemoteNotificationResult.NewData); //other types available: RemoteNotificationResult.NewData, RemoteNotificationResult.ResultFailed
            break;
          case NotificationType.NotificationResponse:
            notif.finish();
            break;
          case NotificationType.WillPresent:
            notif.finish(WillPresentNotificationResult.All); //other types available: WillPresentNotificationResult.None
            break;
        }
      }
    });

    FCM.on(FCMEvent.RefreshToken, token => {
      console.log(token);
    });
  }
ogelacinyc commented 7 years ago

same issue here

jjdp commented 7 years ago

possibly #469