패키지, 저장소 및 앱 카테고리 검색

패키지 상세v2.0.0

geofence_flutter

Flutter 애플리케이션(안드로이드 및 iOS)용 지오페싱 플러그인입니다.

AndroidiOSWebmacOSWindows
30일 다운로드
25
좋아요
24
Pub 점수
140

패키지 설치

flutter pub add geofence_flutter

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

Geofence Flutter는 Android, iOS, Web, macOS, Windows용 플러터 애플리케이션에서 지오페싱 기능을 제공하는 크로스플랫폼 플러그인입니다. 개발자가 장치가 사전 정의된 지리적 영역에 진입하거나 탈출할 때를 모니터링할 수 있게 해주며, 위치 기반 트리거에 이상적입니다. 각 플랫폼의 네이티브 지오페싱 API와 원활하게 통합되어 앱이 백그라운드에서도 신뢰할 수 있는 이벤트 감지를 제공합니다. 원형 및 사용자 정의 형태의 지오페싱을 지원하며, 모니터링 간격과 정확도 설정을 구성할 수 있습니다. 단순성과 성능을 고려해 설계되었으며 실시간 위치 인식이 필요한 앱에 적합합니다.

사용 사례

  • 위치 기반 알림
  • 근접 알림
  • 자산 추적
  • 컨텍스트 인식 애플리케이션
  • 자동 체크인

주요 기능

  • 다중 플랫폼 지원 (Android, iOS, Web, macOS, Windows)
  • 백그라운드 지오페스 모니터링
  • 사용자 정의 지오펜스 모양
  • 입장/퇴장용 이벤트 기반 API
  • 사용자 정의 가능한 정확도 및 업데이트 간격

적합한 대상

  • 위치 지능을 갖춘 모바일 앱
  • 현장 서비스 관리 도구
  • 스마트 리테일 경험
  • 물류 및 배송 추적
  • 아웃도어 활동 앱

고려 사항

  • 모든 플랫폼에서 위치 권한이 필요합니다
  • 자주 모니터링할 경우 배터리 사용량이 증가할 수 있습니다
  • 정확도는 장치 하드웨어 및 네트워크 조건에 따라 달라집니다
  • 웹 지원은 브라우저 위치 정보 API에 국한됩니다
  • iOS 및 안드로이드의 백그라운드 실행 제약

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

Flutter Geofence

A flutter geofencing plugin for flutter application (android & ios) which provides geofencing functionalities.

Features

  • Geofence event triggered on location changes
  • Get continuous geofence event updates

Usage

To add the geofence_flutter to your flutter application read the install instructions. Below are some Android and iOS specifics that are required for the geofence_flutter to work correctly.

For android

AndroidX

The geofence_flutter plugin requires the AndroidX version of the Android Support Libraries. This means you need to make sure your Android project supports AndroidX. Detailed instructions can be found here.

The TL;DR version is:

  1. Add the following to your "gradle.properties" file:
android.useAndroidX=true
android.enableJetifier=true
  1. Make sure you set the compileSdkVersion in your "android/app/build.gradle" file to 33:
android {
  compileSdkVersion 33

  ...
}
  1. Make sure you replace all the android. dependencies to their AndroidX counterparts (a full list can be found here: https://developer.android.com/jetpack/androidx/migrate).

Permissions

On Android you'll need to add either the ACCESS_COARSE_LOCATION or the ACCESS_FINE_LOCATION permission to your Android Manifest. To do so open the AndroidManifest.xml file (located under android/app/src/main) and add one of the following two lines as direct children of the <manifest> tag (when you configure both permissions the ACCESS_FINE_LOCATION will be used):

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

Starting from Android 10 you need to add the ACCESS_BACKGROUND_LOCATION permission (next to the ACCESS_COARSE_LOCATION or the ACCESS_FINE_LOCATION permission) if you want to continue receiving updates even when your App is running in the background (note that the geofence_flutter plugin doesn't support receiving an processing geofence event updates while running in the background):

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

For ios

On iOS you'll need to add the following entries to your Info.plist file (located under ios/Runner) in order to access the device's location. Simply open your Info.plist file and add the following:

<key>NSLocationWhenInUseUsageDescription</key>
<string>This app needs access to location when open.</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>This app needs access to location when in the background.</string>

If you would like to receive updates when your App is in the background, you'll also need to add the Background Modes capability to your XCode project (Project > Signing and Capabilities > "+ Capability" button) and select Location Updates. Be careful with this, you will need to explain in detail to Apple why your App needs this when submitting your App to the AppStore. If Apple isn't satisfied with the explanation your App will be rejected.

API

Start Geofence Service

At first you need to start the geofence service and for that you need to pass the following parameters:

  • pointedLatitude: the latitude of the geofence area center
  • pointedLongitude: the longitude of the geofence area center
  • radiusMeter: the radius of the geofence area in meters
  • eventPeriodInSeconds: geofence event stream period in seconds
import 'package:geofence_flutter/geofence_flutter.dart';

await Geofence.startGeofenceService(
    pointedLatitude: "52.2165157",
    pointedLongitude: "6.9437819",
    radiusMeter: "50.0",
    eventPeriodInSeconds: 10
);
Get Geofence Event Streams

To get the stream geofence event updates on location changes, you need to subscribe getGeofenceStream to listen geofence event streams on current location updates.

import 'package:geofence_flutter/geofence_flutter.dart';

StreamSubscription<GeofenceEvent> geofenceEventStream = Geofence.getGeofenceStream()?.listen(
  (GeofenceEvent event) {
    print(event.toString());
});
Stop Geofence Service

To stop geofence service you need to specify this:

import 'package:geofence_flutter/geofence_flutter.dart';

Geofence.stopGeofenceService();

Also, stop GeofenceEvent stream subscription listener which is geofenceEventStream in our case

geofenceEventStream?.cancel();

Issues

Please file any issues, bugs or feature requests as an issue on our GitHub page.

Dependencies

This plugin is depended on geolocator plugin of baseflow.com

Want to contribute

If you would like to contribute to the plugin (e.g. by improving the documentation, solving a bug or adding a cool new feature), feel free to send your pull request.

Author

This geofence_flutter plugin for Flutter is developed by Sarfaraz.

카테고리

의존성

의존성 목록 1 개

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.