Closed
Description
Based on the documentation for openURL, I expect the returned promise to be rejected when pressing Cancel
on the confirmation alert in iOS.
React Native version:
React Native Environment Info:
System:
OS: macOS High Sierra 10.13.6
CPU: (4) x64 Intel(R) Core(TM) i7-5557U CPU @ 3.10GHz
Memory: 428.16 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 8.12.0 - /usr/local/bin/node
Yarn: 1.9.4 - /usr/local/bin/yarn
npm: 6.4.1 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
Android SDK:
API Levels: 23, 25, 26, 27
Build Tools: 23.0.1, 25.0.0, 25.0.2, 26.0.1, 26.0.2, 27.0.3, 28.0.1, 28.0.3
System Images: android-23 | Intel x86 Atom_64, android-23 | Google APIs Intel x86 Atom_64, android-27 | Google APIs Intel x86 Atom
IDEs:
Android Studio: 3.3 AI-182.5107.16.33.5314842
Xcode: 10.1/10B61 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.3 => 16.8.3
react-native: 0.59.8 => 0.59.8
npmGlobalPackages:
create-react-native-app: 1.0.0
react-native-cli: 2.0.1
react-native-git-upgrade: 0.2.7
solidarity-react-native: 2.0.1
Steps To Reproduce
- Call
openURL
on a phone number. - Press the
Cancel
option.
Describe what you expected to happen:
- Promise is rejected.
Describe what actually happens:
- Promise is resolved.
Snack, code example, or link to a repository:
https://snack.expo.io/S1g2RMvhE
Code snippet:
import React, { Component } from 'react'
import { View, StyleSheet, Button, Linking, Alert } from 'react-native'
export default class App extends Component {
handlePress = () => {
const link = 'tel:2125551212'
Linking.openURL(link)
.then(() => Alert.alert('success'))
.catch(() => Alert.alert('cancel'))
}
render() {
return (
<View style={styles.container}>
<Button title="Test Button" onPress={this.handlePress} />
</View>
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
})