Giter Site home page Giter Site logo

raphaelwoude / capacitor-native-settings Goto Github PK

View Code? Open in Web Editor NEW
80.0 80.0 27.0 287 KB

Capacitor plugin to open native settings screens for android and iOS

License: MIT License

Ruby 3.72% Java 39.23% Swift 14.37% Objective-C 2.85% JavaScript 1.84% TypeScript 37.98%

capacitor-native-settings's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

capacitor-native-settings's Issues

add activityResult to improve promise usability on Android

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

tts settings added

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,
});

Failed to parse source map from './' Error: ENOENT: no such file or directory

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

Android: Missing redirection to 'App Permissions' page

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.

Android/iOS Settings are not imported

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.
image

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,
      })
      ...

Add example to README

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' })

How should the return value be interpreted?

The open() function returns a Promise, which includes a boolean status. Could you elaborate on the scenarios, where the promise is

  1. resolved with a status true,
  2. resolved with status false,
  3. rejected

Thank you in advance!

Capacitor 6 support

Android SDK 34+ will be mandatory after August 2024. Do you have plans to upgrade this plugin?

Edit: Duplicated issue.

Problem when trying to run.

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?

UIApplication.shared.canOpenURL should be used from main thread

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
        ])
    });
}

image

Thanks

Invalid source release: 17

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'
}

IOS Setting for `TOUCHID_PASSCODE`

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?

Compatability with Capacitor v4?

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.

Only one Open Method

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?

Error: Uncaught (in promise): Error: "NativeSettings" plugin is not implemented on android

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)

Add more App-Prefs to iOS

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/

Not able to return into the app

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

ApplicationDetailSettings crashes

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.

Location permission setting direct open in IOS device setting

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.