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

패키지 상세v2.3.2

detect_fake_location

위치가 시뮬레이션되거나 위조되었는지 감지하기 위한 플러터 플러그인

AndroidiOS
30일 다운로드
2.7천
좋아요
41
Pub 점수
140

패키지 설치

flutter pub add detect_fake_location

패키지 개요

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

기기의 위치가 시뮬레이션되거나 위조되었는지 감지하는 플러터 플러그인입니다. 안드로이드 및 iOS에서 플랫폼 전용 API를 활용하여 GPS 신호의 일관성 부족이나 비정상적인 이동 패턴과 같은 위조 징후를 분석합니다. 이를 통해 앱은 사용자 위치의 진위 여부를 확인할 수 있으며, 위치 민감한 애플리케이션의 보안과 신뢰성을 향상시킵니다. 이 플러그인은 가볍고 기존 플러터 프로젝트에 원활하게 통합됩니다.

사용 사례

  • 공유 탑승 앱에서 사용자 위치 확인
  • 지오로케이션 기반 서비스에서의 사기 방지
  • 피트니스 트래킹 앱의 정확성 보장
  • 지역 제한 콘텐츠에 대한 액세스 보호
  • 가짜 체크인 또는 위치 공유 감지

주요 기능

  • Android 및 iOS용 크로스 플랫폼 지원
  • 정확한 탐지에 네이티브 장치 API 사용
  • 경량이며 통합이 쉬움
  • 위치 위조에 대한 명확한 표시 제공
  • 최소 성능 오버헤드

적합한 대상

  • 안전한 위치 검증이 필요한 앱
  • 위치 인식 서비스를 구축하는 개발자
  • 사기 방지 요구 사항이 있는 애플리케이션
  • 실시간 지리 위치를 사용하는 모바일 앱
  • 위치 무결성 기준 준수를 필요로 하는 프로젝트

고려 사항

  • 위치 접근을 위한 적절한 권한이 필요합니다
  • 모든 고급 스푸핑 방법을 감지하지 못할 수 있습니다
  • 기기 간에 동작이 약간 다를 수 있습니다
  • 서버 측 검증의 대체가 아님
  • 루트 또는 제일브레이크된 장치에서의 효과는 제한적

원본 README

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

detect_fake_location

This is a Flutter plugin that detects if the user is using a fake(mock or simulated) location on their device.

Pub License GitHub code size in bytes

Installation

To use this plugin, add detect_fake_location as a dependency in your pubspec.yaml file.

Permissions

iOS

Add the following entries to your Info.plist file

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

Add the following to your Podfile

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    # Start of the permission_handler configuration
    target.build_configurations.each do |config|
      config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
        '$(inherited)',
      # dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
        'PERMISSION_LOCATION=1'
    ]
    end
  end
end
Android

Add the ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION permission to your Android Manifest.

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

Usage

Import the package with:

import 'package:detect_fake_location/detect_fake_location.dart';

Then you can use the following method to check if the user is using a fake location:

// Basic usage (default behavior)
bool isFakeLocation = await DetectFakeLocation().detectFakeLocation();

// Advanced usage with configuration options
bool isFakeLocation = await DetectFakeLocation().detectFakeLocation(
  ignoreExternalAccessory: true, // Ignore external accessories like CarPlay
);

Configuration Options

ignoreExternalAccessory (iOS only)

By default, the plugin detects fake locations from both software simulation and external accessories. However, external accessories like CarPlay, external GPS devices, or other legitimate hardware can trigger false positives.

  • Default: false (maintains backward compatibility)
  • When to use true: If you want to ignore location data from external accessories and only detect software-based fake locations
  • Use case: Prevent false positives when users have legitimate external accessories connected
// Only detect software-simulated locations, ignore external accessories
bool isFakeLocation = await DetectFakeLocation().detectFakeLocation(
  ignoreExternalAccessory: true,
);

Example

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

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'My App',
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('My App'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            ElevatedButton(
              child: Text('Detect Fake Location (Standard)'),
              onPressed: () async {
                bool isFakeLocation =
                    await DetectFakeLocation().detectFakeLocation();
                _showResult(context, isFakeLocation, 'Standard Mode');
              },
            ),
            SizedBox(height: 20),
            ElevatedButton(
              child: Text('Detect Fake Location (Ignore External Accessory)'),
              onPressed: () async {
                bool isFakeLocation = await DetectFakeLocation()
                    .detectFakeLocation(ignoreExternalAccessory: true);
                _showResult(context, isFakeLocation, 'Ignore External Accessory Mode');
              },
            ),
          ],
        ),
      ),
    );
  }

  void _showResult(BuildContext context, bool isFakeLocation, String mode) {
    showDialog(
      context: context,
      builder: (BuildContext context) {
        return AlertDialog(
          title: Text('Fake Location Detection Result'),
          content: Text(
              'Mode: $mode\nThe user is${isFakeLocation ? '' : ' not'} using a fake location.'),
          actions: <Widget>[
            TextButton(
              child: Text('OK'),
              onPressed: () {
                Navigator.of(context).pop();
              },
            ),
          ],
        );
      },
    );
  }
}

Image 1 Image 2

Limitations

For iOS, the plugin uses the CLLocationSourceInformation class to detect if the location is simulated by software or produced by an external accessory. This class is only available on iOS 15 or later.

Contribute

Contributions are welcome! Please submit issues and pull requests on the GitHub repository.

Credits

For requesting permissions: permission_handler

카테고리

의존성

의존성 목록 2 개

소스 저장소

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

아직 데이터가 없습니다.