Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/components/UpdateAppModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pourquoi ne pas passer directement ANDROID_STORE_WEB_URL ici ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c'est pas la même url, ici c'est l'url market pour ouvrir le play store sur la page de compani, l'url web c'est comme son nom l'indique une url web qui s'ouvre dans un navigateur

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oui je sais bien mais si tu passes tout le temps l'url web ca n'ouvre pas automatiquement dans le play store s'il est installé sur ton tel et sur le web sinon ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pas sur 100% des tél non


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 (
<NiModal visible={true}>
<Text style={styles.title}>Nouvelle version de l&apos;app disponible !</Text>
<Text style={styles.contentText}>
Merci de mettre à jour votre application pour pouvoir continuer à l&apos;utiliser :)
</Text>
<NiPrimaryButton customStyle={styles.button} caption="Mettre à jour"
onPress={() => { Linking.openURL(appUrl); }} />
<NiPrimaryButton customStyle={styles.button} caption="Mettre à jour" onPress={onPressUpdate} />
</NiModal>
);
};
Expand Down
15 changes: 10 additions & 5 deletions src/components/steps/LiveInfoItem/index.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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 (
<>
Expand Down
14 changes: 7 additions & 7 deletions src/core/helpers/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ type ExpoTokenAndStatusType = {
export const registerForPushNotificationsAsync = async (): Promise<ExpoTokenAndStatusType> => {
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);
Expand Down
Loading