ionic: add own cordova plugin - cordova-plugins

I modified an existing cordova plugin and want to integrate it now into my application.
I already created a link to my source directory
cordova plugin add --link ~/path/to/plugin
but now I can not find my plugin in my project. I suggest, that the plugin needs to be build?
Is it needed to modify my package.json?

Add the plugin to project:
ionic cordova plugin add [plugin]
Documentation
Install and save the plugin:
npm install --save [plugin]
Example

This is related to stackoverflow/questions/30345035
Since you modify existing plugin there is possibility that you didn't modify it right. Also there is possibility that plugin is not working for specific platform version.

If you are looking to add your own cordova plugin in Ionic v2 here can be your solution.
If you have exported your module / plugin like
module.exports = new YourPluginJavaClass();
then you will be able to use it in your Ionic application as
(window as any).YourPluginJavaClass.yourFunction();
Please see this link as well
Hope this helps.

Related

How to add plugins for ios in phonegap?

I am new to phonegap.
Using phonegap app I have created new project.
Now I like to use this project in xcode (7.2.1) is it possible?
What is the best way to develop app in phonegap for various plugin ,I was googled and heard about coredova but can't understand exact needed .
For IOS Try this to add any new Plugin.
Go to your Created Project Directory in Mac CLI.
Then do this.
If you haven't added IOS Platform then run below command.
cordova platform add ios
Then build your whole project with below command.
cordova prepare ios
Then to add plugin run below command.
cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git
Here take whatever plugin you want to install.
Make sure you connected with internet while installing plugin.
Now I like to use this project in xCode (7.2.1) is it possible?*
Yes it is possible, Read this article
What is the best way to develop app in phonegap for various plugin
I am assuming you are asking how to add different plugins?
Create your APP with the PhoneGap Interface (You already did)
Go to the www folder where you stored the PG build files and look for your config.xml, then you will see a section where a few plugins already exists. You can add additional ones by just simply copying and pasting the below XML syntax (Battery Status Plugin), example:
<plugin name="cordova-plugin-battery-status" spec="1.1.0" source="pgb" />
Reference this article for a comprehensive list of PhoneGap's plugins:
https://build.phonegap.com/plugins
Alternatively, you can add them through the Command Line interface (See the first answer to your question)

How to configure Cordova CLI to use custom project template repo for given platform?

Cordova CLI is simple:
cordova platform add ios
Plus you can append #<VERSION_TAG> and so use a different version. But my goal is to have something like this:
cordova platform add ios#https://github.com/<MY_FORK>/cordova-ios.git#<MY_VERSION_TAG/BRANCH>
So platform add command will use my fork instead of https://github.com/apache/cordova-ios.git. Cordova CLI doesn't seem to allow this type of weird statement, but is there (where?) a way to customise it somehow to use a different repo URL for the Cordova platform?
Ok, I got it,
I found it while traversing Cordova-CLI files and then Cordova-Lib. Here's the answer:
cordova platform add git-url#custom-branch
And here is the source: https://github.com/apache/cordova-lib/blob/master/cordova-lib/src/cordova/platform.js

Add plugins using cli in cordova 2.5.0

I have tried my best to add a plugins using Command line interface in cordova 2.5.0 but failed to find any solution can u please help me to add plugins
I don't believe you can use the command line to manage cordova 2.5 projects. The node base CLI didn't get added to the project until cordova 2.9.0.
You need to manually add plugins as outlined here: https://cordova.apache.org/docs/en/2.5.0/guide_plugin-development_index.md.html#Plugin%20Development%20Guide

Cannot add Plugins to my iOS Cordova Application

I have a cordova 3.3.0 application that I created using ./create etc etc now Whe i try to add the device plugin either phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git
or
cordova plugin add org.apache.cordova.console org.apache.cordova.device all give me errors, the device plugin is essential to my application. Anyway to add that plugin without using the CLI tools? just git cloning? or a quick fix? I have killed a lot of time on this.
I think you should follow thier new way to add plugins like Device:
phonegap local plugin add org.apache.cordova.device

cordova console log can not be installed

I am trying to install the cordova console.log plugin.
when i am trying to install it using the command line using:
cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-console.git
I am running it from the path of the root application path
the structure of the folder is:
projName
|-- --project
|-- projName
|-- cordova
|-- CordovaLib
|-- projName.xcodeproj
|-- plugin
And the error i receive in the command line is
[Error: Current working directory is not a Cordova-based project.]
i should mention that i build the cordova project manually using imports of the frameworks because in the xcode new project window there was not Cordova/Phonegap new project option.
I am using xCode 5.0.1 and cordova 3.1.0
The error you get is self-explanatory, it is because you have not created a cordova project as it must be created. Keep reading to solve the problem.
Cordova basic project preparation steps
Based on my comment and your answer, you should follow the cordova workflow for creating projects using the CLI (command line interface), it is strongly recommended to avoid unnecessary problems, and the steps are not hard to follow.
Please follow the steps described here (official doc), read it fully, it will save you more time later if you read it:
http://cordova.apache.org/docs/en/3.2.0/guide_cli_index.md.html#The%20Command-Line%20Interface
In brief the steps are:
Install node.js
Install cordova using npm
Create a cordova project / app using the CLI
Add the desired platform to the project (android, ios, etc, as needed)
Work on your project
Add cordova plugins as necessary (for example if you need notifications add the notificacion plugin)
Build the project
Test of device or emulator (in your case iPhone, iPad simulator)
iOS Platform Guide
Also check the iOS Platform Guide completely, it is very helpful, explain additional instructions to prepare and work with XCode.
http://cordova.apache.org/docs/en/3.2.0/guide_platforms_ios_index.md.html#iOS%20Platform%20Guide
Plugins
For each plugin in the API reference you will find instructions to install them using the CLI, as well as to "uninstall" them.
Only install the plugins you will need
Just for reference, the code to install notifications-dialogs plugin using the terminal (run the command inside your project folder):
$ cordova plugin rm org.apache.cordova.dialogs
On the other hand, the easier way to solve the problem is create the new project following the noted steps and later just add your existing code or files to the proper folders, as well as add the required plugins, not that difficult.

Resources