Skip to content

Instantly share code, notes, and snippets.

@juucustodio
Created October 31, 2018 13:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juucustodio/0f2703e15da942adc33aa5de2e36fbb3 to your computer and use it in GitHub Desktop.
Save juucustodio/0f2703e15da942adc33aa5de2e36fbb3 to your computer and use it in GitHub Desktop.
Example how your Xamarin.Forms application get the IMEI code from device - http://julianocustodio.com/imei
using System;
using Plugin.Permissions;
using Plugin.Permissions.Abstractions;
using Xamarin.Forms;
namespace DemoImei
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
private async void Button_OnClicked(object sender, EventArgs e)
{
//Verify Permission
var status = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Phone);
if (status != PermissionStatus.Granted)
{
var results = await CrossPermissions.Current.RequestPermissionsAsync(Permission.Phone);
//Best practice to always check that the key exists
if (results.ContainsKey(Permission.Phone))
status = results[Permission.Phone];
}
//Get Imei
LblImei.Text = "IMEI = " + DependencyService.Get<IServiceImei>().GetImei();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment