Create custom cordova plugin for ionic



Install plugman for create a custom plugin

https://www.npmjs.com/package/plugman

CLI command:
npm install -g plugman
npm install -g cordova
npm install -g @ionic/cli@latest

Create a plugin using plugman:

plugman create --name AppName --plugin_id cordova-plugin-myapp --plugin_version 0.0.1


cd AppName

Create a package json for the plugin:

plugman createpackagejson AppName

Add a platform for android and ios:

plugman platform add --platform_name android
plugman platform add --platform_name ios

Upload the plugin in github repositary

Eg: https://github.com/AndroidManikandan5689/Custom-cordova-plugin-example

Publish the plugin in NPM repository
npm publish --access=public

Login npm for publish the plugin
npm login

Check the existing user through command line
npm whoami

Install the plugin in Ionic/Cordova project from the npm repository

npm install <plugin_name>
ionic cordova plugin add <plugin_name>

(or)

Install the plugin from local director to node modules folder

npm install <local_directory/plugin folder>

Eg: npm install pluginsrc/MicrChequeReader










Install the plugin from local director to ionic plugins folder

ionic cordova plugin add <plugin_id>


Error:

Error:

Getting this error when run ionic using ionic serve command 

" - Generating browser application bundles (phase: setup)... [ng] Compiling @angular/core : es2015 as esm2015 [ng] Compiling @angular/common : es2015 as esm2015 [ng] Compiling @angular/platform-browser : es2015 as esm2015 [ng] Compiling @angular/forms : es2015 as esm2015 [ng] Compiling @angular/platform-browser-dynamic : es2015 as esm2015 [ng] Compiling @angular/router : es2015 as esm2015 [ng] Compiling @ionic/angular : es2015 as esm2015 [ng] node:internal/crypto/hash:79 [ng] this[kHandle] = new _Hash(algorithm, xofLen, algorithmId, getHashCache()); [ng] ^ [ng] Error: error:0308010C:digital envelope routines::unsupported [ng] at new Hash (node:internal/crypto/hash:79:19) [ng] at Object.createHash (node:crypto:139:10) [ng] at BulkUpdateDecorator.hashFactory (/Users/fssdeveloper/Desktop/Manikandan/FSS-SDK/FssMerchantIonicApp/node_modules/webpack/lib/util/createHash.js:145:18) [ng] at BulkUpdateDecorator.update (/Users/fssdeveloper/Desktop/Manikandan/FSS-SDK/FssMerchantIonicApp/node_modules/webpack/lib/util/createHash.js:46:50) [ng] at RawSource.updateHash (/Users/fssdeveloper/Desktop/Manikandan/FSS-SDK/FssMerchantIonicApp/node_modules/webpack/node_modules/webpack-sources/lib/RawSource.js:77:8) [ng] at NormalModule._initBuildHash (/Users/fssdeveloper/Desktop/Manikandan/FSS-SDK/FssMerchantIonicApp/node_modules/webpack/lib/NormalModule.js:880:17) [ng] at handleParseResult (/Users/fssdeveloper/Desktop/Manikandan/FSS-SDK/FssMerchantIonicApp/node_modules/webpack/lib/NormalModule.js:946:10) [ng] at /Users/fssdeveloper/Desktop/Manikandan/FSS-SDK/FssMerchantIonicApp/node_modules/webpack/lib/NormalModule.js:1040:4 [ng] at processResult (/Users/fssdeveloper/Desktop/Manikandan/FSS-SDK/FssMerchantIonicApp/node_modules/webpack/lib/NormalModule.js:755:11) [ng] at /Users/fssdeveloper/Desktop/Manikandan/FSS-SDK/FssMerchantIonicApp/node_modules/webpack/lib/NormalModule.js:819:5 { [ng] opensslErrorStack: [ [ng] 'error:03000086:digital envelope routines::initialization error', [ng] 'error:0308010C:digital envelope routines::unsupported' [ng] ], [ng] library: 'digital envelope routines', [ng] reason: 'unsupported', [ng] code: 'ERR_OSSL_EVP_UNSUPPORTED' [ng] } [ng] Node.js v22.11.0"


Linux/macOS:

bash
export NODE_OPTIONS=--openssl-legacy-provider ionic serve

Windows (Command Prompt):

cmd
set NODE_OPTIONS=--openssl-legacy-provider ionic serve

Windows (PowerShell):

powershell
$env:NODE_OPTIONS = "--openssl-legacy-provider" ionic serve



Comments

Popular posts from this blog

Google Assistant Implementation in Android application with app actions