From eb1bcdd078f3300eb167e7a3c0413857766b0dfa Mon Sep 17 00:00:00 2001 From: Hannes Date: Sat, 7 Apr 2018 14:47:33 +0200 Subject: [PATCH 1/2] feat(plugin): Add google nearby plugin --- .../plugins/google-nearby/index.ts | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 src/@ionic-native/plugins/google-nearby/index.ts diff --git a/src/@ionic-native/plugins/google-nearby/index.ts b/src/@ionic-native/plugins/google-nearby/index.ts new file mode 100644 index 000000000..3e3fb6a34 --- /dev/null +++ b/src/@ionic-native/plugins/google-nearby/index.ts @@ -0,0 +1,69 @@ +import { Injectable } from '@angular/core'; +import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core'; +import { Observable } from 'rxjs/Observable'; + +/** + * @name google-nearby + * @description + * This plugin adds support for the Google Nearby Messages API. + * + * @usage + * ```typescript + * import { GoogleNearby } from '@ionic-native/google-nearby'; + * + * + * constructor(private googleNearby: GoogleNearby) { } + * + * this.googleNearby.publish('Hello') + * .then((res: any) => console.log(res)) + * .catch((error: any) => console.error(error)); + * + * this.googleNearby.subscribe() + * .then((res: any) => console.log(res)) + * .catch((error: any) => console.error(error)); + * ``` + */ +@Plugin({ + pluginName: 'GoogleNearby', + plugin: 'cordova-plugin-google-nearby', + pluginRef: 'window.nearby', + repo: 'https://github.com/hahahannes/googlenearby-cordova-plugin', + install: 'ionic cordova plugin add cordova-plugin-google-nearby --variable API_KEY="123456789"', + installVariables: ['API_KEY'], + platforms: ['Android'] +}) +@Injectable() +export class GoogleNearby extends IonicNativePlugin { + + /** + * Publish a message + * @param message {string} Message to publish + * @return {Promise} Returns a promise that resolves when the message got published + */ + @Cordova() + publish(message: string): Promise { + return; + } + +/** + * Subscribe to recieve messages + * @return {Observable} Returns an observable that emits recieved messages + */ + @Cordova({ + observable: true, + clearFunction: 'unsubscribe' + }) + subscribe(): Observable { + return; + } + +/** + * Unsubscribe from Messages + * @return {Promise} Returns a promise that resolves when you unsubscribed + */ + @Cordova() + unsubscribe(): Promise { + return; + } + +} From 8f1854c180d21bb47716d37a6f0abe66f19b5fb3 Mon Sep 17 00:00:00 2001 From: Hannes Date: Sun, 8 Apr 2018 22:21:18 +0200 Subject: [PATCH 2/2] refactor(GoogleNearby): add requested changes --- src/@ionic-native/plugins/google-nearby/index.ts | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/@ionic-native/plugins/google-nearby/index.ts b/src/@ionic-native/plugins/google-nearby/index.ts index 3e3fb6a34..3ef6e97b0 100644 --- a/src/@ionic-native/plugins/google-nearby/index.ts +++ b/src/@ionic-native/plugins/google-nearby/index.ts @@ -27,7 +27,7 @@ import { Observable } from 'rxjs/Observable'; pluginName: 'GoogleNearby', plugin: 'cordova-plugin-google-nearby', pluginRef: 'window.nearby', - repo: 'https://github.com/hahahannes/googlenearby-cordova-plugin', + repo: 'https://github.com/hahahannes/cordova-plugin-google-nearby', install: 'ionic cordova plugin add cordova-plugin-google-nearby --variable API_KEY="123456789"', installVariables: ['API_KEY'], platforms: ['Android'] @@ -56,14 +56,4 @@ export class GoogleNearby extends IonicNativePlugin { subscribe(): Observable { return; } - -/** - * Unsubscribe from Messages - * @return {Promise} Returns a promise that resolves when you unsubscribed - */ - @Cordova() - unsubscribe(): Promise { - return; - } - }