Description
A Cordova plugin for the Google Nearby Connections API.
Supported Platforms
Android (4.1+)
Limitations
- Currently only supports sending/receiving string payloads (no file or stream support)
Plugin Installation
Cordova:
cordova plugin add cordova-plugin-google-nearby-connections
Ionic (2+):
ionic cordova plugin add cordova-plugin-google-nearby-connections
Install from GitHub:
cordova plugin add https://github.com/kspierson/cordova-plugin-google-nearby-connections
Plugin Usage
Initialize
var GoogleNearbyConnections = cordova.plugins.GoogleNearbyConnections;
Methods
Start Advertising
GoogleNearbyConnections.startAdvertising(deviceName, strategyType, serviceId, successCallback, errorCallback);
Start Discovery
GoogleNearbyConnections.startDiscovery(strategyType, serviceId, successCallback, errorCallback);
Stop Advertising
GoogleNearbyConnections.stopAdvertising(callback);
Stop Discovery
GoogleNearbyConnections.stopDiscovery(callback);
Stop All Endpoints
GoogleNearbyConnections.stopAllEndpoints(callback);
On Endpoint Found
GoogleNearbyConnections.onEndpointFound(successCallback, errorCallback);
On Endpoint Lost
GoogleNearbyConnections.onEndpointLost(callback);
On Connection Found
GoogleNearbyConnections.onConnectionFound(successCallback, errorCallback);
On Connection
GoogleNearbyConnections.onConnection(successCallback, errorCallback);
On Connection Lost
GoogleNearbyConnections.onConnectionLost(callback);
Accept Connection
GoogleNearbyConnections.acceptConnection(endpointId, successCallback, errorCallback);
Deny Connection
GoogleNearbyConnections.denyConnection(endpointId, successCallback, errorCallback);
Send Payload
GoogleNearbyConnections.sendPayload(endpointId, payload, successCallback, errorCallback);
On Payload Received
GoogleNearbyConnections.onPayloadReceived(successCallback, errorCallback);
Disconnect From Endpoint
GoogleNearbyConnections.disconnectFromEndpoint(endpointId, callback);
Remove Plugin
Cordova
cordova plugin rm cordova-plugin-google-nearby-connections
Ionic
ionic cordova plugin rm cordova-plugin-google-nearby-connections