【问题标题】:how to get device id from flutter web如何从 Flutter Web 获取设备 ID
【发布时间】:2022-01-19 06:54:45
【问题描述】:

我需要为我的 Flutter Web 应用程序获取 Device_id,我的意思是当我在移动设备上的浏览器上打开应用程序时,我需要获取设备 ID。

我尝试了各种库,但它们提供的只是浏览器数据。我该如何解决这个问题?

【问题讨论】:

    标签: android ios flutter device wpa


    【解决方案1】:

    使用包device_info

    you can use flutter package  <device_info>  to get device info.
    following function will help to get device id
    
    Future<String> _getId() async {
     var deviceInfo = DeviceInfoPlugin();
     if (Platform.isIOS) {
       // import 'dart:io'
       var iosDeviceInfo = await deviceInfo.iosInfo;
       return iosDeviceInfo.identifierForVendor; // unique ID on iOS
     } else {
       var androidDeviceInfo = await deviceInfo.androidInfo;
       return androidDeviceInfo.androidId; // unique ID on Android
     }
    }
    

    【讨论】:

    • 我想使用网络,而不是android或ios,我想在移动设备上通过浏览器打开应用程序时获取设备ID
    猜你喜欢
    • 2019-08-28
    • 1970-01-01
    • 1970-01-01
    • 2011-05-30
    • 2018-02-11
    • 1970-01-01
    • 2013-02-09
    • 1970-01-01
    相关资源
    最近更新 更多