ios: Open more links directly in apps

bump ver
This commit is contained in:
Nikolai R Kristiansen committed 2017-09-17 23:53:48 +02:00
1 parent 318158f2b3
commit 992f9ccffd
4 files changed
+74 -21

No files matched your search

+19 -2
View File
@@ -11,7 +11,10 @@ export default class About extends Component {
openFacebook() {
/* Ref: https://stackoverflow.com/questions/4810803/open-facebook-page-from-android-app */
const url = 'fb://page/23664032291/';
const url = Platform.select({
ios: 'fb://page/?id=23664032291',
android: 'fb://page/23664032291/'
});
Linking.canOpenURL(url).then(supported => {
if (!supported) {
return Linking.openURL('https://www.facebook.com/studentersamfundet/');
@@ -36,6 +39,20 @@ export default class About extends Component {
}).catch(err => console.error('An error occurred', err));
}
openMap() {
const url = Platform.select({
ios: `comgooglemaps://?q=${CHATEAU_NEUF_ADDRESS}`,
android: `https://www.google.com/maps/search/?api=1&query=${CHATEAU_NEUF_ADDRESS}`
});
Linking.canOpenURL(url).then(supported => {
if (!supported) {
return Linking.openURL(`https://www.google.com/maps/search/?api=1&query=${CHATEAU_NEUF_ADDRESS}`);
} else {
return Linking.openURL(url);
}
}).catch(err => console.error('An error occurred', err));
}
render() {
return (
<ScrollView>
@@ -57,7 +74,7 @@ export default class About extends Component {
<Text style={styles.header}>Adresse</Text>
<Text style={[styles.paragraph, {textAlign: 'center'}]}>Det Norske Studentersamfund{"\n"}Slemdalsveien 15, 0369 Oslo</Text>
<View style={styles.section}>
<Button iconLeft onPress={() => Linking.openURL(`https://www.google.com/maps/search/?api=1&query=${CHATEAU_NEUF_ADDRESS}`)}>
<Button iconLeft onPress={this.openMap}>
<Icon name="map" style={styles.icon} /><NBText> Vis i kart</NBText>
</Button>
</View>