After updating to iOS 13, I've begun receiving a prompt to allow my application to use Bluetooth. In reality, a lot of apps started asking for Bluetooth permission. This caught me by surprise because I did not know my app used Bluetooth and because I did not want it to use Bluetooth.
I found an issue on GitHub from September 19, 2019, which explains why I was having this issue. The app uses the Cordova plugin referenced in the issue: cordova.plugins.diagnostic. This plugin is used to "manage device settings such as Location, Bluetooth and WiFi", and I was specifically using it to request the Location permission and check if the Wi-Fi is on.
It was my first time submitting to App Store so, naïve as I was, I tried to send the app for review without removing the Bluetooth alert, just changing the purpose string. For it, I added the following lines to config.xml.
<config-file parent="NSBluetoothAlwaysUsageDescription" platform="ios" target="*-Info.plist"> <string>Bluetooth permission is required because of X, Y and Z</string> </config-file>
Of course, I received an email from Apple:
During review, we were prompted to provide consent to access the Bluetooth. However, we were not able to locate any features in your app that use the Bluetooth.
If your app does not include any features that use the Bluetooth, please remove access to the Bluetooth from your app.
The easy way didn't work out, so I guess I had to make sure my app doesn't request this feature. After a quick check on the documentation, I found out that modules can be specified. By default, all modules are added to the project. I followed their suggestion to add a preference to config.xml stating which modules I wanted to include.
I had to uninstall the plugin and reinstall it after adding this preference. Basically, during the plugin installation, parts of plugin.xml get commented so the files for the modules left out of the preference are excluded. After that, I removed the iOS platform, added it again and built the app.
I would rather have the plugin add nothing by default, making the developer choose the plugins it needs instead of importing a lot of unnecessary code.
I have a love-hate relationship with Ionic. While I like that this framework allows me to use Angular to develop mobile applications (an environment I'm personally fond of), I encounter problems with its plugins more often than not.
I've experienced countless issues with the native plugins, often because of incompatibilities with each other or with updated versions of the Cordova platforms. Through a series of posts, I will try to summarize some of those problems I encountered, the investigations I did, and how I solved them through the means at my disposal.