パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v2.3.2

detect_fake_location

位置がシミュレートまたは偽装されているかどうかを検出するためのFlutterプラグイン

AndroidiOS
30日間ダウンロード
2700
いいね数
41
Pub ポイント
140

パッケージをインストール

flutter pub add detect_fake_location

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

デバイスの位置情報がシミュレートまたは偽装されているかどうかを検出するFlutterプラグインです。AndroidおよびiOSのプラットフォーム固有のAPIを利用して、GPS信号の不一致や異常な移動パターンなどのスプーフィングの兆候を分析します。これにより、アプリはユーザーの位置情報の正当性を確認でき、位置に敏感なアプリケーションにおけるセキュリティと信頼性が向上します。このプラグインは軽量で、既存のFlutterプロジェクトにスムーズに統合できます。

用途

  • ライドシェアリングアプリにおけるユーザーの位置確認
  • 位置情報ベースのサービスにおける詐欺防止
  • フィットネストラッキングアプリの正確性を保証する
  • 地理制限コンテンツへのアクセスを保護する
  • 偽のチェックインや場所共有の検出

主な機能

  • 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 件

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。