Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16552

React Native push notifications iOS - number pending notifications

$
0
0

I use React Push Notifications (https://github.com/zo0r/react-native-push-notification) with localNotificationSchedule for launch notifications, but in iOS the number of push notifications is never destroyed.

Even if I select notifications the number doesn't go down...

This number: (in icon from desktop)

enter image description here

My code:

import PushNotificationIOS from "@react-native-community/push-notification-ios";

var PushNotification = require("react-native-push-notification");

  PushNotification.configure({

    onRegister: function(token) {
      console.log("TOKEN:", token);
    },

    onNotification: function(notification) {
      console.log("NOTIFICATION:", notification);

        let num = 0;
        if (Platform.OS === 'ios') {
          num = notification.data.num;
        } else {
          num = notification.userInfo.num;
        }        

        switch(num) {

          case 1:
            NavigationService.navigate('OnePage');
            break;
          case 2:
            NavigationService.navigate('TwoPage');
            break;     
          default:
            NavigationService.navigate('Home');

      }

      if (Platform.OS === 'ios') {
        notification.finish(PushNotificationIOS.FetchResult.NoData);
      }
    },

    senderID: "YOUR GCM (OR FCM) SENDER ID",

    permissions: {
      alert: true,
      badge: true,
      sound: true
    },

    popInitialNotification: true,


    requestPermissions: true    
  });

class IndexNavigator extends React.Component {
...

Apparently, according to the documentation this code should be correct, but even if I press the notifications and redirect me to the page I want. The number in the icon never decreases, it always increases.

Anyone know why this can happen?


Viewing all articles
Browse latest Browse all 16552

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>