diff --git a/src/components/UpdateAppModal/index.tsx b/src/components/UpdateAppModal/index.tsx
index 95ab8953b..34202f31d 100644
--- a/src/components/UpdateAppModal/index.tsx
+++ b/src/components/UpdateAppModal/index.tsx
@@ -4,17 +4,32 @@ import NiPrimaryButton from '../form/PrimaryButton';
import styles from './styles';
import { IS_IOS } from '../../core/data/constants';
+const ANDROID_STORE_WEB_URL = 'https://play.google.com/store/apps/details?id=com.alenvi.compani';
+
const UpdateAppModal = () => {
const appUrl = IS_IOS ? 'https://apps.apple.com/app/id/1516691161' : 'market://details?id=com.alenvi.compani';
+ const onPressUpdate = async () => {
+ try {
+ await Linking.openURL(appUrl);
+ } catch (_) {
+ if (!IS_IOS) {
+ try {
+ await Linking.openURL(ANDROID_STORE_WEB_URL);
+ } catch (e) {
+ console.error(e);
+ }
+ }
+ }
+ };
+
return (
Nouvelle version de l'app disponible !
Merci de mettre à jour votre application pour pouvoir continuer à l'utiliser :)
- { Linking.openURL(appUrl); }} />
+
);
};
diff --git a/src/components/steps/LiveInfoItem/index.tsx b/src/components/steps/LiveInfoItem/index.tsx
index 7237350aa..562b2b22e 100644
--- a/src/components/steps/LiveInfoItem/index.tsx
+++ b/src/components/steps/LiveInfoItem/index.tsx
@@ -1,4 +1,4 @@
-import { View, Text, FlatList, Linking, TouchableOpacity } from 'react-native';
+import { View, Text, FlatList, Linking, TouchableOpacity, Alert } from 'react-native';
import get from 'lodash/get';
import { SlotType } from '../../../types/CourseTypes';
import CompaniDate from '../../../core/helpers/dates/companiDates';
@@ -17,10 +17,15 @@ const LiveInfoItem = ({ slots }: LiveInfoItemProps) => {
? (get(slots[0], 'address.fullAddress') || '')
: (get(slots[0], 'meetingLink') || '');
- const openUrl = async (add: string) => (slots[0].step.type === ON_SITE
- ? Linking.openURL(`https://www.google.com/maps/search/?api=1&query=${add}`)
- : Linking.openURL(add)
- );
+ const openUrl = async (add: string) => {
+ try {
+ await (slots[0].step.type === ON_SITE
+ ? Linking.openURL(`https://www.google.com/maps/search/?api=1&query=${add}`)
+ : Linking.openURL(add));
+ } catch (_) {
+ Alert.alert('Erreur', 'Impossible d\'ouvrir ce lien, veuillez contacter votre formateur');
+ }
+ };
return (
<>
diff --git a/src/core/helpers/notifications.ts b/src/core/helpers/notifications.ts
index 7814bc66d..0a3e8cd5c 100644
--- a/src/core/helpers/notifications.ts
+++ b/src/core/helpers/notifications.ts
@@ -26,15 +26,15 @@ type ExpoTokenAndStatusType = {
export const registerForPushNotificationsAsync = async (): Promise => {
if (!Device.isDevice) return { token: null, status: DENIED };
- const { status: existingStatus } = await Notifications.getPermissionsAsync();
- let finalStatus = existingStatus;
+ try {
+ const { status: existingStatus } = await Notifications.getPermissionsAsync();
+ let finalStatus = existingStatus;
- if (existingStatus !== GRANTED) {
- const { status } = await Notifications.requestPermissionsAsync();
- finalStatus = status;
- }
+ if (existingStatus !== GRANTED) {
+ const { status } = await Notifications.requestPermissionsAsync();
+ finalStatus = status;
+ }
- try {
const { data: token } = await Notifications
.getExpoPushTokenAsync({ projectId: Constants.expoConfig?.extra?.eas.projectId });
await asyncStorage.setExpoToken(token);