23
19

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

FlutterでiOS/Android 識別ID取得

Posted at

Flutterアプリ開発において使用APIのリクエストとしてデバイスを識別するためのIDが必要な場面があったのでiOS、Androidでそれぞれ個体識別IDを取得してみた。

iOSはUUID、AndroidならデバイスIDがそれぞれ個体識別IDになる
これらを取得するにはdevice_infoパッケージを使用する

パッケージの取得

pubspec.yaml

dependencies:
  flutter:
    sdk: flutter
  device_info: ^0.4.0+2

Packages Getでパッケージをインストール

実際にID取得

device_infoパッケージをimportする

import 'package:device_info/device_info.dart';

Android

DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
print('Running on ${androidInfo.androidId}');  // => Android デバイスID出力

iOS

DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
IosDeviceInfo iosDeviceInfo = await deviceInfo.iosInfo;
print('Running on ${iosDeviceInfo.identifierForVendor}');  // => iOS UUID 出力
23
19
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
23
19

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?