Skip to content

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

Closed
estevaolucas wants to merge 3 commits into
react:masterfrom
estevaolucas:feat/linking-opensettings
Closed

[General] [add] - Add openSettings method to Linking module#23965
estevaolucas wants to merge 3 commits into
react:masterfrom
estevaolucas:feat/linking-opensettings

Conversation

@estevaolucas

@estevaolucas estevaolucas commented Mar 15, 2019

Copy link
Copy Markdown

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

pull-bot commented Mar 15, 2019

Copy link
Copy Markdown
Messages
📖

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

DetailsCATEGORY 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

@cpojer cpojer left a comment

Copy link
Copy Markdown
Contributor

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.

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

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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

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

Copy link
Copy Markdown
Contributor

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

cpojer commented Mar 18, 2019

Copy link
Copy Markdown
Contributor

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

@react-native-bot

Copy link
Copy Markdown
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