dpa99c / cordova-diagnostic-plugin

Cordova/Phonegap plugin to manage device settings
540 stars 361 forks source link

How to specify modules with Capacitor? #379

Closed zaarheed closed 5 years ago

zaarheed commented 5 years ago

I am trying to use this plugin with an Ionic 4 + Capacitor project.

When installing the plugin with the command npm install cordova.plugins.diagnostic --save I get the error:

cordova.plugins.diagnostic: Diagnostic plugin - ERROR: ENOENT: no such file or directory, open '/Users/zahid/Downloads/halaljoints-app2/config.xml'

In addition, adding the following to capacitor.config.json file:

{
    "appId": "<APP ID>",
    "appName": "<APP NAME>",
    ...
    "cordova": {
        "preferences": {
            "cordova.plugins.diagnostic.modules": "LOCATION"
        }
    }
}

Still results in the following being added to my iOS config.xml (which appears to be all modules included):

...

<feature name="Diagnostic">
    <param name="ios-package" value="Diagnostic"/>
    <param name="onload" value="true"/>
</feature>

<feature name="Diagnostic_Location">
    <param name="ios-package" value="Diagnostic_Location"/>
    <param name="onload" value="true"/>
</feature>

<feature name="Diagnostic_Bluetooth">
    <param name="ios-package" value="Diagnostic_Bluetooth"/>
    <param name="onload" value="true"/>
</feature>

...

<feature name="Diagnostic_Notifications">
    <param name="ios-package" value="Diagnostic_Notifications"/>
    <param name="onload" value="true"/>
</feature>

<preference name="cordova.plugins.diagnostic.modules" value="LOCATION" />

Any direction on how to specify modules when using Capacitor (and update the docs accordingly)?

dpa99c commented 5 years ago

You may be able to make the plugin work with Capacitor by adding a "fake" config.xml in the root of your project (where the plugin is looking for it) and add the preference to that. No idea if that will work though.

The plugin is designed to work with Cordova. There are currently no plans to explicitly add support for Capacitor hence closing this.

ondrejstolar commented 3 years ago

Just tested it and it works.. just drop config.xml in to your project root folder. see attached :) like below >> `<?xml version='1.0' encoding='utf-8'?>

`