dpa99c / cordova-diagnostic-plugin

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

[iOs] NSBluetoothAlwaysUsageDescription warning after specifying optional modules #375

Closed rodrigojrmartinez closed 5 years ago

rodrigojrmartinez commented 5 years ago

Hi, I'm building an Ionic 4 app meant for both Android and iOs and recently I've been starting to receive a warning from Apple App Store Connect regarding a missing purpose on why I'm using bluetooth information on my App. For my case I'm not using it at all and I've read the 'Specifying modules' section of the readme, so I know this comes by default when installing the plugin. I've tried to do what it's suggested in this section so as to avoid having this warning

By default, all the modules will be added to your project when you install the plugin. You can specify which modules are installed by adding a to your config.xml which specifies the modules you wish to add as a space-separated list. Module names should be capitalised. ... If you change the modules specified in the preference, you'll need to uninstall then re-install the plugin to your project to apply the changes.

So what I've done now is to add this line over my config.xml

<preference name="cordova.plugins.diagnostic.modules" value="LOCATION WIFI" />
....
<plugin name="cordova.plugins.diagnostic" spec="^5.0.1">
  <variable name="ANDROID_SUPPORT_VERSION" value="28.+" />
</plugin>

Since this is the only information I've been retrieving for the app. Also I have a merge for Info.plist to specify why I need the location as follows:

<platform name="ios">
   ...
  <edit-config file="*-Info.plist" mode="merge" target="NSLocationWhenInUseUsageDescription">
     <string>Need access to detect user's position so as to have location of registrations made</string>
  </edit-config>
</platform>

I have removed the plugin and uninstall the ionic dependency as well and then reinstall it with the following commands

ionic cordova plugin remove cordova.plugins.diagnostic
npm uninstall @ionic-native/diagnostic
ionic cordova plugin add cordova.plugins.diagnostic
npm install @ionic-native/diagnostic

Which updated my package.json with the latest versions, Then I've build the app for ios just fine, then I check for the ios.json generated file and I can't find the 'NSBluetoothAlwaysUsageDescription' description on the "*-Info.plist" information (though I can see that there are other values such as NSCamaraUsageDescription, NSMicrophoneUsageDescription, etc. which I'm also not using). Then there's an entry for config.xml parents where I can indeed see

...
{
"xml": "<feature name=\"Diagnostic_Bluetooth\"><param name=\"ios-package\" value=\"Diagnostic_Bluetooth\" /><param name=\"onload\" value=\"true\" /></feature>",
"count": 1
}
...

At the end when submitting the app to the App Store for testing purposes I still receive the usual warning:

ITMS-90683: Missing Purpose String in Info.plist - Your app's code references one or more APIs that access sensitive user data. The app's Info.plist file should contain a NSBluetoothAlwaysUsageDescription key with a user-facing purpose string explaining clearly and completely why your app needs the data. Starting Spring 2019, all apps submitted to the App Store that access user data are required to include a purpose string. If you're using external libraries or SDKs, they may reference APIs that require a purpose string. While your app might not use these APIs, a purpose string is still required. You can contact the developer of the library or SDK and request they release a version of their code that doesn't contain the APIs. Learn more (https://developer.apple.com/documentation/uikit/core_app/protecting_the_user_s_privacy).

Am I doing something wrong? I wouldn't want to add a description of the use of data I'm not taking into account for my app since it would be a lie and I run the risk for my app to be rejected when publishing it for real. Some advice for avoiding this?

Thanks a lot!

attebury commented 5 years ago

Are you using Phone Gap to build your apps? If so, Phone Gap essentially ignores the preference and downloads the entire plugin. I had to build the iOS version in Xcode. Others have used a forked version of the plugin. (I'd add a link but I can't find it at the moment.)

rodrigojrmartinez commented 5 years ago

I'm using ionic actually and cordova beneath it, with the following command

ionic cordova build ios

mathewkuttymathew commented 5 years ago

I am having the same issue, any solution?

alexisAvenel commented 5 years ago

Same error for me. Using ionic 4 / XCode 11.1 / iPhone iOS 13.1 this error appear when upgrading iOS version of iPhone into 13.+

attebury commented 5 years ago

If you aren't using PhoneGap it may be that the bluetooth plugin is still present. I had to remove the plugin, remove the platform, make sure the preference is set in config.xml, then add the plugin, then add the platform.

alexisAvenel commented 5 years ago

Thank you @attebury it's good for me !

rodrigojrmartinez commented 5 years ago

Okey, I finally got it. It wasn't enough to just uninstall and re-install the plugins & module but also the platform as well, so for anyone having this issue and to make it as clear as possible, you should

  1. remove ios platform ionic cordova platform remove ios
  2. uninstall ionic diagnostic node module (if using ionic) npm uninstall @ionic-native/diagnostic
  3. uninstall cordova diagnostic plugin ionic cordova plugin remove cordova.plugins.diagnostic
  4. ensure you have the desired configuration on config.xml (under general section, not platform specific) <preference name="cordova.plugins.diagnostic.modules" value="LOCATION" />
  5. re-install cordova diagnostic plugin ionic cordova plugin add cordova.plugins.diagnostic
  6. re-install ionic diagnostic node module npm install @ionic-native/diagnostic
  7. If you inspect the node_modules folder cordova.plugins.diagnostic/src/ios/ you will see that Diagnostic_Bluetooth is still present, this got me confused but is not a problem
  8. re-add the ios platform ionic cordova platform add ios
  9. If you go to platforms/ios/YOUR_APP/Plugins/cordova.plugins.diagnostic you should see there's no BlueTooth file present Which means the configuration got applied
  10. build your project and then open XCode to build native ios app and submit to distribution as usual ionic cordova build ios
cassini-usman commented 5 years ago

@rodrigojrmartinez Thanks. It worked!

2diegoduque commented 5 years ago

@rodrigojrmartinez Thanks. It worked!

molinet88 commented 4 years ago

The preference cordova.plugins.diagnostic.modules is not working with ionic@2 & cordova@6. I followed @rodrigojrmartinez steps but all modules are present in platforms/ios/YOUR_APP/Plugins/cordova.plugins.diagnostic folder. The plugin version i'm using is 4.0.8 due to cordova@6.5.0 compatibility. @dpa99c Any clues on this? Thanks!

dpa99c commented 4 years ago

@molinet88 I suggest updating to latest cordova (CLI) and cordova-android (platform) versions then you can update to the latest version of this plugin.

molinet88 commented 4 years ago

@dpa99c Yes, but I wanted to skip this solution because it's too aggressive to all project dependencies. Just to clarify, since plugin version 4 the modules preference should work, isn't it?

dpa99c commented 4 years ago

In theory it should work but I can't support such old versions of the plugin so if you're having issues, you'll need to resolve them yourself.

molinet88 commented 4 years ago

Sure, it's a mess to use old versions... I finally solved it updating cordova CLIto latest version (9.0.0) and using plugin version 4.0.8 (due to cordova-android@6.1.2 compatibility). That way the modules preference is working fine! Thank you :)