GithubHelp home page GithubHelp logo

vikramkapoor / fluttergeofencing Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ubheamar/fluttergeofencing

0.0 2.0 0.0 189 KB

Rough work for Flutter geofencing plugin

License: Other

Kotlin 42.79% Ruby 4.79% Objective-C 23.79% Dart 28.63%

fluttergeofencing's Introduction

Geofencing

A sample geofencing plugin with background execution support for Flutter.

Getting Started

This plugin works on both Android and iOS. Follow the instructions in the following sections for the platforms which are to be targeted.

Android

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

<receiver android:name="io.flutter.plugins.geofencing.GeofencingBroadcastReceiver"
    android:enabled="true" android:exported="true"/>
<service android:name="io.flutter.plugins.geofencing.GeofencingService"
    android:permission="android.permission.BIND_JOB_SERVICE" android:exported="true"/>

Also request the correct permissions for geofencing:

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

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();
    GeofencingService.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();
    GeofencingService.setPluginRegistrant(this);
  }

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

Which must also be referenced in AndroidManifest.xml:

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

iOS

Add the following lines to your Info.plist:

<dict>
    <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
    <string>YOUR DESCRIPTION HERE</string>
    <key>NSLocationWhenInUseUsageDescription</key>
    <string>YOUR DESCRIPTION HERE</string>
    ...

And request the correct permissions for geofencing:

<dict>
    ...
    <string>Main</string>
    <key>UIRequiredDeviceCapabilities</key>
    <array>
        <string>location-services</string>
        <string>gps</string>
        <string>armv7</string>
    </array>
    <key>UIBackgroundModes</key>
    <array>
        <string>location</string>
    </array>
    ...
</dict>

Need Help?

For help getting started with Flutter, view our online documentation.

For help on editing plugin code, view the documentation.

fluttergeofencing's People

Contributors

bkonyi avatar ubheamar avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.