# Get the device id

Equipment to facilitate the developer's access to the system Id, and taking into account the fact that getting the device id Is the sensitive information of the user and requires the developer to make a statement in the privacy policy of the application. Therefore, the platform will be developed in the form of an official plug-in. The developer should refer to it according to the following guidelines.

# SDK Requirement

  • Android SDK need >= 1.3.3
  • iOS SDK >= 1.2.25

# step 1, Go to project.miniapp.json Configure plugin

  • Will be required to project.miniapp.json Switch to json Pattern, and then fill in the following
"mini-plugin": {
  "ios": [
    {
      "open": true,
      "pluginId": "wx033a6b34f2c7ea15", // Plug-in id
      "pluginVersion": "1.0.0", // Plugin version number
      "isFromLocal": false
    }
  ],
  "android": [
    {
      "open": true,
      "pluginId": "wx033a6b34f2c7ea15",
      "pluginVersion": "1.0.0"
    }
  ]
}

# step 2, Go to project.miniapp.json Configure iOS Privacy Issue Information Access Permission

  • May be added project.miniapp.json Switch to visual mode, iOS. End if used. IDFA You need to configure access permissions NSUserTrackingUsageDescription, need to fill in the purpose here

# step 3, Load Plugins

  • iOS and Android The same is written, as follows:
wx.miniapp.loadNativePlugin({
  pluginId: "wx033a6b34f2c7ea15",
  success(myPlugin) {
    // Calling plug-in interface
  },
  fail(err) {
    // Startup plugin failure
  }
})

# step 4,iOS End acquisition IDFV

const IDFV = myPlugin.getIdentifierForVendor ()

# step 5,iOS End acquisition IDFA

const IDFA = myPlugin.getAdvertisingIdentifier()

# Supplement, Get IDFA System authorization is required before

  • Please refer to the following way through requestTrackingPermission Get System Authorization
myPlugin.requestTrackingPermission({}, (ret) => {
  /** 
   * ret Enumeration type of status
   * ATTrackingManagerAuthorizationStatusNotDetermined
   * ATTrackingManagerAuthorizationStatusRestricted
   * ATTrackingManagerAuthorizationStatusDenied
   * ATTrackingManagerAuthorizationStatusAuthorized
   */
  if (ret && ret.status === 'ATTrackingManagerAuthorizationStatusAuthorized') {
    const IDFV = myPlugin.getIdentifierForVendor ()
  }
})

# step 6,Android End acquisition Android Id

const ret = myPlugin.getAndroidId ({})