android_cn_oaid 0.0.2 copy "android_cn_oaid: ^0.0.2" to clipboard
android_cn_oaid: ^0.0.2 copied to clipboard

PlatformAndroid

Flutter Android plugin for getting OAID/AAID and other device identifiers via Android_CN_OAID library.

android_cn_oaid #

English | 中文

A Flutter Android plugin that bridges Android_CN_OAID to obtain OAID (Open Anonymous Device Identifier), AAID, and other device identifiers from mainstream Chinese Android manufacturers.

Android only. Calling any method on other platforms throws UnsupportedError.

Table of Contents #


Features #

  • Get OAID / AAID asynchronously (supports mainstream Chinese manufacturers)
  • Get AndroidID, PseudoID, GUID as fallback identifiers
  • Privacy-compliant initialization — call register() only after user consent
  • Structured error handling via OaidException

Supported Manufacturers #

Manufacturer System / Framework
Huawei HMS Core 2.6.2+, Google Play Service 4.0+
Honor Magic UI 4/5/6, MagicOS 7.0+, Google Play Service 4.0+
Xiaomi / Redmi / BlackShark MIUI 10.2+, Google Play Service 4.0+
VIVO / iQOO Funtouch OS 9+, OriginOS 1.0+, Google Play Service 4.0+
OPPO / Realme ColorOS 7.0+, Google Play Service 4.0+
Samsung Android 10+, Google Play Service 4.0+
Lenovo ZUI 11.4+, Google Play Service 4.0+
ASUS Android 10+, Google Play Service 4.0+
Meizu Android 10+, Google Play Service 4.0+
OnePlus Android 10+, Google Play Service 4.0+
Nubia Android 10+, Google Play Service 4.0+
Coolpad CoolOS, Google Play Service 4.0+
Others (ZTE, HTC, Motorola…) Google Play Service 4.0+

Installation #

Add to your pubspec.yaml:

dependencies:
  android_cn_oaid: ^0.0.1

Usage #

1. Privacy Compliance — register() #

Call register() after the user has agreed to your privacy policy. This pre-initializes the OAID service.

import 'package:android_cn_oaid/android_cn_oaid.dart';

final plugin = AndroidCnOaid();

// Call this after user agrees to privacy policy
await plugin.register();

2. Check Support #

final supported = await plugin.isSupported();
if (!supported) {
  // Device does not support OAID or AAID
}

3. Get OAID / AAID #

try {
  // Auto-selects the best available method
  final oaid = await plugin.getOAID();
  print('OAID: $oaid'); // null if not supported

  // Or use manufacturer-specific interface
  final mfrOaid = await plugin.getOAIDByManufacturer();
} on OaidException catch (e) {
  print('Error [${e.code}]: ${e.message}');
}

4. Get Other Identifiers #

final androidId = await plugin.getAndroidID(); // String? — may be null
final pseudoId  = await plugin.getPseudoID();  // String  — never null, may repeat
final guid      = await plugin.getGUID();      // String  — never null, random

5. Get Supported Manufacturers #

final manufacturers = await plugin.getSupportedManufacturers();
print(manufacturers); // ['Huawei', 'Honor', 'Xiaomi', ...]

API Reference #

Method Return Type Description
register() Future<void> Pre-initialize OAID service. Call after privacy policy consent.
isSupported() Future<bool> Check if device supports OAID or AAID.
getOAID() Future<String?> Get OAID or AAID. Returns null if unsupported.
getOAIDByManufacturer() Future<String?> Get ad identifier via manufacturer-specific interface.
getAndroidID() Future<String?> Get Android ID. May return null.
getPseudoID() Future<String> Get PseudoID (hardware-based, never null, may repeat).
getGUID() Future<String> Get GUID (randomly generated, never null).
getSupportedManufacturers() Future<List<String>> Get list of supported manufacturer names.

Error Handling #

All methods may throw OaidException when the native layer encounters an error:

try {
  final oaid = await plugin.getOAID();
} on OaidException catch (e) {
  switch (e.code) {
    case 'permission_denied':
      // SecurityException on the Android side
      break;
    case 'oaid_error':
      // General error during OAID retrieval
      break;
  }
  print('${e.code}: ${e.message}');
} on UnsupportedError catch (e) {
  // Called on a non-Android platform
  print(e.message);
}

Error codes:

Code Cause
oaid_error General exception during OAID/AAID retrieval
permission_denied SecurityException thrown by the Android system

Privacy Compliance Notes #

Per Chinese app compliance requirements:

  1. Do not call register() before the user agrees to your privacy policy.
  2. Call all identifier methods after register().
  3. Disclose device identifier usage in your app's privacy policy.
2
likes
160
points
118
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Flutter Android plugin for getting OAID/AAID and other device identifiers via Android_CN_OAID library.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on android_cn_oaid

Packages that implement android_cn_oaid