This project is a sample plugin for the Kiwi mobile app.
These Kiwi mobile plugins are NativeScript plugins. This means that they must follow the NativeScript plugin requirements.
Use the kiwiirc-mobile-plugin-sample as a starting point.
-
Download the repo as a .zip file;
-
Change the name of the package in
src/package.json
(e.g.my-kiwi-plugin
); -
Install the plugin As you can see in the docs, you can install plugins from:
-
Npm registry. See more about publishing to npm here.
-
A local path:
ns plugin install /path/to/plugin/src
. Notice that you must point to thesrc/
directory containing thepackage.json
. -
A local
.tar.gz
of the directory containing thepackage.json
:ns plugin install /path/to/plugin.tar.gz
; -
A remote
.tar.gz
of the directory containing thepackage.json
:ns plugin install https://example.com/plugin.tar.gz
.
require()
the plugin in the App Project's `app/plugins.js``:// require npm plugins: require('my-kiwi-plugin');
Inside the main .js
file (src/index.js
), you must register a plugin using the
kiwi.plugin()
call, such as:
kiwi.plugin('plugin_name', function(kiwi, log) {
// Plugin code here
});
Your plugin function will be called once mobile app has been loaded and ready to start. You can listen for events and use any of the below API in your plugin.
As a very simple example, this plugin will listen for any new networks being created and set the default server address to irc.freenode.net
:
kiwi.plugin('my_plugin', function(kiwi) {
kiwi.on('network.new', function(event) {
event.network.connection.server = 'irc.freenode.net';
event.network.connection.port = 6667;
});
});
The command ns plugin install
installs the plugin under node_modules
, which could make
the development very hard. The best way to develop Kiwi mobile plugins is to install them
from a local directory and use yarn link
to link the directory under node_modules
to your
source code.
cd /path/to/kiwiirc-mobile/mobile
tns plugin install /path/to/my-plugin/src
cd /path/to/my-plugin/src
yarn link
cd /path/to/kiwiirc-mobile/mobile
yarn link my-plugin
This way, you can keep developing the plugin in its place
(/path/to/my-plugin/src
) and each time you change the code, webpack will
re-pack it and the app will reload.
The plugin API is described here