diff --git a/.vscode/launch.json b/.vscode/launch.json
deleted file mode 100644
index 3287bb6..0000000
--- a/.vscode/launch.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- // Use IntelliSense to learn about possible attributes.
- // Hover to view descriptions of existing attributes.
- // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
- "version": "0.2.0",
- "configurations": [
- {
- "name": "Flutter",
- "request": "launch",
- "type": "dart"
- }
- ]
-}
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 41cc7d8..28e9d23 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,6 @@
## 0.0.1
-* TODO: Describe initial release.
+* Currently only bytes (max 32k array size) payload are supported
+* Analogous to NearbyConnection library in Android with similar callback names and all
+* Singleton pattern using factory constructor
+
diff --git a/LICENSE b/LICENSE
index ba75c69..ed4feaf 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1 +1,25 @@
-TODO: Add your license here.
+BSD 2-Clause License
+
+Copyright (c) 2019, Prerak Mann
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/README.md b/README.md
index ce49602..646038e 100644
--- a/README.md
+++ b/README.md
@@ -5,6 +5,7 @@ An android flutter plugin for the Nearby Connections API
## Getting Started
### Set Permissions
+Add these to AndroidManifest.xml
```xml
@@ -16,3 +17,98 @@ An android flutter plugin for the Nearby Connections API
```
Since ACCESS_FINE_LOCATION is considered to be dangerous system permissions, in addition to adding them to your manifest, you must request these permissions at runtime.
+##### As a convinience the library provides methods to check and request location permissions
+```java
+// returns true/false asynchronously
+bool a = await Nearby().checkPermissions()
+
+// asks for permissions only if its not given
+Nearby().askPermission()
+```
+
+### Working Flow
+
+The working flow is similar to the [android nearby connections library](https://developers.google.com/nearby/connections/overviewoverview)
+
+#### Advertise for connection
+```dart
+try {
+ bool a = await Nearby().startAdvertising(
+ userName,
+ strategy,
+ onConnectionInitiated: (String id,ConnectionInfo info) {
+ // Called whenever a discoverer requests connection
+ },
+ onConnectionResult: (String id,Status status) {
+ // Called when connection is accepted/rejected
+ },
+ onDisconnected: (id) {
+ // Callled whenever a discoverer disconnects from advertiser
+ },
+ );
+} catch (exception) {
+ // platform exceptions like unable to start bluetooth or insufficient permissions
+}
+```
+#### Discover Advertisers
+```dart
+try {
+ bool a = await Nearby().startDiscovery(
+ userName,
+ strategy,
+ onEndpointFound: (String id,String name, String serviceId) {
+ // called when an advertiser is found
+ },
+ onEndpointLost: (String id) {
+ //called when an advertiser is lost (only if we weren't connected to it )
+ },
+ );
+} catch (e) {
+ // platform exceptions like unable to start bluetooth or insufficient permissions
+}
+```
+#### Start and Stop Discovery
+```dart
+Nearby().stopAdvertising();
+Nearby().stopDiscovery();
+
+```
+### Request Connection
+```dart
+// to be called by discover whenever an endpoint is found
+// callbacks are similar to those in startAdvertising method
+try{
+ Nearby().requestConnection(
+ userName,
+ id,
+ onConnectionInitiated: (id, info) {
+ },
+ onConnectionResult: (id, status) {
+ },
+ onDisconnected: (id) {
+ },
+ );
+}catch(exception){
+ // called if request was invalid
+}
+```
+#### Accept Connections
+```dart
+Nearby().acceptConnection(
+ id,
+ onPayLoadRecieved: (endid,Uint8List bytes) {
+ // called whenever a payload is recieved.
+ },
+);
+```
+### Sending Payload
+
+```dart
+Nearby().sendPayload(endpointId, bytes_array);
+
+// payloads are recieved by callback given to acceptConnection method.
+```
+
+
+
+
diff --git a/example/lib/main.dart b/example/lib/main.dart
index 3366535..e44db47 100644
--- a/example/lib/main.dart
+++ b/example/lib/main.dart
@@ -2,9 +2,6 @@ import 'dart:math';
import 'dart:typed_data';
import 'package:flutter/material.dart';
-import 'dart:async';
-
-import 'package:flutter/services.dart';
import 'package:nearby_connections/nearby_connections.dart';
void main() => runApp(MyApp());
diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart
deleted file mode 100644
index e8ad300..0000000
--- a/example/test/widget_test.dart
+++ /dev/null
@@ -1,27 +0,0 @@
-// This is a basic Flutter widget test.
-//
-// To perform an interaction with a widget in your test, use the WidgetTester
-// utility that Flutter provides. For example, you can send tap and scroll
-// gestures. You can also use WidgetTester to find child widgets in the widget
-// tree, read text, and verify that the values of widget properties are correct.
-
-import 'package:flutter/material.dart';
-import 'package:flutter_test/flutter_test.dart';
-
-import 'package:nearby_connections_example/main.dart';
-
-void main() {
- testWidgets('Verify Platform version', (WidgetTester tester) async {
- // Build our app and trigger a frame.
- await tester.pumpWidget(MyApp());
-
- // Verify that platform version is retrieved.
- expect(
- find.byWidgetPredicate(
- (Widget widget) => widget is Text &&
- widget.data.startsWith('Running on:'),
- ),
- findsOneWidget,
- );
- });
-}
diff --git a/pubspec.yaml b/pubspec.yaml
index 8cf2b01..261d28e 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,8 +1,8 @@
name: nearby_connections
description: A new Flutter plugin.
version: 0.0.1
-author:
-homepage:
+author: Prerak Mann
+homepage: https://github.com/mannprerak2/nearby_connections
environment:
sdk: ">=2.1.0 <3.0.0"
@@ -15,46 +15,7 @@ dev_dependencies:
flutter_test:
sdk: flutter
-# For information on the generic Dart part of this file, see the
-# following page: https://www.dartlang.org/tools/pub/pubspec
-
-# The following section is specific to Flutter.
flutter:
- # This section identifies this Flutter project as a plugin project.
- # The androidPackage and pluginClass identifiers should not ordinarily
- # be modified. They are used by the tooling to maintain consistency when
- # adding or updating assets for this project.
plugin:
androidPackage: com.pkmnapps.nearby_connections
pluginClass: NearbyConnectionsPlugin
-
- # To add assets to your plugin package, add an assets section, like this:
- # assets:
- # - images/a_dot_burr.jpeg
- # - images/a_dot_ham.jpeg
- #
- # For details regarding assets in packages, see
- # https://flutter.dev/assets-and-images/#from-packages
- #
- # An image asset can refer to one or more resolution-specific "variants", see
- # https://flutter.dev/assets-and-images/#resolution-aware.
-
- # To add custom fonts to your plugin package, add a fonts section here,
- # in this "flutter" section. Each entry in this list should have a
- # "family" key with the font family name, and a "fonts" key with a
- # list giving the asset and other descriptors for the font. For
- # example:
- # fonts:
- # - family: Schyler
- # fonts:
- # - asset: fonts/Schyler-Regular.ttf
- # - asset: fonts/Schyler-Italic.ttf
- # style: italic
- # - family: Trajan Pro
- # fonts:
- # - asset: fonts/TrajanPro.ttf
- # - asset: fonts/TrajanPro_Bold.ttf
- # weight: 700
- #
- # For details regarding fonts in packages, see
- # https://flutter.dev/custom-fonts/#from-packages
diff --git a/test/nearby_connections_test.dart b/test/nearby_connections_test.dart
index 57c8a08..4120ef6 100644
--- a/test/nearby_connections_test.dart
+++ b/test/nearby_connections_test.dart
@@ -1,6 +1,5 @@
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
-import 'package:nearby_connections/nearby_connections.dart';
void main() {
const MethodChannel channel = MethodChannel('nearby_connections');