diff --git a/blue_modules/notifications.js b/blue_modules/notifications.js index b3d7516fe..b68924104 100644 --- a/blue_modules/notifications.js +++ b/blue_modules/notifications.js @@ -1,9 +1,10 @@ import PushNotificationIOS from '@react-native-community/push-notification-ios'; -import { Alert } from 'react-native'; +import { Alert, Platform } from 'react-native'; import Frisbee from 'frisbee'; -import { getApplicationName, getVersion, getSystemName, getSystemVersion } from 'react-native-device-info'; +import { getApplicationName, getVersion, getSystemName, getSystemVersion, hasGmsSync, hasHmsSync } from 'react-native-device-info'; import AsyncStorage from '@react-native-async-storage/async-storage'; import loc from '../loc'; + const PushNotification = require('react-native-push-notification'); const constants = require('./constants'); const PUSH_TOKEN = 'PUSH_TOKEN'; @@ -28,6 +29,7 @@ function Notifications(props) { return false; }; + Notifications.isNotificationsCapable = hasGmsSync() || hasHmsSync() || Platform.OS !== 'android'; /** * Calls `configure`, which tries to obtain push token, save it, and registers all associated with * notifications callbacks @@ -120,6 +122,7 @@ function Notifications(props) { * @returns {Promise} TRUE if permissions were obtained, FALSE otherwise */ Notifications.tryToObtainPermissions = async function () { + if (!Notifications.isNotificationsCapable) return false; if (await Notifications.getPushToken()) { // we already have a token, no sense asking again, just configure pushes to register callbacks and we are done if (!alreadyConfigured) configureNotifications(); // no await so it executes in background while we return TRUE and use token @@ -127,7 +130,7 @@ function Notifications(props) { } if (await AsyncStorage.getItem(NOTIFICATIONS_NO_AND_DONT_ASK_FLAG)) { - // user doesnt want them + // user doesn't want them return false; } diff --git a/screen/settings/settings.js b/screen/settings/settings.js index aa80054e8..6c8e251d6 100644 --- a/screen/settings/settings.js +++ b/screen/settings/settings.js @@ -6,6 +6,7 @@ import navigationStyle from '../../components/navigationStyle'; import { BlueListItem, BlueHeaderDefaultSub } from '../../BlueComponents'; import loc from '../../loc'; import { BlueStorageContext } from '../../blue_modules/storage-context'; +import Notifications from '../../blue_modules/notifications'; const styles = StyleSheet.create({ root: { @@ -28,7 +29,9 @@ const Settings = () => { navigate('Language')} chevron /> navigate('EncryptStorage')} testID="SecurityButton" chevron /> navigate('NetworkSettings')} chevron /> - navigate('NotificationSettings')} chevron /> + {Notifications.isNotificationsCapable && ( + navigate('NotificationSettings')} chevron /> + )} navigate('SettingsPrivacy')} chevron /> navigate('About')} testID="AboutButton" chevron />