How to use the react-native-push-notification.setApplicationIconBadgeNumber function in react-native-push-notification

To help you get started, we’ve selected a few react-native-push-notification examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mongrov / roverz / src / network / PushService.js View on Github external
if (PushService._token.os === 'android') {
        data.token = {
          gcm: PushService._token.token,
        };
      } else if (PushService._token.os === 'ios') {
        data.token = {
          apn: PushService._token.token,
        };
      }

      // console.log('==============> push =================', data);
      Meteor.call('raix:push-update', data, (err, res) => {
        AppUtil.debug('Push backend', JSON.stringify(res));
      });
      // clear badges on init
      PushNotification.setApplicationIconBadgeNumber(0);
    }
  }
github keybase / client / shared / actions / platform-specific / push.native.js View on Github external
const updateAppBadge = (_, action) => {
  const count = (action.payload.badgeState.conversations || []).reduce(
    (total, c) => (c.badgeCounts ? total + c.badgeCounts[`${RPCTypes.commonDeviceType.mobile}`] : total),
    0
  )

  PushNotifications.setApplicationIconBadgeNumber(count)
  // Only do this native call if the count actually changed, not over and over if its zero
  if (count === 0 && lastCount !== 0) {
    PushNotifications.cancelAllLocalNotifications()
  }
  lastCount = count
}
github crownstone / CrownstoneApp / js / notifications / LocalNotifications.ts View on Github external
ongoing: false,
            });
          }
          else {
            PushNotification.localNotification({
              category: 'newMessage',

              data: data,
              userInfo: data,

              title: "New Message Found\n", // (optional, for iOS this is only used in apple watch, the title will be the app name on other iOS devices)
              message: messageData.content, // (required)
              playSound: true, // (optional) default: true
            });
          }
          PushNotification.setApplicationIconBadgeNumber(1);
        }
        else {
          if (!alreadyNotified) {
            Toast.showWithGravity('  Message found!  ', Toast.SHORT, Toast.CENTER);
            LOG.info("LocalNotifications: on the front, just vibe.");
            // notify the user by vibration that the crownstone will be switched.
            Vibration.vibrate(200, false);
          }
        }

        return true;
      }
    }

    return false;
  },
github crownstone / CrownstoneApp / js / backgroundProcesses / BackgroundProcessHandler.ts View on Github external
_clearBadge() {
    // if there is a badge number, remove it on opening the app.
    PushNotification.setApplicationIconBadgeNumber(0);
  }
github DefinitelyTyped / DefinitelyTyped / types / react-native-push-notification / react-native-push-notification-tests.ts View on Github external
},
    onRegister: (token) => {},
    senderID: 'XXX',
    popInitialNotification: false,
    requestPermissions: true,
});

PushNotification.unregister();
PushNotification.localNotification = (details) => {};
PushNotification.localNotificationSchedule = (details) => {};
PushNotification.requestPermissions();
PushNotification.presentLocalNotification = (details) => {};
PushNotification.scheduleLocalNotification = (details) => {};
PushNotification.cancelLocalNotifications = (details) => {};
PushNotification.cancelAllLocalNotifications();
PushNotification.setApplicationIconBadgeNumber(1);
PushNotification.getApplicationIconBadgeNumber((badgeCount) => {});
PushNotification.popInitialNotification((notification) => {});
PushNotification.checkPermissions((checkPermissions) => {});
PushNotification.abandonPermissions();
PushNotification.registerNotificationActions(['Accept', 'Reject', 'Yes', 'No']);
PushNotification.clearAllNotifications();
github guardian / editions / projects / Mallard / src / helpers / push-notifications.ts View on Github external
number =>
            number > 0 && PushNotification.setApplicationIconBadgeNumber(0),
    )
github mattermost / mattermost-mobile / app / components / push_notification / push_notification.js View on Github external
componentWillReceiveProps(props) {
        if (this.isConfigured) {
            DeviceNotification.setApplicationIconBadgeNumber(props.mentionCount);
        }
    }