react-native icon indicating copy to clipboard operation
react-native copied to clipboard

`Linking.openURL` throws an error with formatted phone numbers on iOS

Open Illu opened this issue 1 year ago • 0 comments

Description

There seems to be a regression with the Linking.openURL where formatted phone numbers that include spaces will throw the following error while testing on a iOS device:

Possible Unhandled Promise Rejection (id: 4):
Error: Unable to open URL: file:///private/var/containers/Bundle/Application/4D059EA1-34C4-4242-BFA0-068098E749C6/test.app/tel:(418)%20000-0000

React Native Version

0.72.1

Output of npx react-native info

System: OS: macOS 13.0 CPU: (12) arm64 Apple M2 Pro Memory: 82.66 MB / 16.00 GB Shell: version: 5.8.1 path: /bin/zsh Binaries: Node: version: 18.15.0 path: ~/.nvm/versions/node/v18.15.0/bin/node Yarn: version: 1.22.19 path: ~/.nvm/versions/node/v18.15.0/bin/yarn npm: version: 9.5.0 path: ~/.nvm/versions/node/v18.15.0/bin/npm Watchman: version: 2023.06.08.00 path: /opt/homebrew/bin/watchman Managers: CocoaPods: version: 1.12.1 path: /Users/maximenory/.rvm/gems/ruby-3.1.3/bin/pod SDKs: iOS SDK: Platforms: - DriverKit 22.4 - iOS 16.4 - macOS 13.3 - tvOS 16.4 - watchOS 9.4 Android SDK: API Levels: - "30" - "31" - "33" - "34" Build Tools: - 30.0.3 - 33.0.0 - 34.0.0 System Images: - android-34 | Google APIs ARM 64 v8a Android NDK: Not Found IDEs: Android Studio: 2022.2 AI-222.4459.24.2221.10121639 Xcode: version: 14.3.1/14E300c path: /usr/bin/xcodebuild Languages: Java: version: 17.0.7 path: /usr/bin/javac Ruby: version: 3.1.3 path: /Users/maximenory/.rvm/rubies/ruby-3.1.3/bin/ruby npmPackages: "@react-native-community/cli": Not Found react: installed: 18.2.0 wanted: 18.2.0 react-native: installed: 0.72.1 wanted: 0.72.1 react-native-macos: Not Found npmGlobalPackages: "react-native": Not Found Android: hermesEnabled: true newArchEnabled: false iOS: hermesEnabled: true newArchEnabled: false

Steps to reproduce

This only occurs on an iOS Device (not a simulator)

Trying to call Linking.openURL with a phone number that contains spaces won't work (ex: tel:(418) 000-0000), while sending only numbers will work as expected (ex: tel:4180000000)

Snack, code example, screenshot, or link to a repository

Test this snippet running on a iOS device:

<TouchableOpacity onPress={() => Linking.openURL('tel:0000000000')}>
    <Text>This will work</Text>
 </TouchableOpacity>
 <TouchableOpacity onPress={() => Linking.openURL('tel:(418) 000-0000')}>
     <Text>This will throw an error</Text>
 </TouchableOpacity>

Illu avatar Jul 06 '23 20:07 Illu