Showing
1 changed file
with
22 additions
and
18 deletions
| @@ -11,39 +11,40 @@ import { | @@ -11,39 +11,40 @@ import { | ||
| 11 | AsyncStorage, | 11 | AsyncStorage, |
| 12 | Button, | 12 | Button, |
| 13 | ScrollView, | 13 | ScrollView, |
| 14 | - Linking | 14 | + Linking, |
| 15 | + Platform | ||
| 15 | } from "react-native"; | 16 | } from "react-native"; |
| 16 | import { StackNavigator, TabNavigator } from "react-navigation"; | 17 | import { StackNavigator, TabNavigator } from "react-navigation"; |
| 17 | 18 | ||
| 18 | -const LaunchURL = function (url) { | 19 | +const LaunchURL = function(url) { |
| 19 | - Linking.canOpenURL(url).then(supported => { | 20 | + Linking.canOpenURL(url) |
| 21 | + .then(supported => { | ||
| 20 | if (!supported) { | 22 | if (!supported) { |
| 21 | - console.log('Can\'t handle url: ' + url); | 23 | + console.log("Can't handle url: " + url); |
| 22 | } else { | 24 | } else { |
| 23 | - Linking.openURL(url) | 25 | + Linking.openURL(url).catch(err => { |
| 24 | - .catch(err => { | 26 | + if (url.includes("telprompt")) { |
| 25 | - if (url.includes('telprompt')) { | ||
| 26 | // telprompt was cancelled and Linking openURL method sees this as an error | 27 | // telprompt was cancelled and Linking openURL method sees this as an error |
| 27 | // it is not a true error so ignore it to prevent apps crashing | 28 | // it is not a true error so ignore it to prevent apps crashing |
| 28 | // see https://github.com/anarchicknight/react-native-communications/issues/39 | 29 | // see https://github.com/anarchicknight/react-native-communications/issues/39 |
| 29 | } else { | 30 | } else { |
| 30 | - console.warn('openURL error', err) | 31 | + console.warn("openURL error", err); |
| 31 | } | 32 | } |
| 32 | }); | 33 | }); |
| 33 | } | 34 | } |
| 34 | - }).catch(err => console.warn('An unexpected error happened', err)); | 35 | + }) |
| 36 | + .catch(err => console.warn("An unexpected error happened", err)); | ||
| 35 | }; | 37 | }; |
| 36 | -const phonecall = function (phoneNumber, prompt) { | 38 | +const phonecall = function(phoneNumber, prompt) { |
| 37 | let url; | 39 | let url; |
| 38 | - if (Platform.OS !== 'android') { | 40 | + if (Platform.OS !== "android") { |
| 39 | - url = prompt ? 'telprompt:' : 'tel:'; | 41 | + url = prompt ? "telprompt:" : "tel:"; |
| 40 | - } | 42 | + } else { |
| 41 | - else { | 43 | + url = "tel:"; |
| 42 | - url = 'tel:'; | ||
| 43 | } | 44 | } |
| 44 | url += phoneNumber; | 45 | url += phoneNumber; |
| 45 | LaunchURL(url); | 46 | LaunchURL(url); |
| 46 | -} | 47 | +}; |
| 47 | 48 | ||
| 48 | export default class Mine extends Component { | 49 | export default class Mine extends Component { |
| 49 | constructor(props) { | 50 | constructor(props) { |
| @@ -325,9 +326,12 @@ export default class Mine extends Component { | @@ -325,9 +326,12 @@ export default class Mine extends Component { | ||
| 325 | /> | 326 | /> |
| 326 | </View> | 327 | </View> |
| 327 | </TouchableOpacity> | 328 | </TouchableOpacity> |
| 328 | - <TouchableOpacity style={styles.itemContainer} onPress={() => { | 329 | + <TouchableOpacity |
| 330 | + style={styles.itemContainer} | ||
| 331 | + onPress={() => { | ||
| 329 | phonecall("4001-608876", true); | 332 | phonecall("4001-608876", true); |
| 330 | - }}> | 333 | + }} |
| 334 | + > | ||
| 331 | <View style={styles.itemLeft}> | 335 | <View style={styles.itemLeft}> |
| 332 | <Text style={styles.leftTitle}>客服电话</Text> | 336 | <Text style={styles.leftTitle}>客服电话</Text> |
| 333 | </View> | 337 | </View> |
-
Please register or login to post a comment