罗广聪

可以打电话了

... ... @@ -11,39 +11,40 @@ import {
AsyncStorage,
Button,
ScrollView,
Linking
Linking,
Platform
} from "react-native";
import { StackNavigator, TabNavigator } from "react-navigation";
const LaunchURL = function (url) {
Linking.canOpenURL(url).then(supported => {
const LaunchURL = function(url) {
Linking.canOpenURL(url)
.then(supported => {
if (!supported) {
console.log('Can\'t handle url: ' + url);
console.log("Can't handle url: " + url);
} else {
Linking.openURL(url)
.catch(err => {
if (url.includes('telprompt')) {
Linking.openURL(url).catch(err => {
if (url.includes("telprompt")) {
// telprompt was cancelled and Linking openURL method sees this as an error
// it is not a true error so ignore it to prevent apps crashing
// see https://github.com/anarchicknight/react-native-communications/issues/39
} else {
console.warn('openURL error', err)
console.warn("openURL error", err);
}
});
}
}).catch(err => console.warn('An unexpected error happened', err));
})
.catch(err => console.warn("An unexpected error happened", err));
};
const phonecall = function (phoneNumber, prompt) {
const phonecall = function(phoneNumber, prompt) {
let url;
if (Platform.OS !== 'android') {
url = prompt ? 'telprompt:' : 'tel:';
}
else {
url = 'tel:';
if (Platform.OS !== "android") {
url = prompt ? "telprompt:" : "tel:";
} else {
url = "tel:";
}
url += phoneNumber;
LaunchURL(url);
}
};
export default class Mine extends Component {
constructor(props) {
... ... @@ -325,9 +326,12 @@ export default class Mine extends Component {
/>
</View>
</TouchableOpacity>
<TouchableOpacity style={styles.itemContainer} onPress={() => {
<TouchableOpacity
style={styles.itemContainer}
onPress={() => {
phonecall("4001-608876", true);
}}>
}}
>
<View style={styles.itemLeft}>
<Text style={styles.leftTitle}>客服电话</Text>
</View>
... ...