forked from vergnet/application-amicale
Removed unused functions
This commit is contained in:
parent
c37f6d07a4
commit
81eddd9bdd
2 changed files with 1 additions and 91 deletions
|
@ -1,9 +1,8 @@
|
|||
// @flow
|
||||
|
||||
import * as React from 'react';
|
||||
import {Alert, Clipboard, ScrollView, View} from "react-native";
|
||||
import {ScrollView, View} from "react-native";
|
||||
import AsyncStorageManager from "../../utils/AsyncStorageManager";
|
||||
import NotificationsManager from "../../utils/NotificationsManager";
|
||||
import CustomModal from "../../components/CustomModal";
|
||||
import {Button, Card, List, Subheading, TextInput, Title, withTheme} from 'react-native-paper';
|
||||
|
||||
|
@ -59,23 +58,6 @@ class DebugScreen extends React.Component<Props, State> {
|
|||
}
|
||||
}
|
||||
|
||||
alertCurrentExpoToken() {
|
||||
let token = AsyncStorageManager.getInstance().preferences.expoToken.current;
|
||||
Alert.alert(
|
||||
'Expo Token',
|
||||
token,
|
||||
[
|
||||
{text: 'Copy', onPress: () => Clipboard.setString(token)},
|
||||
{text: 'OK'}
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
async forceExpoTokenUpdate() {
|
||||
await NotificationsManager.forceExpoTokenUpdate();
|
||||
this.alertCurrentExpoToken();
|
||||
}
|
||||
|
||||
showEditModal(item: Object) {
|
||||
this.setState({
|
||||
modalCurrentDisplayItem: item
|
||||
|
@ -142,15 +124,6 @@ class DebugScreen extends React.Component<Props, State> {
|
|||
{this.getModalContent()}
|
||||
</CustomModal>
|
||||
<ScrollView style={{padding: 5}}>
|
||||
<Card style={{margin: 5}}>
|
||||
<Card.Title
|
||||
title={'Notifications'}
|
||||
/>
|
||||
<Card.Content>
|
||||
{DebugScreen.getGeneralItem(() => this.alertCurrentExpoToken(), 'bell', 'Get current Expo Token', '')}
|
||||
{DebugScreen.getGeneralItem(() => this.forceExpoTokenUpdate(), 'bell-ring', 'Force Expo token update', '')}
|
||||
</Card.Content>
|
||||
</Card>
|
||||
<Card style={{margin: 5}}>
|
||||
<Card.Title
|
||||
title={'Preferences'}
|
||||
|
|
|
@ -28,62 +28,6 @@ export default class NotificationsManager {
|
|||
return finalStatus === 'granted';
|
||||
}
|
||||
|
||||
/**
|
||||
* Async function sending a notification without delay to the user
|
||||
*
|
||||
* @param title {String} Notification title
|
||||
* @param body {String} Notification body text
|
||||
* @returns {Promise<import("react").ReactText>} Notification Id
|
||||
*/
|
||||
static async sendNotificationImmediately(title: string, body: string) {
|
||||
await NotificationsManager.askPermissions();
|
||||
return await Notifications.presentLocalNotificationAsync({
|
||||
title: title,
|
||||
body: body,
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Async function sending notification at the specified time
|
||||
*
|
||||
* @param title Notification title
|
||||
* @param body Notification body text
|
||||
* @param time Time at which we should send the notification
|
||||
* @param data Data to send with the notification, used for listeners
|
||||
* @param androidChannelID
|
||||
* @returns {Promise<import("react").ReactText>} Notification Id
|
||||
*/
|
||||
static async scheduleNotification(title: string, body: string, time: number, data: Object, androidChannelID: string): Promise<string> {
|
||||
await NotificationsManager.askPermissions();
|
||||
let date = new Date();
|
||||
date.setTime(time);
|
||||
return Notifications.scheduleLocalNotificationAsync(
|
||||
{
|
||||
title: title,
|
||||
body: body,
|
||||
data: data,
|
||||
ios: { // configuration for iOS.
|
||||
sound: true
|
||||
},
|
||||
android: { // configuration for Android.
|
||||
channelId: androidChannelID,
|
||||
}
|
||||
},
|
||||
{
|
||||
time: time,
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Async function used to cancel the notification of a specific ID
|
||||
* @param notificationID {Number} The notification ID
|
||||
* @returns {Promise}
|
||||
*/
|
||||
static async cancelScheduledNotification(notificationID: number) {
|
||||
await Notifications.cancelScheduledNotificationAsync(notificationID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save expo token to allow sending notifications to this device.
|
||||
* This token is unique for each device and won't change.
|
||||
|
@ -105,13 +49,6 @@ export default class NotificationsManager {
|
|||
}
|
||||
}
|
||||
|
||||
static async forceExpoTokenUpdate() {
|
||||
await NotificationsManager.askPermissions();
|
||||
let expoToken = await Notifications.getExpoPushTokenAsync();
|
||||
// Save token for instant use later on
|
||||
AsyncStorageManager.getInstance().savePref(AsyncStorageManager.getInstance().preferences.expoToken.key, expoToken);
|
||||
}
|
||||
|
||||
static getMachineNotificationWatchlist(callback: Function) {
|
||||
let token = AsyncStorageManager.getInstance().preferences.expoToken.current;
|
||||
if (token !== '') {
|
||||
|
|
Loading…
Reference in a new issue