import org.apache.cordova.CordovaPlugin;
public class CustomAlertPlugin extends CordovaPlugin {
private static final String TAG = "CustomAlertPlugin";
public void initialize(CordovaInterface cordova,
CordovaWebView webView) {
super.initialize(cordova, webView);
Log.d(TAG, "Initializing MyCordovaPlugin");
}
...
}
@objc(ModusEchoSwift) class CustomAlertPlugin : CDVPlugin {
func superFunction(command: CDVInvokedUrlCommand) {
let superArg = command.arguments[0] as? String ?? ""
if msg.characters.count > 0 {
let alertController: UIAlertController =
UIAlertController(
title: "",
message: msg,
preferredStyle: .Alert
)
.
├── package.json
├── plugin.xml
├── src
│ └── android
│ └── com
│ └── example
│ └── CustomAlertPlugin.java
└── www
└── plugin.js
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" id="my-cordova-plugin" version="1.0.0">
<name>Cordova Plugin Template</name>
<description></description>
<repo>https://github.com/driftyco/cordova-plugin-template.git</repo>
<!-- android -->
<platform name="android">
<js-module src="www/plugin.js" name="plugin">
<runs/>
<!-- This is the window variable name you want, like window.MyCordovaPlugin -->
<clobbers target="CustomAlertPlugin"/>
</js-module>
<config-file target="res/xml/config.xml" parent="/*">
<feature name="CustomAlertPlugin">
<param name="android-package" value="com.example.CustomAlertPlugin"/>
<param name="onload" value="true"/>
</feature>
</config-file>
<source-file src="src/android/com/example/CustomAlertPlugin.java" target-dir="src/com/example/"/>
</platform>
</plugin>
var exec = require('cordova/exec');
// Plugin name defined in `plugin.xml`
const PLUGIN_NAME = 'DatePlugin'
// Export a public function.
exports.getDate = function(success, error) {
exec(success, error, PLUGIN_NAME, 'getDate', []);
};
public class CustomAlertPlugin extends CordovaPlugin {
private static final String TAG = "CustomAlertPlugin";
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
super.initialize(cordova, webView);
Log.d(TAG, "Initializing MyCordovaPlugin");
}
@Override
public boolean execute(String action, JSONArray args, final CallbackContext callbackContext)
throws JSONException {
if(action.equals("getDate")) {
final PluginResult result = new PluginResult(PluginResult.Status.OK, (new Date().toString());
callbackContext.sendPluginResult(result)
return true;
} else {
callbackContext.error(action + " not found !");
return false;
}
}
}
cordova plugin add cordova-plugin-googlemaps \
--variable API_KEY_FOR_ANDROID="API_KEY_VALUE" \
--variable API_KEY_FOR_IOS="API_KEY_VALUE"
var options = {
camera: {
target: {lat: ..., lng: ...},
zoom: 19
}
};
var map = plugin.google.maps
.Map.getMap(mapDiv, options)
map.addMarker({
position: {lat: ..., lng: ...},
title: "Hello Cordova Google Maps for iOS and Android",
snippet: "This plugin is awesome!"
}, function(marker) { ... })
var options = {
camera: {
target: {lat: ..., lng: ...},
zoom: 19
}
};
var map = plugin.google.maps
.Map.getMap(mapDiv, options)
map.addCircle({
'center': {lat: ..., lng: ...},
'radius': 300,
'strokeColor' : '#AA00FF',
'strokeWidth': 5,
'fillColor' : '#880000'
}, function(circle) { ... });
map.addPolyline({
points: AIR_PORTS,
'color' : '#AA00FF',
'width': 10,
'geodesic': true
}, function(polyline) { ... });
map.addPolygon({
'points': GORYOKAKU_POINTS,
'strokeColor' : '#AA00FF',
'strokeWidth': 5,
'fillColor' : '#880000'
}, function(polygon) { ... });