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

client_information のカバー
パッケージ詳細v2.2.0

client_information

このプラグインを使用すると、アプリケーションクライアントの基本情報を取得できます。使いやすく、さまざまなプラットフォーム(Android、iOS、Web)をサポートしています。

AndroidiOSWeb
30日間ダウンロード
5450
いいね数
53
Pub ポイント
140

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

flutter pub add client_information

パッケージ概要

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

client_information パッケージは、Flutter アプリケーション内の基本的なクライアントデバイス情報へのアクセスを容易にします。Android、iOS、Web プラットフォームをサポートしており、モデル、OS バージョン、プラットフォームタイプなどの重要なデバイス情報を取得できます。シンプルな設計により、直感的な API を使用して既存のプロジェクトにスムーズに統合可能です。分析、デバッグ、パーソナライゼーション機能に最適で、さまざまな環境での一貫した動作を保証します。

用途

  • デバイス分析
  • ユーザーのプロファイリング
  • デバッグとトラブルシューティング
  • パーソナライズされたユーザー体験
  • クロスプラットフォームアプリ開発

主な機能

  • クロスプラットフォーム対応(Android、iOS、Web)
  • シンプルで直感的な API
  • デバイスモデルおよびOS情報の取得
  • 軽量で高速
  • プラットフォーム間での一貫したデータ

適している対象

  • クロスプラットフォームアプリを開発する開発者
  • デバイスレベルのインサイトが必要なチーム
  • ユーザー端末のコンテキストを必要とするアプリ
  • 分析およびモニタリングツール
  • Web とモバイルのハイブリッドアプリケーション

注意事項

  • Android および iOS には適切な権限が必要です
  • 基本的なデバイス情報に限定
  • データ収集時にはプライバシー準拠が必須です
  • リアルタイムの更新なし
  • プラットフォーム固有の実装に依存しています

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

Client Information

This is a plugin that lets you get basic information from your application's client. It's easy to use and supports different platforms (Android, iOS, and Web). There are four different information types: "application information", "software information", "operating system information", and "device information".

Pub License: MIT

iOS screenshot

Android screenshot

Web screenshot

Information Types

There are 4 different types:

  1. Application Information
  2. Software Information
  3. Operating System Information
  4. Device Information
Application Information

Application information is all about the application you build. And notice that applicationId is not supported for web applications.

Attribute iOS Android Web
applicationId
String
⭕
bundleIdentifier
⭕
package name
❌
default: application name
applicationType
String (app/web)
⭕ ⭕ ⭕
applicationName
String
⭕ ⭕ ⭕
applicationVersion
String
⭕ ⭕ ⭕
applicationBuildCode
String
⭕ ⭕ ⭕

Software Information

"Software" stands for the "software" that runs your application, such as "Operating System" for iOS/Android projects or "Browser" for web projects.

Attribute iOS Android Web
softwareName
String
⭕
OS name
⭕
OS name
⭕
Browser name
softwareVersion
String
⭕
OS version
⭕
OS version
⭕
Browser version

Operating System Information

OS information will show you the OS's name and version. Notice: Web projects may not get this information if the browser's user-agent doesn't contain any information about the operating system.

Attribute iOS Android Web
osName
String
⭕
OS name
⭕
OS name
⚠️
OS name
(*unknown possible)
osVersion
String
⭕
OS version
⭕
OS version
⚠️
OS Version
(*unknown possible)
osVersionCode
String
⭕
iOS version(number)
⭕
Android API level
⚠️
OS Version(number)
(*unknown: -1)

Device Information

The device information will display device's ID and name. Note that web projects don't support real deviceId, so they will use the package uuid to generate a unique string and save to the browser's cookie.

Attribute iOS Android Web
deviceId
String
⭕ ⭕ ⭕
deviceName
String
⭕ ⭕ ❌
default: osName osVersion / browserName browserVersion
(e.g. iOS 14 / Chrome 88.0)

Getting Started

In the pubspec.yaml of your flutter project, add the following dependency:

dependencies:
  ...
  client_information: ^2.2.0

In your project add the following import:

import 'package:client_information/client_information.dart';

Then, you can get information like this:

// Get client information
ClientInformation info = await ClientInformation.fetch();

print(info.deviceId); // EA625164-4XXX-XXXX-XXXXXXXXXXXX
print(info.osName); // iOS

Decoration

Starting from version 2.1.0, you can customize some information by passing the decorators. Like below:

var information = await ClientInformation.fetch(
      // you can pass decorators to decoration the value before it return.
      decorators: ClientInformationDecorators(
        deviceId: (oriInfo, value) =>
            'prefix-$value-${oriInfo.applicationName}',
      ),
    );

Or, you can use extension method like this:

var information = await ClientInformation.fetch();
print('Original DeviceId: ${information.deviceId}');
// Original DeviceId: EA625164-4XXX-XXXX-XXXXXXXXXXXX

var decoratedInfo = information.decoration(deviceId: (oriInfo, value) => '$value-some-suffix-string-here');
print('Decorated DeviceId: ${decoratedInfo.deviceId}');
// Decorated DeviceId: EA625164-4XXX-XXXX-XXXXXXXXXXXX-some-suffix-string-here

Mock Data for Test

Starting from version 1.0.2, you can mock data or enable "mockMode" to facilitate testing. Here is how to set it up:


In your test file:

setUp(() async {
  // Change to "MockMode" and set the default data you need.
  ClientInformation.mockOn(
      deviceId: 'mock_device_id', osName: 'MyCustomOS');
});

tearDown(() {
  // Close the "MockMode" in tearDown method
  ClientInformation.mockOff();
});

// Run your test
test('`deviceId` will be "mock_device_id"', () async {
  ClientInformation info = await ClientInformation.fetch();
  expect(info.deviceId, 'mock_device_id');
});

カテゴリー

依存関係

依存関係一覧 1 件

ソースリポジトリ

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

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