mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-02-22 06:52:41 +01:00
ADD: Do not show notification settings if device does not support it.
This commit is contained in:
parent
e9a5539af3
commit
95ea380e7f
2 changed files with 10 additions and 4 deletions
|
@ -1,9 +1,10 @@
|
||||||
import PushNotificationIOS from '@react-native-community/push-notification-ios';
|
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 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 AsyncStorage from '@react-native-async-storage/async-storage';
|
||||||
import loc from '../loc';
|
import loc from '../loc';
|
||||||
|
|
||||||
const PushNotification = require('react-native-push-notification');
|
const PushNotification = require('react-native-push-notification');
|
||||||
const constants = require('./constants');
|
const constants = require('./constants');
|
||||||
const PUSH_TOKEN = 'PUSH_TOKEN';
|
const PUSH_TOKEN = 'PUSH_TOKEN';
|
||||||
|
@ -28,6 +29,7 @@ function Notifications(props) {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Notifications.isNotificationsCapable = hasGmsSync() || hasHmsSync() || Platform.OS !== 'android';
|
||||||
/**
|
/**
|
||||||
* Calls `configure`, which tries to obtain push token, save it, and registers all associated with
|
* Calls `configure`, which tries to obtain push token, save it, and registers all associated with
|
||||||
* notifications callbacks
|
* notifications callbacks
|
||||||
|
@ -120,6 +122,7 @@ function Notifications(props) {
|
||||||
* @returns {Promise<boolean>} TRUE if permissions were obtained, FALSE otherwise
|
* @returns {Promise<boolean>} TRUE if permissions were obtained, FALSE otherwise
|
||||||
*/
|
*/
|
||||||
Notifications.tryToObtainPermissions = async function () {
|
Notifications.tryToObtainPermissions = async function () {
|
||||||
|
if (!Notifications.isNotificationsCapable) return false;
|
||||||
if (await Notifications.getPushToken()) {
|
if (await Notifications.getPushToken()) {
|
||||||
// we already have a token, no sense asking again, just configure pushes to register callbacks and we are done
|
// 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
|
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)) {
|
if (await AsyncStorage.getItem(NOTIFICATIONS_NO_AND_DONT_ASK_FLAG)) {
|
||||||
// user doesnt want them
|
// user doesn't want them
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import navigationStyle from '../../components/navigationStyle';
|
||||||
import { BlueListItem, BlueHeaderDefaultSub } from '../../BlueComponents';
|
import { BlueListItem, BlueHeaderDefaultSub } from '../../BlueComponents';
|
||||||
import loc from '../../loc';
|
import loc from '../../loc';
|
||||||
import { BlueStorageContext } from '../../blue_modules/storage-context';
|
import { BlueStorageContext } from '../../blue_modules/storage-context';
|
||||||
|
import Notifications from '../../blue_modules/notifications';
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
root: {
|
root: {
|
||||||
|
@ -28,7 +29,9 @@ const Settings = () => {
|
||||||
<BlueListItem title={loc.settings.language} onPress={() => navigate('Language')} chevron />
|
<BlueListItem title={loc.settings.language} onPress={() => navigate('Language')} chevron />
|
||||||
<BlueListItem title={loc.settings.encrypt_title} onPress={() => navigate('EncryptStorage')} testID="SecurityButton" chevron />
|
<BlueListItem title={loc.settings.encrypt_title} onPress={() => navigate('EncryptStorage')} testID="SecurityButton" chevron />
|
||||||
<BlueListItem title={loc.settings.network} onPress={() => navigate('NetworkSettings')} chevron />
|
<BlueListItem title={loc.settings.network} onPress={() => navigate('NetworkSettings')} chevron />
|
||||||
<BlueListItem title={loc.settings.notifications} onPress={() => navigate('NotificationSettings')} chevron />
|
{Notifications.isNotificationsCapable && (
|
||||||
|
<BlueListItem title={loc.settings.notifications} onPress={() => navigate('NotificationSettings')} chevron />
|
||||||
|
)}
|
||||||
<BlueListItem title={loc.settings.privacy} onPress={() => navigate('SettingsPrivacy')} chevron />
|
<BlueListItem title={loc.settings.privacy} onPress={() => navigate('SettingsPrivacy')} chevron />
|
||||||
<BlueListItem title={loc.settings.about} onPress={() => navigate('About')} testID="AboutButton" chevron />
|
<BlueListItem title={loc.settings.about} onPress={() => navigate('About')} testID="AboutButton" chevron />
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
Loading…
Add table
Reference in a new issue