facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
118.87k stars 24.3k forks source link

Linking.openUrl('sms:number') doesn't work on (some) Android phones #32571

Closed lfrkovic-spaceiq closed 2 years ago

lfrkovic-spaceiq commented 2 years ago

Description

Trying to implement a feature to open an SMS app on button press. Official docs say scheme for SMS is "sms" (https://reactnative.dev/docs/linking#built-in-url-schemes)

Linking.openUrl('sms:xxxxxx')

results in a system message from Android saying "Cannot start a conversation" on some Android phones (e.g. Android 11 on Samsung Galaxy A22)

Linking.openUrl('smsto:xxxxxx')

correctly proceeds to open the messaging app picker (again on Android 11 on Samsung Galaxy A22)

Testing with

Linking.canOpenUrl('sms:xxxxxx')
Linking.canOpenUrl('smsto:xxxxxx')

returns true for both cases (Android 11 on Samsung Galaxy A22).

Is there a way to test/determine which scheme should be used on a particular Android phone?

Version

0.66.1

Output of react-native info

System: OS: macOS 12.0.1 CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz Memory: 1.27 GB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 16.3.0 - ~/.asdf/installs/nodejs/16.3.0/bin/node Yarn: 1.22.17 - /usr/local/bin/yarn npm: 7.15.1 - ~/.asdf/installs/nodejs/16.3.0/bin/npm Watchman: 2021.10.18.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.10.1 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.0.1, iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0 Android SDK: API Levels: 28, 29, 30 Build Tools: 30.0.2, 30.0.3 System Images: android-30 | Google APIs Intel x86 Atom, android-30 | Google Play Intel x86 Atom Android NDK: Not Found IDEs: Android Studio: 2020.3 AI-203.7717.56.2031.7784292 Xcode: 13.1/13A1030d - /usr/bin/xcodebuild Languages: Java: 1.8.0_292 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 17.0.2 => 17.0.2 react-native: ^0.66.1 => 0.66.1 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Steps to reproduce

In a RN app, add a button that triggers a Linking interface to open an SMS app on Android

Doesn't work on Samsung Galaxy A22, Android 11 (OS shows a message saying Cannot start a conversation)

<Button
  onPress={() => Linking.openUrl("sms:123456")}
  title="Send SMS to 123456"
/>

Works on Samsung Galaxy A22, Android 11 (opens a messaging app picker)

<Button
  onPress={() => Linking.openUrl("smsto:123456")}
  title="Send SMS to 123456"
/>

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

First button doesn't work on my Android phone, second one does. https://snack.expo.dev/sI4IxJkrD

leonidlewis commented 2 years ago

I had same problem Please read following article https://developer.android.com/training/package-visibility/declaring This will help you

vamper424 commented 2 years ago

Está bien, okey aceptted this celphone thats the expired licence.

github-actions[bot] commented 2 years ago

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] commented 2 years ago

This issue was closed because it has been stalled for 7 days with no activity.