All Projects → umair13adil → simple_beacons_flutter

umair13adil / simple_beacons_flutter

Licence: Apache-2.0 license
A flutter plugin project to range & monitor iBeacons.

Programming Languages

kotlin
9241 projects
dart
5743 projects
swift
15916 projects
java
68154 projects - #9 most used programming language
ruby
36898 projects - #4 most used programming language
objective c
16641 projects - #2 most used programming language

Projects that are alternatives of or similar to simple beacons flutter

react-native-ibeacon-simulator
Simulate device act as an iBeacon, or transmit as an iBeacon signal from your phone
Stars: ✭ 48 (+65.52%)
Mutual labels:  ibeacon, ibeacon-support
PiBeacon
Low-cost iBeacon using Raspberry Pi
Stars: ✭ 41 (+41.38%)
Mutual labels:  ibeacon, ibeacon-support
iBeacon-Android
iBeacon scanner and simulator - Android application example
Stars: ✭ 28 (-3.45%)
Mutual labels:  ibeacon, ibeacon-support
GithubClient
Github iOS Client based on Github REST V3 API and GraphQL V4 API
Stars: ✭ 42 (+44.83%)
Mutual labels:  ios-app
tea-notes
Source code for Tea Notes app. Built with React Native. Search "Tea Notes" to download in app store.
Stars: ✭ 14 (-51.72%)
Mutual labels:  ios-app
Tasky
Tasky is a task management app made with SwiftUI.
Stars: ✭ 22 (-24.14%)
Mutual labels:  ios-app
Web Vuw
A Web View for flutter
Stars: ✭ 40 (+37.93%)
Mutual labels:  flutter-plugin
Awesome-Flutter-Templates
A Huge Collection of Flutter App templates
Stars: ✭ 53 (+82.76%)
Mutual labels:  ios-app
iBeacon-Demo
iBeacon demo in Swift
Stars: ✭ 22 (-24.14%)
Mutual labels:  ibeacon
Leon
Leon is swift library to show and slid images with more gesture
Stars: ✭ 16 (-44.83%)
Mutual labels:  ios-app
flutter mailer
A wrapper on top of MFMailComposeViewController from iOS and Mail Intent on android
Stars: ✭ 43 (+48.28%)
Mutual labels:  flutter-plugin
OFOBike
A demo app like OFO Bike in Swift.
Stars: ✭ 18 (-37.93%)
Mutual labels:  ios-app
flutter-moum
Flutter를 좋아하는 사람들이 모여서 Flutter 관련 지식과 기술을 모음📚
Stars: ✭ 67 (+131.03%)
Mutual labels:  flutter-plugin
flutter rtmppublisher
Publisher to rtmp using the camera plugin as a basis to do all the basic camera/record management.
Stars: ✭ 86 (+196.55%)
Mutual labels:  flutter-plugin
Iris.iOS
An iOS application enables you explore art works provided by DeviartArt.com with high quality UX.
Stars: ✭ 60 (+106.9%)
Mutual labels:  ios-app
OnboardingSample
Beginners - A demo of an onboarding screen in iOS using Swift
Stars: ✭ 95 (+227.59%)
Mutual labels:  ios-app
justBreathe
A minimal meditation app made with Flutter
Stars: ✭ 47 (+62.07%)
Mutual labels:  ios-app
pal-widgets
A collection of widgets for making amazing onboarding experience in your flutter applications
Stars: ✭ 21 (-27.59%)
Mutual labels:  flutter-plugin
survey kit
Flutter library to create beautiful surveys (aligned with ResearchKit on iOS)
Stars: ✭ 68 (+134.48%)
Mutual labels:  flutter-plugin
flutter vibration
Handle vibration on iOS and Android in Flutter apps
Stars: ✭ 146 (+403.45%)
Mutual labels:  flutter-plugin

beacons_plugin

pub package

This plugin is developed to scan nearby iBeacons on both Android iOS. This library makes it easier to scan & range nearby BLE beacons and read their proximity values.

Android

For Android change min SDK version:

defaultConfig {
  ...
  minSdkVersion 19
  ...
}

Change your Android Project's MainActivity class to following:

import com.umair.beacons_plugin.BeaconsPlugin
import io.flutter.embedding.android.FlutterActivity

class MainActivity : FlutterActivity(){

    override fun onPause() {
        super.onPause()

        //Start Background service to scan BLE devices
        BeaconsPlugin.startBackgroundService(this)
    }

    override fun onResume() {
        super.onResume()

        //Stop Background service, app is in foreground
        BeaconsPlugin.stopBackgroundService(this)
    }
}

That's it for Android.

iOS

In your AppDelegate.swift file change it to like this:

    
    import UIKit
    import Flutter
    import CoreLocation
    
    @UIApplicationMain
    @objc class AppDelegate: FlutterAppDelegate {
    
        let locationManager = CLLocationManager()
    
        override func application(
            _ application: UIApplication,
            didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
        ) -> Bool {
    
            locationManager.requestAlwaysAuthorization()
            GeneratedPluginRegistrant.register(with: self)
    
            return super.application(application, didFinishLaunchingWithOptions: launchOptions)
        }
    }

In your Info.plist file add following lines:

    <dict>
      <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
    	<string>App needs location permissions to scan nearby beacons.</string>
    	<key>NSLocationWhenInUseUsageDescription</key>
    	<string>App needs location permissions to scan nearby beacons.</string>
    	<key>NSLocationAlwaysUsageDescription</key>
    	<string>App needs location permissions to scan nearby beacons.</string>
    </dict>

Install

In your pubspec.yaml

dependencies:
  beacons_plugin: [LATEST_VERSION]
import 'dart:async';
import 'dart:io' show Platform;
import 'package:flutter/services.dart';
import 'package:beacons_plugin/beacons_plugin.dart';

Ranging Beacons & Setting Up

    // if you need to monitor also major and minor use the original version and not this fork
    BeaconsPlugin.addRegion("myBeacon", "01022022-f88f-0000-00ae-9605fd9bb620")
        .then((result) {
          print(result);
        });
    
    //Send 'true' to run in background [OPTIONAL]
    await BeaconsPlugin.runInBackground(true);
    
    //IMPORTANT: Start monitoring once scanner is setup & ready (only for Android)
    if (Platform.isAndroid) {
      BeaconsPlugin.channel.setMethodCallHandler((call) async {
        if (call.method == 'scannerReady') {
          await BeaconsPlugin.startMonitoring();
        }
      });
    } else if (Platform.isIOS) {
      await BeaconsPlugin.startMonitoring();
    }
    

Listen To Beacon Scan Results as Stream

    
    final StreamController<String> beaconEventsController = StreamController<String>.broadcast();
    BeaconsPlugin.listenToBeacons(beaconEventsController);
    
    beaconEventsController.stream.listen(
        (data) {
          if (data.isNotEmpty) {
            setState(() {
              _beaconResult = data;
            });
            print("Beacons DataReceived: " + data);
          }
        },
        onDone: () {},
        onError: (error) {
          print("Error: $error");
        });

Stop Listening to Beacons

     await BeaconsPlugin.stopMonitoring();

Run in Background

    //Send 'true' to run in background
     await BeaconsPlugin.runInBackground(true);

Clear Regions

    await BeaconsPlugin.clearRegions();

Add custom beacons layout (AltBeacon)

    BeaconsPlugin.addBeaconLayoutForAndroid(
            "m:2-3=beac,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25");

Add custom Foreground scan periods (AltBeacon)

    BeaconsPlugin.setForegroundScanPeriodForAndroid(
            foregroundScanPeriod: 2200, foregroundBetweenScanPeriod: 10);

Add custom Background scan periods (AltBeacon)

    BeaconsPlugin.setBackgroundScanPeriodForAndroid(
            backgroundScanPeriod: 2200, backgroundBetweenScanPeriod: 10);

Set the level of debug messages

    //Valid values: 0 = no messages, 1 = errors, 2 = all messages
    await BeaconsPlugin.setDebugLevel(int value);

Set Prominent Disclosure message (Android 10)

See: Link

    if (Platform.isAndroid) {
    
      //Prominent disclosure
      await BeaconsPlugin.setDisclosureDialogMessage(
          title: "Need Location Permission",
          message: "This app collects location data to work with beacons.");

      //Only in case, you want the dialog to be shown again. By Default, dialog will never be shown if permissions are granted.
      await BeaconsPlugin.clearDisclosureDialogShowFlag(false);
    }

    BeaconsPlugin.channel.setMethodCallHandler((call) async {
        if (call.method == 'isPermissionDialogShown') {
          //Do something here
        }
    });

Scan Results

Data Android iOS
name Yes Yes
uuid Yes Yes
major Yes Yes
minor Yes Yes
distance Yes Yes
proximity Yes Yes
rssi Yes Yes
macAddress Yes No
txPower Yes No

Native Libraries

Author

Flutter Beacons plugin is developed by Umair Adil. You can email me at [email protected] for any queries.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].