Nearby Messages API

Google Nearby Messages API for Flutter

Installation

First, add nearby_messages_api as a dependency in your pubspec.yaml file.

iOS

Coming Soon

Android

Get and add a google cloud nearby messages API key to your project https://developers.google.com/nearby/messages/android/get-started

Example

import 'package:nearby_messages_api/nearby_messages_api.dart';

class main {
    /**
    * This method gets the message when an a nearby device sends one
    */
    static void onFound(dynamic arguments) {
      print(arguments);
    }
    
    /**
    * This method gets the message when a nearby device leaves
    */
    static void onLost(dynamic arguments) {
      print(arguments);
    }
    
    NearbyMessagesApi nearbyMessagesApi = NearbyMessagesApi(onFound, onLost);
 
    Future<void> main() async {
      await nearbyMessagesApi.publish();
      await nearbyMessagesApi.backgroundSubscribe();
    
    Future<void> dispose() async {
      await nearbyMessagesApi.unPublish();
      await nearbyMessagesApi.backgroundUnsubscribe();
    }
}

Libraries

nearby_messages_api

Dart

VM

dart:ffi
Foreign Function Interface for interoperability with the C programming language. [...]

Web

dart:html
HTML elements and other resources for web-based applications that need to interact with the browser and the DOM (Document Object Model). [...]
dart:js
Low-level support for interoperating with JavaScript. [...]
dart:js_util
Utility methods to efficiently manipulate typed JSInterop objects in cases where the name to call is not known at runtime. You should only use these methods when the same effect cannot be achieved with @JS annotations. These methods would be extension methods on JSObject if Dart supported extension methods.