Cordova - remove unnecessary permissions
How to remove unnecessary cordova permissions?
Remove not needed permissions from cordova config
When building a project, some of the dependencies plugins add unnecessary permissions.
We throw the file remove_permissions.js in the folder with the plugins
Example:
<ROOT_PROJECT_PATH>\plugins\cordova-plugin-whitelist\remove_permissions.js
Editing the plugin configuration (plugin.xml)
<platform name="android">
....
<hook type="after_prepare" src="remove_permissions.js"/>
</platform>
Also we do with the configuration in the project root
###### remove_permissions.js ##########
var permissionsToRemove = [ "RECORD_AUDIO", "RECORD_VIDEO", "RECORD_VIDEO", "INTERNET" ];
var fs = require('fs');
var path = require('path');
var rootdir = "";
var manifestFile = path.join(rootdir, "platforms/android/app/src/main/AndroidManifest.xml");
fs.readFile( manifestFile, "utf8", function( err, data )
{
if (err)
return console.log( err );
var result = data;
for (var i=0; i<permissionsToRemove.length; i++)
result = result.replace( "<uses-permission android:name=\"android.permission." + permissionsToRemove[i] + "\" />", "" );
fs.writeFile( manifestFile, result, "utf8", function( err )
{
if (err)
return console.log( err );
} );
} );
Buil Project
cordova build --release android -- --versionCode=1
Check tool
https://vaibhavpandey.com/apkstudio/
Комментариев нет:
Отправить комментарий