xamarin .forms 手机的一些信息获取Device Info Plugin

来源:互联网 发布:淘宝基础版店铺装修 编辑:程序博客网 时间:2024/06/03 14:26

API的使用

调用 CrossDeviceInfo.Current 从任何项目或PCL访问api。

GenerateAppId 用于为应用程序生成一个惟一的Id。

/// <summary>/// Generates a an AppId optionally using the PhoneId a prefix and a suffix and a Guid to ensure uniqueness/// /// The AppId format is as follows {prefix}guid{phoneid}{suffix}, where parts in {} are optional./// </summary>/// <param name="usingPhoneId">Setting this to true adds the device specific id to the AppId (remember to give the app the correct permissions)</param>/// <param name="prefix">Sets the prefix of the AppId</param>/// <param name="suffix">Sets the suffix of the AppId</param>/// <returns></returns>string GenerateAppId(bool usingPhoneId = false, string prefix = null, string suffix = null);

ID

/// <summary>/// This is the device specific Id (remember the correct permissions in your app to use this)/// </summary>string Id { get; }

重要的是:

Windows Phone: 权限添加: ID_CAP_IDENTITY_DEVICE

设备模型

/// <summary>/// Get the model of the device/// </summary>string Model { get; }

版本

/// <summary>/// Get the version of the Operating System/// </summary>string Version { get; }

返回特定的操作系统版本号的如:

  • iOS:8.1
  • Android:4.4.4
  • Windows Phone:8.10.14219.0
  • WinRT:总是8.1,直到有一个工作

平台

/// <summary>/// Get the platform of the device/// </summary>Platform Platform { get; }

返回平台枚举:

public enum Platform{  Android,  iOS,  WindowsPhone,  Windows}



dll下载地址

http://components.xamarin.com/view/DeviceInfoPlugin

  1. 另外推荐168vpn,很多开发更新时候必备,交流qq470138890


0 0
原创粉丝点击