raphaelwoude / capacitor-native-settings Goto Github PK
View Code? Open in Web Editor NEWCapacitor plugin to open native settings screens for android and iOS
License: MIT License
Capacitor plugin to open native settings screens for android and iOS
License: MIT License
Capacitor 5 is now in beta and has minimal changes for plugins. There's a plugin update guide.
It would be great to have a capacitor 5-compatible version of this plugin.
maybe move plugin to https://github.com/capacitor-community
for more popularity
Adds usability to then promise in the method NativeSettings.open to trigger some method when user gets back to screen
Platform:
Android
Current Behavior: Then promise execute immediately when call open method
New Behavior: Then promise wait to user gets back to screen
openSettingsTurnOnLocation = () => {
const options = {
optionAndroid: AndroidSettings.ApplicationDetails,
optionIOS: IOSSettings.App,
};
NativeSettings.open(options).then((data) => {
this.presentAlert('then execution', JSON.stringify(data), '');
});
};
I created a pull request to add this enhancement #31
import android.content.ComponentName;
..
..
else if(action.equals("tts"))
{
if (android.os.Build.VERSION.SDK_INT >= 14)
{
intent = new Intent();
intent.setAction("com.android.settings.TTS_SETTINGS");
}
else
{
intent = new Intent();
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setComponent(new ComponentName("com.android.settings", "com.android.settings.TextToSpeechSettings"));
}
}
,,,,,,,,,,,,,,,,,,,,,
TTS = "tts",
use->
NativeSettings.openAndroid({
option: AndroidSettings.TTS,
});
The first release candidate of Capacitor 6 was released last month, and the official release is scheduled to occur soon.
It would be great to update this plugin to add Capacitor 6 support.
The ionic serve
compiler gives these warning/errors each time. The files are not in those locations. Any thoughts on how to fix this?
[react-scripts] WARNING in ./node_modules/capacitor-native-settings/dist/esm/definitions.js
[react-scripts] Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
[react-scripts] Failed to parse source map from '/Users/saroverhees/Documents/git/appv2/app-v2/node_modules/capacitor-native-settings/src/definitions.ts' file: Error: ENOENT: no such file or directory, open '/Users/saroverhees/Documents/git/appv2/app-v2/node_modules/capacitor-native-settings/src/definitions.ts'
[react-scripts] WARNING in ./node_modules/capacitor-native-settings/dist/esm/index.js
[react-scripts] Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
[react-scripts] Failed to parse source map from '/Users/saroverhees/Documents/git/appv2/app-v2/node_modules/capacitor-native-settings/src/index.ts' file: Error: ENOENT: no such file or directory, open '/Users/saroverhees/Documents/git/appv2/app-v2/node_modules/capacitor-native-settings/src/index.ts'
[react-scripts] WARNING in ./node_modules/capacitor-native-settings/dist/esm/web.js
[react-scripts] Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
[react-scripts] Failed to parse source map from '/Users/saroverhees/Documents/git/appv2/app-v2/node_modules/capacitor-native-settings/src/web.ts' file: Error: ENOENT: no such file or directory, open '/Users/saroverhees/Documents/git/appv2/app-v2/node_modules/capacitor-native-settings/src/web.ts'
@capacitor/cli: 4.3.0
@capacitor/core: 4.3.0
@capacitor/android: 4.3.0
@capacitor/ios: 4.3.0
In case the user denies camera permission, I want to redirect them directly to the App Permissions
setting where they can manually give access. But, it seems that the plugin doesn't support it. The closest I came, is redirecting the user to the ApplicationDetails
setting, then ask them to click on Permission
and then provide the necessary permissions.
Now the issue with this is that, not all Android skins have the same flow. For example, on one of my android device, after redirecting to ApplicationDetails
, I have to click on Privacy
-> Permissions
and then give the permissions.
Direct redirection to the App Permissions
page would fix this and provide a better UX.
Please publish this plugin to NPM :)
Both AndroidSettings and IOSSettings need to be imported in order for the example in the docs to work. If they are not, the error is that they are not defined.
So this is what worked for me:
import {NativeSettings, AndroidSettings, IOSSettings} from 'capacitor-native-settings'
export default {
methods: {
onInput(value) {
NativeSettings.open({
optionAndroid: AndroidSettings.AppNotification,
optionIOS: IOSSettings.App,
})
...
It took me a while to realise how to import this library as NativeSettings
export wasn't documented and I had to read through the source.
An example:
import { NativeSettings } from 'capacitor-native-settings'
NativeSettings.openIOS({ option: 'app' })
or
NativeSettings.openAndroid({ option: 'application' })
The open()
function returns a Promise, which includes a boolean status. Could you elaborate on the scenarios, where the promise is
Thank you in advance!
Android SDK 34+ will be mandatory after August 2024. Do you have plans to upgrade this plugin?
Edit: Duplicated issue.
It was tested in gradle 8.0.0 with capacitor-native-settings 5.0.0 and 5.0.1. The following error is displayed:
[capacitor] ร Running Gradle build - failed!
[capacitor] [error]
[capacitor] FAILURE: Build failed with an exception.
[capacitor]
[capacitor] * Where:
[capacitor] Settings file 'C:......\android\settings.gradle' line: 5
[capacitor]
[capacitor] * What went wrong:
[capacitor] A problem occurred evaluating settings 'android'.
[capacitor] > Could not open dsl generic class cache for script 'C:....\android\capacitor.settings.gradle' (C:\Users.....gradle\caches\8.0.2\scripts\17bc3sygz4ahd3d0s8rt4pb12).
[capacitor] > BUG! exception in phase 'semantic analysis' in source unit 'BuildScript' Unsupported class file major version 64
[capacitor]
[capacitor] * Try:
[capacitor] > Run with --stacktrace option to get the stack trace.
[capacitor] > Run with --info or --debug option to get more log output.
[capacitor] > Run with --scan to get full insights.
[capacitor]
[capacitor] * Get more help at https://help.gradle.org
[capacitor]
[capacitor] BUILD FAILED in 647ms
[capacitor]
[ERROR] An error occurred while running subprocess capacitor.
Some solution for that?
capacitor-native-settings is not compatible with @capacitor/core 6.0.0
I received this warning...
UI API called from background thread: UIApplication.canOpenURL(_:) must be used from main thread only
...when navigating back to my application.
It seems like the main thread should be retrieved before calling the UIApplication.shared.canOpenURL
method. Maybe something like this would help?
DispatchQueue.main.async {
UIApplication.shared.open(settingsUrl, completionHandler: { (success) in
call.resolve([
"status": success
])
});
}
Thanks
It looks like Apple added support for deep-linking to the notification settings for an App using UIApplication.openNotificationSettingsURLString
. It would be nice to use this when available instead of a hardcoded string. This way IOSSettings.Notifications
could use the official API as well.
I got build errors with this plugin on android. I'am using capacitor 4.
Execution failed for task ':capacitor-native-settings:compileDebugJavaWithJavac'.
> error: invalid source release: 17
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':capacitor-native-settings:compileDebugJavaWithJavac'.
Used versions:
ext {
minSdkVersion = 22
compileSdkVersion = 32
targetSdkVersion = 32
buildToolsVersion = '30.0.3'
androidxActivityVersion = '1.4.0'
androidxCoordinatorLayoutVersion = '1.2.0'
androidxAppCompatVersion = '1.4.2'
androidxCoreVersion = '1.8.0'
androidxFragmentVersion = '1.4.1'
coreSplashScreenVersion = '1.0.0-rc01'
androidxWebkitVersion = '1.4.0'
androidxMaterialVersion = '1.6.1'
androidxBrowserVersion = '1.4.0'
androidxExifInterfaceVersion = '1.3.3'
firebaseMessagingVersion = '23.0.5'
playServicesLocationVersion = '21.0.1'
junitVersion = '4.13.2'
androidxJunitVersion = '1.1.3'
androidxEspressoCoreVersion = '3.4.0'
cordovaAndroidVersion = '10.1.1'
}
I'd like to open the passcode setting to let the user activate a local device authentication, as sensitive data is not secured properly without that. It would be nice to lead the user directly to that setting.
Would it be also possible, to just open the main page of the settings?
Capacitor v4 has just been released, and I'm testing out compatibility with my app.
When running npm install with the v4.0.1 plugins present, this plugin throws a peer dependency error. However everything appears to work fine in app.
Can we get an update to avoid needing to run npm install with the --force tag? Much appreciated.
Is there a reason you seperate the Methode in a openIos and openAndroid? I don't like that as i always have to add a platform detection before Plugin Call.
Why did you decide to do it like this and not like jn the Cordova one?
Hi,
I have done all the instructions to install de plugin.
This is the updated usage:
NativeSettings.openAndroid({
option: AndroidSettings.ApplicationDetails,
});
vendor.js:46093 ERROR Error: Uncaught (in promise): Error: "NativeSettings" plugin is not implemented on android
Error: "NativeSettings" plugin is not implemented on android
at createPluginMethod (vendor.js:89422)
at vendor.js:89429
at ZoneDelegate.invoke (polyfills.js:436)
at Object.onInvoke (vendor.js:68311)
at ZoneDelegate.invoke (polyfills.js:435)
at Zone.run (polyfills.js:196)
at polyfills.js:1354
at ZoneDelegate.invokeTask (polyfills.js:470)
at Object.onInvokeTask (vendor.js:68298)
at ZoneDelegate.invokeTask (polyfills.js:469)
at resolvePromise (polyfills.js:1291)
at polyfills.js:1361
at ZoneDelegate.invokeTask (polyfills.js:470)
at Object.onInvokeTask (vendor.js:68298)
at ZoneDelegate.invokeTask (polyfills.js:469)
at Zone.runTask (polyfills.js:241)
at drainMicroTaskQueue (polyfills.js:656)
Since iOS 10 the private API was deprecated to open screens, but since ios 13.1 you are able to use App-Prefs again. We have tested this on iOS and seems to be working fine with root:general. A upload to apple shows that you are allowed to use it and your app will not be rejected.
Implement all setting screens for iOS with App-Prefs.
https://github.com/RaphaelWoude/capacitor-native-settings/blob/main/ios/Plugin/NativeSettingsPlugin.swift
https://www.macstories.net/ios/a-comprehensive-guide-to-all-120-settings-urls-supported-by-ios-and-ipados-13-1/
Hi!
Thanks for this plugin!
I have an issue.
When I open the app settings (IOS) I'm not able to return into the app (clicking the app name in the top left corner of the screen.)
I missed something?
This is my simple code triggered on click:
try {
await NativeSettings.open({
optionAndroid: AndroidSettings.ApplicationDetails,
optionIOS: IOSSettings.App,
});
} catch (e) {
console.error(e);
}
Thanks and kind regards,
Davide
If you use ACTION_APPLICATION_DETAIL_SETTINGS
it will crash when opening it. This is probably because the package URI is not provided with the action.
Hi guys,
App store rejecting my apk because of security reasons to given access in my app.
My code:
NativeSettings.open({
optionAndroid: AndroidSettings.ApplicationDetails,
optionIOS: IOSSettings.App
}).then((res: any) => {
// Code
}).catch((err: any) => {
// Code
})
But in this module i don't find any specific way to open device setting directly to location access permission.
Can anyone suggest me how i can give specific location access permission in IOS?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.