From 6e2e7f4017b68246058430eae4e0620fce617892 Mon Sep 17 00:00:00 2001 From: Rui Ying Date: Sat, 6 Jun 2020 16:03:57 +0800 Subject: [PATCH] Disable push token on simulators --- src/screens/NoticeScreen.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/screens/NoticeScreen.tsx b/src/screens/NoticeScreen.tsx index 9aaed2c5..3070152e 100644 --- a/src/screens/NoticeScreen.tsx +++ b/src/screens/NoticeScreen.tsx @@ -51,6 +51,7 @@ import { } from '../helpers/notification'; import DateTimePicker from '@react-native-community/datetimepicker'; import Modal from 'react-native-modal'; +import Device from 'react-native-device-info'; import Button from '../components/Button'; import {removeTags} from '../helpers/html'; import Snackbar from 'react-native-snackbar'; @@ -74,8 +75,10 @@ const NoticeScreen: INavigationScreen = (props) => { useEffect(() => { (async () => { - const token = await Notifications.getDevicePushTokenAsync(); - updateDeviceToken(token.data); + if (!Device.isEmulatorSync()) { + const token = await Notifications.getDevicePushTokenAsync(); + updateDeviceToken(token.data); + } })(); }, []);