Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[General] [add] - Add openSettings method to Linking module #23965

Closed

Conversation

estevaolucas
Copy link

@estevaolucas estevaolucas commented Mar 15, 2019

Summary

This will create a cross-platform and safe way to programmatically open the app's settings into the iOS /Android Settings app.

Right now it's possible to open the app's settings, but only for iOS via Linking.openURL("app-settings:")

To do the same for Android, you need to either create NodeModule or install a dependency such as react-native-open-settings.

Why this new method is useful: since Android 6, app permissions work similar to iOS. It's granular and it's requested in the app runtime.

https://developer.android.com/guide/topics/permissions/overview#runtime_requests_android_60_and_higher

If the device is running Android 6.0 (API level 23) or higher, and the app's targetSdkVersion is 23 or higher, the user isn't notified of any app permissions at install time. Your app must ask the user to grant the dangerous permissions at runtime. When your app requests permission, the user sees a system dialog telling the user which permission group your app is trying to access. The dialog includes a Deny and Allow button.

Thus, if the user checks the "Never ask again box" and taps "Deny", for some specific permission, the only way to change the permission is going to the Android Setting app.

And that's where this new method becomes useful. It'll allow our apps to programmatically send the the user to settings app.

Also, openSettings() doesn't receive a parameter to redirect to specific subsections of the Settings app because there's no public API to do it on iOS (there's a way to have, via private API, but it causes the app to get rejected.)

Changelog

Create Linking.openSettings() for iOS and Android;

[General] [add ] - Add openSetting method to Linking module

Test Plan

With <Button onPress={() => Linking.openSettings()} title="Settings" color="#841584" /> it's possible to test this new method.

TODO:

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 15, 2019
@pull-bot
Copy link

pull-bot commented Mar 15, 2019

Messages
📖

📋 Changelog Format - Did you include a Changelog? A changelog entry has the following format: [CATEGORY] [TYPE] - Message.

CATEGORY may be:
  • General
  • iOS
  • Android

TYPE may be:

  • Added, for new features.
  • Changed, for changes in existing functionality.
  • Deprecated, for soon-to-be removed features.
  • Removed, for now removed features.
  • Fixed, for any bug fixes.
  • Security, in case of vulnerabilities.

MESSAGE may answer "what and why" on a feature level. Use this to briefly tell React Native users about notable changes.

Generated by 🚫 dangerJS against 787875c

Copy link
Contributor

@cpojer cpojer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your PR. I think it makes sense to have this cross platform feature right out of the box.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cpojer is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@estevaolucas estevaolucas force-pushed the feat/linking-opensettings branch from 46f0b23 to 4d7a951 Compare March 18, 2019 14:08
@estevaolucas
Copy link
Author

@cpojer I ended up overriding your commit by mistake with my force push. I just updated it including a commit doing the same you did. Thanks

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cpojer is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@cpojer
Copy link
Contributor

cpojer commented Mar 18, 2019

That's alright, thanks for letting me know :)

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @elucaswork in fa426cf.

When will my fix make it into a release? | Upcoming Releases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API: Linking API: Settings CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants