geofence 1.0.1

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • new68

geofence

This plugin help get geofence notification

Getting Started

Android

Add the following lines to your AndroidManifest.xml to register the background service for geofencing:

<receiver   android:name="com.webstersys.geofence.geofence.GeofenceBroadcastReceiver"
            android:enabled="true"
            android:exported="true" />
<service android:name="com.webstersys.geofence.geofence.GeofenceTransitionsJobIntentService" android:enabled="true" android:exported="true"
            android:permission="android.permission.BIND_JOB_SERVICE"/>
<receiver android:name="com.webstersys.geofence.BootDeviceReceiver">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED"/>
            </intent-filter>
</receiver>

Also request the correct permissions for geofencing:

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>

Finally, create either Application.kt or Application.java in the same directory as MainActivity.

For Application.kt, use the following:

class Application : FlutterApplication(), PluginRegistrantCallback {
  override fun onCreate() {
    super.onCreate();
    GeofenceTransitionsJobIntentService.setPluginRegistrant(this)
  }

  override fun registerWith(registry: PluginRegistry) {
    GeneratedPluginRegistrant.registerWith(registry);
  }
}

For Application.java, use the following:

public class Application extends FlutterApplication implements PluginRegistrantCallback {
  @Override
  public void onCreate() {
    super.onCreate();
     GeofenceTransitionsJobIntentService.setPluginRegistrant(this);
  }

  @Override
  public void registerWith(PluginRegistry registry) {
    GeneratedPluginRegistrant.registerWith(registry);
  }
}

Which must also be referenced in AndroidManifest.xml:

   <application
        android:name=".Application" />

0.0.1

  • Added Geofence Flutter Plugin With Only Android Support

example/README.md

geofence_example

Demonstrates how to use the geofence plugin.

Getting Started



import 'dart:isolate';
import 'dart:ui';

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:geofence/geofence.dart';
import 'package:geofence/geofence_event.dart';
import 'package:geofence/geofence_region.dart';
import 'package:geofence/location.dart';

void main() => runApp(new MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => new _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';

  @override
  void initState() {
    super.initState();
    // initPlatformState();
    initGeofence();
  }

  static void callback(Location l, GeofenceEvent e) async {
    print('Location $l Event: $e');
    final SendPort send =
        IsolateNameServer.lookupPortByName('geofencing_send_port');
    send?.send(e.toString());
  }

  Future<void> initGeofence() async {
    try {
      bool isInitialized = await Geofence.initialize();
      print("Geofence plugin initialzed : $isInitialized");
      var region = GeofenceRegion(Location(18.4825, 73.7973), 3000.00);
      bool geofenceAdded = await Geofence.registerGeofence(region, callback);
      //await Geofence.unRegisterGeofence();
    } catch (e) {
      print(e);
    }
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String platformVersion;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      platformVersion = await Geofence.platformVersion;
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
    });
  }

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: const Text('Plugin example app'),
        ),
        body: new Center(
          child: new Text('Running on: $_platformVersion\n'),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  geofence: ^1.0.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:geofence/geofence.dart';
  
Version Uploaded Documentation Archive
1.0.1 Nov 5, 2018 Go to the documentation of geofence 1.0.1 Download geofence 1.0.1 archive
1.0.0 Nov 5, 2018 Go to the documentation of geofence 1.0.0 Download geofence 1.0.0 archive
0.0.2 Nov 5, 2018 Go to the documentation of geofence 0.0.2 Download geofence 0.0.2 archive
0.0.1 Nov 5, 2018 Go to the documentation of geofence 0.0.1 Download geofence 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
36
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
68
Learn more about scoring.

We analyzed this package on Nov 14, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.6
  • Flutter: 0.11.3

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8