jamesmontemagno / deviceinfoplugin Goto Github PK
View Code? Open in Web Editor NEWDevice Information Plugin for Xamarin and Windows
License: Other
Device Information Plugin for Xamarin and Windows
License: Other
Bug Information:
Version of Plugin: 3.1.0.57-beta
Tested on: Android 6 API 23 - Samsung Galaxy 5
VS: 2017 15.5.4
Xamarin: 4.8.0.757
Xamarin Forms: 2.5.0.122203
Running CrossDeviceInfo.Current.DeviceName causes an Exception Error:
01-24 09:16:15.077 I/MonoDroid( 9139): UNHANDLED EXCEPTION:
01-24 09:16:15.137 I/MonoDroid( 9139): System.MissingMethodException: Method 'Plugin.DeviceInfo.Abstractions.IDeviceInfo.get_DeviceName' not found.
01-24 09:16:15.137 I/MonoDroid( 9139): at System.Runtime.CompilerServices.AsyncVoidMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x0002c] in <657aa8fea4454dc898a9e5f379c58734>:0
CrossDeviceInfo.Current.Version and Platform and Model work fine.
Version Number of Plugin: 3.0.1
Device Tested On: Android 5.1 Model N501
Version of VS: 2015 Update 3
Version of Xamarin: 4.7.9.45
Versions of other things you are using: Xamarin.Adroid 7.4.5.1
When the Serial Number of the Android phone is zero CrossDeviceInfo.Current.Id returns 0
Checking the code I see that if the Serial Number is Unknown then try to get the android id. I think the best behaviour would be that in case of Serial Number 0 try to get the android id too.
Case with Serial Number cero.
I used this lib for Production. And after few days running, I found out that Id is not working properly.
A lot of devices return Id as "0123456789ABCDEF", or "0123456789012345678901234567890" or empty, sure, that's not correct. Please check attached file for details.
Appreciate to hear any update from you :)
Please fill out either the bug or feature request section and remove whatever section you are not using.
Version Number of Plugin:
Device Tested On:
Simulator Tested On:
Please fill in what you would like
I have installed the plugin through NuGet (version 2.0.2) into the Core and clients projects, but I cannot use it...it says that the class 'CrossDeviceInfo' does not exist in the current context.
What can be happening?
EDITED: just resolved uninstalling - installing again
Hi there @jamesmontemagno, appreciate your work with this library, the API is very simple. :)
I am working on trying to implement this in Stripe.net. I noticed this code block:
#if PORTABLE
return null;
#else
return new DeviceInfoImplementation();
#endif
Seeing as my project has a .NET 4.5 version and a portable version that works for Xamarin, this will always return null on the portable version of the assembly. Is this expected, or am I doing something wrong? Also, is this intended to work for a regular .NET assembly as well?
Thanks much!
Version Number of Plugin: 4.0.0.5
Device Tested On: iPhone 6Plus
Simulator Tested On: Version 10.0
Version of VS: Visual Studio for Mac 7.5 (build 1254)
Version of Xamarin: Xamarin.Forms package version 2.5.0.122203
Xamarin.iOS
Version: 11.10.1.177 (Visual Studio Professional)
Added call to CrossDeviceInfo.Current.Platform in code.
No crash
Method containing this call cannot be executed on device (Works fine within simulator).
Fails with:
System.ExecutionEngineException has been thrown
Attempting to JIT compile method 'Acc.C.ThemeManager:SetCurrentTheme (string)' while running in aot-only mode. See https://developer.xamarin.com/guides/ios/advanced_topics/limitations/ for more information.
public void SetCurrentTheme(String aTheme)
{
...
if(CrossDeviceInfo.Current.Platform == Platform.iOS)
Application.Current.Resources.Add("AISeparatorVisibility", SeparatorVisibility.None);
else
Application.Current.Resources.Add("AISeparatorVisibility", SeparatorVisibility.Default);
}
After removing this block of code, everything else works as expected.
Stacktrace at:
https://gist.github.com/kiwicodemonkey/9038bd117b313fb508ec0a2a2c67cde1
This error happens with any call to any CrossDeviceInfo method.
Got version 3.1.0 of the NuGet package and tried to use it with my net standard unit tests that are running on my MacBook. Whatever you call, you will get the following Exception:
NotImplementedException: This functionality is not implemented in the portable version of this assembly. You should reference the NuGet package from your main application project in order to reference the platform-specific implementation.
Is there a way to use this package with my net standard unit tests?
I have a Macbook Pro in which I tried to create a MacOS version of my app
Every devices used are indexed by their Id which is supposed to be unique. For my Mac I got many different IDs
Ex.
5B5DDEA3-7B09-4D6B-XXXX-D42F1D84814D
FA1E24F4-DCC5-4BA0-XXXX-D8B015C52EED
98FD8A6E-8F14-4F77-XXXX-C83EEA9DFCCC
(the xxxx are used to obfuscate the IDs in any case)
Version Number of Plugin: 3.1.0.57
Device Tested On: Mac
Simulator Tested On:Real machine
Version of VS: 2017 (15.5.3)
Version of Xamarin:
Versions of other things you are
PS.
Also the Idiom gives Phone (3) and model is iPhone
If you are creating an issue for a BUG please fill out this information. If you are asking a question or requesting a feature you can delete the sections below.
Failure to fill out this information will result in this issue being closed. If you post a full stack trace in a bug it will be closed, please post it to http://gist.github.com and then post the link here.
Version Number of Plugin: 4.0.0.13
Device Tested On: Samsung G925F (Android 7.0 API 24)
Simulator Tested On:
Version of VS: 15.7.2
Version of Xamarin: 4.10.0.448
Versions of other things you are using:
Create an F# Android class library
Package it up as a NuGet package
Create an F# Android application and reference the generated NuGet package
Run the F# Android application.
The Android app should launch
On launch, the app crashes with the message
System.TypeLoadException: Could not resolve type with token 01000078 (from typeref, class/assembly Plugin.DeviceInfo.Abstractions.IDeviceInfo, Plugin.DeviceInfo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null) occurred
I am want to Unit Test some of my code that consumes DeviceInfo.
I found that if I use a Shared Project Unit Test on some methods that call into Device Info, that it throws an exeption of not having the Mono.Android runtime for some of the items, but not all of them. This is because it is being called from Unit Test Project, via the Android Project
Version 2.1.2
Returns values
CrossDeviceInfo.Current.Platform.ToString();
CrossDeviceInfo.Current.GenerateAppId().ToString();
CrossDeviceInfo.Current.VersionNumber.ToString();
Exception (Mono.Android runtime missing)
CrossDeviceInfo.Current.Model.ToString();
CrossDeviceInfo.Current.Idiom.ToString();
CrossDeviceInfo.Current.Version.ToString();
CrossDeviceInfo.Current.Id;
How are you able to Unit Test in a Shared Project using VS Unit Test Projects?
Is it possible to get screen size (height and width) in pixels through this plugin?
This bug happens after I've upgraded to the beta channel.
Version Number of Plugin: 3.0.1
Device Tested On: LGE Nexus 4 (API 22), HUAWEIVNS-L31 (API 24)
Version of VS: 7.2 preview (build 634)
Version of Xamarin:
Xamarin.Forms: 2.4.0.282
Xamarin.Android: 8.0.0.33
Simply call CrossDeviceInfo.Current.Id
Java.Lang.NoSuchMethodError: no static method "Landroid/os/Build;.getSerial()Ljava/lang/String;"
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
at Java.Interop.JniEnvironment+StaticMethods.GetStaticMethodID (Java.Interop.JniObjectReference type, System.String name, System.String signature) [0x0005b] in <1d799d87381c4db5b1252825fd105b84>:0
at Java.Interop.JniType.GetStaticMethod (System.String name, System.String signature) [0x0000c] in <1d799d87381c4db5b1252825fd105b84>:0
at Java.Interop.JniPeerMembers+JniStaticMethods.GetMethodInfo (System.String encodedMember) [0x00036] in <1d799d87381c4db5b1252825fd105b84>:0
at Java.Interop.JniPeerMembers+JniStaticMethods.InvokeObjectMethod (System.String encodedMember, Java.Interop.JniArgumentValue* parameters) [0x00000] in <1d799d87381c4db5b1252825fd105b84>:0
at Android.OS.Build.get_Serial () [0x0000a] in <c82a099136944d8aa96281cf061cbc12>:0
at Plugin.DeviceInfo.DeviceInfoImplementation.get_Id () [0x00014] in C:\projects\deviceinfoplugin\src\DeviceInfo.Plugin.Android\DeviceInfoImplementation.cs:61
Hi James
A strange problem..
A have 2 almost identical apps, where i use the plugin.
Suddenly only the one APP, throws an exception in Android (device and simulator)
System.NotImplementedException
This functionality is not implemented in the portable version of this assembly. You should reference the NuGet package from your main application project in order to reference the platform-specific implementation.
I have tried uninstalling/re-installing the plugin, ad also tried re-install all nuget packes, but nothings helps. OIS is working fine.
The plugin is installed in PCL and target projekts
This is my packages.config:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="monoandroid60" />
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="monoandroid60" />
<package id="Microsoft.Bcl.Compression" version="3.9.85" targetFramework="monoandroid60" />
<package id="Microsoft.Net.Http" version="2.2.29" targetFramework="monoandroid60" />
<package id="modernhttpclient" version="2.4.2" targetFramework="monoandroid60" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="MonoAndroid60" />
<package id="Plugin.CurrentActivity" version="1.0.1" targetFramework="monoandroid60" />
<package id="Plugin.Permissions" version="1.2.1" targetFramework="monoandroid60" />
<package id="Plugin.VersionTracking" version="1.0.1" targetFramework="monoandroid60" />
<package id="SQLite.Net.Core-PCL" version="3.1.1" targetFramework="monoandroid60" />
<package id="SQLite.Net-PCL" version="3.1.1" targetFramework="monoandroid60" />
<package id="Xam.Plugin.DeviceInfo" version="2.1.2" targetFramework="monoandroid70" />
<package id="Xam.Plugin.Geolocator" version="3.0.4" targetFramework="MonoAndroid60" />
<package id="Xam.Plugin.Media" version="2.6.2" targetFramework="monoandroid70" />
<package id="Xam.Plugins.Settings" version="2.5.4" targetFramework="monoandroid71" />
<package id="Xamarin.Android.Support.Animated.Vector.Drawable" version="23.3.0" targetFramework="MonoAndroid60" />
<package id="Xamarin.Android.Support.Design" version="23.3.0" targetFramework="MonoAndroid60" />
<package id="Xamarin.Android.Support.v4" version="23.3.0" targetFramework="MonoAndroid60" />
<package id="Xamarin.Android.Support.v7.AppCompat" version="23.3.0" targetFramework="MonoAndroid60" />
<package id="Xamarin.Android.Support.v7.CardView" version="23.3.0" targetFramework="MonoAndroid60" />
<package id="Xamarin.Android.Support.v7.MediaRouter" version="23.3.0" targetFramework="MonoAndroid60" />
<package id="Xamarin.Android.Support.v7.RecyclerView" version="23.3.0" targetFramework="MonoAndroid60" />
<package id="Xamarin.Android.Support.Vector.Drawable" version="23.3.0" targetFramework="MonoAndroid60" />
<package id="Xamarin.Azure.NotificationHubs.Android" version="0.4.0" targetFramework="monoandroid70" />
<package id="Xamarin.Forms" version="2.3.3.193" targetFramework="monoandroid71" />
<package id="Xamarin.GooglePlayServices.Base" version="29.0.0.1" targetFramework="monoandroid71" />
<package id="Xamarin.GooglePlayServices.Basement" version="29.0.0.1" targetFramework="monoandroid71" />
<package id="Xamarin.GooglePlayServices.Gcm" version="29.0.0.1" targetFramework="monoandroid71" />
<package id="Xamarin.GooglePlayServices.Measurement" version="29.0.0.1" targetFramework="monoandroid71" />
<package id="Xamarin.Insights" version="1.12.3" targetFramework="MonoAndroid60" />
<package id="ZXing.Net.Mobile" version="2.1.47" targetFramework="monoandroid60" />
<package id="ZXing.Net.Mobile.Forms" version="2.1.47" targetFramework="monoandroid60" />
</packages>
Good day Sir @jamesmontemagno,
I was using your plugin for Xamarin Forms project due to the need of getting the device info. Your plugin works perfectly for what I need. However, it enabled my android CAMERA and READ/WRITE permissions and I don't have any idea how to disable it. The client really wants to disable these permissions when installing the APK.
I already tried to explicitly add tools:remove to the camera permission in the AndroidManifest.xml file but it still keeps the permissions.
<uses-permission android:name="android.permission.CAMERA tools:node="remove">
Is there any way to disable these permissions using this plugin or any alternative solutions to do so.
Any suggestions would be very much appreciated. I wouldn't want to end up removing your plugin just because of this problem.
Best regards,
Jan
I am getting deviceId on windows (8.1 or 10) and android (min android version 4.4.2) devices and registering to database this Id for device validation. my app is installed on about 2000 real devices. I have some weird issues.
First issue is: same device could send me different deviceID
Second issue is: 2 or more device could send me same deviceId. Is this an issue or what is wrong ?
My plugin version 2.1.2. VS version is 2015 enterprise
Xamarin forms version: 2.3.3.180
Geolocator version: 4.0.0
Connectivity version: 2.3.0
Plugin.Permission version: 1.1.7
Prism version: 6.3.0-pre1
It would be cool if this plugin allowed you to grab the current devices screen size
At first glance of the README I went straight to API usage and saw the Platform enums shown as
public enum Platform
{
Android,
iOS,
WindowsPhone,
Windows
}
That isn't correct anymore. Also the Version string for WinRT works now, right? The README says it always returns "8.1", but looking at the code it seems to be properly parsing the version.
So this bug is to track updating the "Api Usage" section of README
Version Number of Plugin: 3.1.0
Device Tested On: Samsung S5 Neo
Simulator Tested On:
Version of VS: 2017 15.5.7
Version of Xamarin: 4.8.0.760
Versions of other things you are using: Xamarin Forms app with .NET Standard 2.0
Package installed
It installs on the Android and iOS project, but not in the .Net Standard 2.0 project
Install-Package Xam.Plugin.DeviceInfo -Version 3.1.0
GET https://api.nuget.org/v3/registration3-gz-semver2/xam.plugin.deviceinfo/index.json
OK https://api.nuget.org/v3/registration3-gz-semver2/xam.plugin.deviceinfo/index.json 250ms
GET https://dotnet.myget.org/F/aspnetcore-dev/Packages(Id='Xam.Plugin.DeviceInfo',Version='3.1.0')
GET http://nuget.syncfusion.com/nuget_xamarin/nuget/getsyncfusionpackages/xamarin/Packages(Id='Xam.Plugin.DeviceInfo',Version='3.1.0')
Error finding repository for 'https://www.myget.org/F/aspnetvnext/': An error occurred while retrieving package metadata for 'Xam.Plugin.DeviceInfo.3.1.0' from source 'AspnetVnext'.
A task was canceled.
Error finding repository for 'http://nuget.syncfusion.com/nuget_xamarin/nuget/getsyncfusionpackages/xamarin': An error occurred while retrieving package metadata for 'Xam.Plugin.DeviceInfo.3.1.0' from source 'Syncfusion_Xamarin'.
A task was canceled.
Restoring packages for R:\VeloGuide\VeloGuideApp\VeloGuideApp\VeloGuideApp\VeloGuideApp.csproj...
Installing NuGet package Xam.Plugin.DeviceInfo 3.1.0.
Committing restore...
Writing lock file to disk. Path: R:\VeloGuide\VeloGuideApp\VeloGuideApp\VeloGuideApp\obj\project.assets.json
Restore completed in 258.04 ms for R:\VeloGuide\VeloGuideApp\VeloGuideApp\VeloGuideApp\VeloGuideApp.csproj.
Committing restore...
Assets file has not changed. Skipping assets file writing. Path: R:\VeloGuide\VeloGuideApp\VeloGuideApp\VeloGuideApp.iOS\obj\project.assets.json
Restore completed in 23.87 ms for R:\VeloGuide\VeloGuideApp\VeloGuideApp\VeloGuideApp.iOS\VeloGuideApp.iOS.csproj.
Committing restore...
Assets file has not changed. Skipping assets file writing. Path: R:\VeloGuide\VeloGuideApp\VeloGuideApp\VeloGuideApp.Android\obj\project.assets.json
Restore completed in 35.46 ms for R:\VeloGuide\VeloGuideApp\VeloGuideApp\VeloGuideApp.Android\VeloGuideApp.Android.csproj.NuGet Config files used:
C:\Users\stesv\AppData\Roaming\NuGet\NuGet.Config
C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config
C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.Fallback.configFeeds used:
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages
http://nuget.syncfusion.com/nuget_xamarin/nuget/getsyncfusionpackages/xamarin
https://api.nuget.org/v3/index.json
https://www.myget.org/F/aspnetvnext/
Executing nuget actions took 171.52 ms
Time Elapsed: 00:00:01.8669523
var appVersion = CrossDeviceInfo.Current.AppVersion;
I'm trying to build master but can't.
I have tried on:
Visual Studio for Mac (7.4.3 build 10)
Visual Studio on Windows (15.7 with Xamarin/UWP workloads)
.NET Core CLI (2.1.101)
MSBuild on macOS (15.4.0.0 (xplat-master/67e8006d Thu Mar 8 17:15:24 EST 2018) for Mono)
VS for mac fails with:
/Users/bruno/git/DeviceInfoPlugin/src/DeviceInfo.Plugin/DeviceInfo.Plugin.csproj: Error NU1202: Package Plugin.CurrentActivity 2.0.0.6-beta is not compatible with netstandard1.0 (.NETStandard,Version=v1.0). Package Plugin.CurrentActivity 2.0.0.6-beta supports: monoandroid44 (MonoAndroid,Version=v4.4) (NU1202) (DeviceInfo.Plugin) ...
On Windows it's a MSBuild issue:
Severity | Code | Description | Project | File | Line | Suppression State |
---|---|---|---|---|---|---|
Error | MSB4057 | The target "Clean" does not exist in the project. | DeviceInfo.Plugin | C:\Users\bruno\git\DeviceInfoPlugin\src\DeviceInfo.Plugin\DeviceInfo.Plugin.csproj | 1 |
CLI:
/usr/local/share/dotnet/sdk/2.1.101/Sdks/Microsoft.NET.Sdk/Sdk/Sdk.targets(41,3): error MSB4019: The imported project "/usr/local/share/dotnet/sdk/2.1.101/15.0/Bin/Microsoft.CSharp.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. [/Users/bruno/git/DeviceInfoPlugin/src/DeviceInfo.Plugin/DeviceInfo.Plugin.csproj] /Users/bruno/git/DeviceInfoPlugin/src/DeviceInfo.Plugin/DeviceInfo.Plugin.csproj : error MSB4057: The target "Build" does not exist in the project. /Users/bruno/git/DeviceInfoPlugin/src/DeviceInfo.Plugin/DeviceInfo.Plugin.csproj : error MSB4057: The target "Build" does not exist in the project. /Users/bruno/git/DeviceInfoPlugin/src/DeviceInfo.Plugin/DeviceInfo.Plugin.csproj : error MSB4057: The target "Build" does not exist in the project. /Users/bruno/git/DeviceInfoPlugin/src/DeviceInfo.Plugin/DeviceInfo.Plugin.csproj : error MSB4057: The target "Build" does not exist in the project. /Users/bruno/git/DeviceInfoPlugin/src/DeviceInfo.Plugin/DeviceInfo.Plugin.csproj : error MSB4057: The target "Build" does not exist in the project. /Users/bruno/git/DeviceInfoPlugin/src/DeviceInfo.Plugin/DeviceInfo.Plugin.csproj : error MSB4057: The target "Build" does not exist in the project. 0 Warning(s) 7 Error(s)
MSBuild failed like VS for Mac as expected:
/Users/bruno/git/DeviceInfoPlugin/src/DeviceInfo.Plugin/DeviceInfo.Plugin.csproj : error NU1202: Package System.Threading.Timer 4.0.1 is not compatible with netstandard1.0 (.NETStandard,Version=v1.0). Package System.Threading.Timer 4.0.1 supports: /Users/bruno/git/DeviceInfoPlugin/src/DeviceInfo.Plugin/DeviceInfo.Plugin.csproj : error NU1202: - monoandroid10 (MonoAndroid,Version=v1.0) /Users/bruno/git/DeviceInfoPlugin/src/DeviceInfo.Plugin/DeviceInfo.Plugin.csproj : error NU1202: - monotouch10 (MonoTouch,Version=v1.0) /Users/bruno/git/DeviceInfoPlugin/src/DeviceInfo.Plugin/DeviceInfo.Plugin.csproj : error NU1202: - net451 (.NETFramework,Version=v4.5.1) /Users/bruno/git/DeviceInfoPlugin/src/DeviceInfo.Plugin/DeviceInfo.Plugin.csproj : error NU1202: - netcore50 (.NETCore,Version=v5.0) /Users/bruno/git/DeviceInfoPlugin/src/DeviceInfo.Plugin/DeviceInfo.Plugin.csproj : error NU1202: - netstandard1.2 (.NETStandard,Version=v1.2) /Users/bruno/git/DeviceInfoPlugin/src/DeviceInfo.Plugin/DeviceInfo.Plugin.csproj : error NU1202: - portable-net451+win81+wpa81 (.NETPortable,Version=v0.0,Profile=Profile151) /Users/bruno/git/DeviceInfoPlugin/src/DeviceInfo.Plugin/DeviceInfo.Plugin.csproj : error NU1202: - win81 (Windows,Version=v8.1) /Users/bruno/git/DeviceInfoPlugin/src/DeviceInfo.Plugin/DeviceInfo.Plugin.csproj : error NU1202: - wpa81 (WindowsPhoneApp,Version=v8.1) /Users/bruno/git/DeviceInfoPlugin/src/DeviceInfo.Plugin/DeviceInfo.Plugin.csproj : error NU1202: - xamarinios10 (Xamarin.iOS,Version=v1.0) /Users/bruno/git/DeviceInfoPlugin/src/DeviceInfo.Plugin/DeviceInfo.Plugin.csproj : error NU1202: - xamarinmac20 (Xamarin.Mac,Version=v2.0) /Users/bruno/git/DeviceInfoPlugin/src/DeviceInfo.Plugin/DeviceInfo.Plugin.csproj : error NU1202: - xamarintvos10 (Xamarin.TVOS,Version=v1.0) /Users/bruno/git/DeviceInfoPlugin/src/DeviceInfo.Plugin/DeviceInfo.Plugin.csproj : error NU1202: - xamarinwatchos10 (Xamarin.WatchOS,Version=v1.0)
Do I need to install anything else to get it to build?
The Permissions Plugin dependency is redundant.
I can't find any use of it, except for the sample project.
Can you please remove this dependency from the plugin.
Is it possible to get the bundle id of the app?
Some way to get the Bundle Id (iOS) or Package Name (Android).
A property to distinguish a physical device from an simulator or emulator would be nice. This would add a simple way to enable some debugging features in dev environments.
Additions to the IDeviceInfo
interface:
bool IsDevice { get; }
Additions to the iOS implementation:
public bool IsDevice => Runtime.Arch == Arch.DEVICE;
Additions to the Android implementation (detection is not as simple as on iOS - shamelessly taken from https://stackoverflow.com/a/13635166):
public bool IsDevice => !(
Build.Fingerprint.StartsWith("generic", StringComparison.InvariantCulture)
|| Build.Fingerprint.StartsWith("unknown", StringComparison.InvariantCulture)
|| Build.Model.Contains("google_sdk")
|| Build.Model.Contains("Emulator")
|| Build.Model.Contains("Android SDK built for x86")
|| Build.Manufacturer.Contains("Genymotion")
|| (Build.Brand.StartsWith("generic", StringComparison.InvariantCulture) && Build.Device.StartsWith("generic", StringComparison.InvariantCulture))
|| Build.Product.Equals("google_sdk", StringComparison.InvariantCulture)
);
I have no knowledge about the other platforms.
What do you think?
I'm not sure whether it's a bug or a feature request because I don't know the definition of the DeviceID. Summary says "This is the device specific Id".
It seems that this device ID is recalculated (at least on iOS) whenever I uninstall and install the same app again (also reported in #13 where the link in the last comment does not work anymore ) and it also recalculates if the OS is updated (seen by updating from iOS 10.2.1 to iOS 10.3.1). Is this correct? And if so, is it a bug or the expected behaviour?
I thought the ID would give a unique ID for a unique device, regardless of updates of my App, re-installation of my app, update of OS etc. Obviously that's not the case, at least for iOS.
Is there a way with current plugin to get such unique ID? If not, is there any other way for Xamarin Forms?
Many thanks!
Could/Should AppVersionNumber
include the Build number? I use this to explicitly see build versions when building through Mobile Center. Currently I have a simple DependencyService
which does the following. Would love to be able to eliminate and just use AppVersionNumber
.
iOS CFBundleVersion
:
NSBundle.MainBundle.ObjectForInfoDictionary("CFBundleShortVersionString").ToString() + "." + NSBundle.MainBundle.ObjectForInfoDictionary("CFBundleVersion");
Android VersionCode
:
var context = Android.App.Application.Context;
var pInfo = context.PackageManager.GetPackageInfo(context.PackageName, 0);
return pInfo.VersionName + "." + pInfo.VersionCode;
UWP Build
:
PackageVersion version = Package.Current.Id.Version;
return $"{version.Major}.{version.Minor}.{version.Build}";
Copied from: jamesmontemagno/Xamarin.Plugins#328
Version Number of Plugin:2.0.2
Device Tested On:Windows 10 Visual Studio 2015
Simulator Tested On:Windows Phone 10 emulator by Visual studio 2015
return: 10.0.586
return : 2814750460870974
return CrossDeviceInfo.Current.Version
In some circumstances, it returns "unknown" for device id. It is a real Android device. Plugin still be able to get the Model (M708S) and Version (4.2.2)
Version Number of Plugin: 1.0.0.2
Device Tested On: M708S (Model)
Simulator Tested On:
Return with a unique device ID
Return "unknown"
If you are creating an issue for a BUG please fill out this information. If you are asking a question or requesting a feature you can delete the sections below.
Failure to fill out this information will result in this issue being closed. If you post a full stack trace in a bug it will be closed, please post it to http://gist.github.com and then post the link here.
Version Number of Plugin:2.1.2
Device Tested On: Windows PC
Simulator Tested On:
Version of VS: 2015 update 3
Version of Xamarin:4.4.0.34
Versions of other things you are using: Dot net framework 4.2.6
Can you add getting IMEI or list of IMEIs(in case of dual-sim devices) to your features?
Thanks.
Please fill out either the bug or feature request section and remove whatever section you are not using.
Version Number of Plugin: 2.0.2
Device Tested On: iPhone 6s
Simulator Tested On: NA
Globally unique but same at device level, id every time the app runs [Irrespective of uninstall and install several times]
Every time the SAME app is uninstalled and installed, returned id is different. So can not use it like UDID.
Please fill in what you would like
It seems its the implementation but I would really like to use id as UDID. Any other way to get that on iOS?
BTW for android its unique per device but same for different apps so it can be used as UDID.
I just installed this plugin to get the device name but the property doesn't appear. I thought it's supposed to appear when I enter CrossDeviceInfo.Current.DeviceName but the only properties I see are
Where can I find the DeviceName property?
I am using version 3.0.2
I've just looked into the source code here on Github and the interface has the property DeviceName.
Hi James
I use a number of your Plugins, which are all great and easy to use.
I need to be able to detect iPhoneX in my app and I don’t want to use the device screen size to determine the hardware type due to the potential issues for future maintenance.
I have found a post by Bag Labs that includes a solution using XLabs, which I don’t use.
Just a thought that a useful extension to your DeviceInfo Plugin would be to return the Hardware name.
Thanks
John
Copied from: jamesmontemagno/Xamarin.Plugins#273
Version Number of Plugin: 2.0.2
Device Tested On:
Simulator Tested On: Emulator 8.1 WVGA 512 Mb
get the generated GUID
Sometimes the system returned to me :
Unable to cast object of type 'System.__ComObject' to type 'Windows.System.Profile.IHardwareIdentificationStatics'
With this StackTrace :
at System.StubHelpers.StubHelpers.GetCOMIPFromRCW_WinRT(Object objSrc, IntPtr pCPCMD, IntPtr& ppTarget)
at Windows.System.Profile.HardwareIdentification.GetPackageSpecificToken(IBuffer nonce)
at Plugin.DeviceInfo.DeviceInfoImplementation.get_Id()
I ask for the CrossDeviceInfo.Current.Id at multiple times in the OnLaunched method of App.xaml.cs
(i resolved by stocked the id the first time now but i get this back to you if it can help you to improve this awesome plugin ^^)
If you are creating an issue for a BUG please fill out this information. If you are asking a question or requesting a feature you can delete the sections below.
Failure to fill out this information will result in this issue being closed. If you post a full stack trace in a bug it will be closed, please post it to http://gist.github.com and then post the link here.
Version Number of Plugin: 3.1.0.0
Device Tested On: Samsung Galaxy
Simulator Tested On: 10 devices on google play logcat
Version of VS: VS 2017
Version of Xamarin: 2.5
Versions of other things you are using:
this is all I have to do and it crashes on device
var di = GetDeviceInfo;
var deviceName = di.DeviceName;
this error is thrown
System.MissingMethodException: string Plugin.DeviceInfo.Abstractions.IDeviceInfo.get_DeviceName()
get the device Name
System.MissingMethodException: string Plugin.DeviceInfo.Abstractions.IDeviceInfo.get_DeviceName()
var di = GetDeviceInfo;
var deviceName = di.DeviceName;
Hi,
is that the IMIE of a device?
thanks,
Eric
Hello. Thank you for your plugins!
I had added Xam.Plugin.DeviceInfo to PCL, Android and iOS projects (I don't use UWP in solution).
When I try to get CrossDeviceInfo.Current.Id I have this exception in my Xamarin PCL Project:
This functionality is not implemented in the portable version of this assembly. You should reference the NuGet package from your main application project in order to reference the platform-specific implementation.
Version Number of Plugin: 3.0.2
Device Tested On: Samsung Galaxy A5 2017
Simulator Tested On: -
Version of VS: 2017
Version of Xamarin: 2.5.0.121934
Versions of other things you are using:
So, what do we want the ID to actually be? I described what they currently do in #22
Do we want other properties to be added as well for IDs?
I am looking at this: https://developer.android.com/reference/android/os/Build.html
Not sure how much is supported in iOS and Windows though
Im receiving errors installing your plugin on macOS. Perhaps it could be caused by recent changes to the Xamarin mac runtime.
Version Number of Plugin: 2.1.2
Device Tested On: mac x86 running Sierra 10.12.4 OS
Plugin installs
Receive error.
Could not install package 'Xam.Plugin.DeviceInfo 2.1.2'. You are trying to install this package into a project that targets 'Xamarin.Mac,Version=v2.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
Install Visual Studio 7.0
Attempt to add DeviceInfo to macOS target
Version Number of Plugin: 3.0.2
Device Tested On: Sansung Galaxy S7 Edge
Simulator Tested On: VS Emulator 5.7-inch Marshmallow (6.0.0) XHDPI Phone
Version of VS: 15.4.2
Version of Xamarin: 2.5.0.77107
Versions of other things you are using: Prism.Ninject 7.0.0.168 pre
In the App. xaml. cs class or any other:
var deviceInfo = CrossDeviceInfo. Current;
ToString ();
Get device language
NullReferenceExpection
var deviceInfo = CrossDeviceInfo.Current; device.Idiom = device.Idiom.ToString(); device.VersionNumber = deviceInfo.VersionNumber.ToString(); device.Model = deviceInfo.Model; device.Plataform = deviceInfo.Platform.ToString(); device.Version = deviceInfo.Version.ToString(); device.SerialNumber = deviceInfo.Id.ToString();
It would be great to have on your plugin detail about iphone model.
CrossDeviceInfo.Current.Model just returns "iPhone"
I've tested method GetVersion() on the link below.
It works fine giving informations such as : iPhone5S,iPod6G, etc...
It just needs to be updated to inform newer models
https://github.com/rangav/iOSDeviceModel/blob/master/DeviceHelper.cs
Please fill out either the bug or feature request section and remove whatever section you are not using.
Version Number of Plugin: 2.1.0.2-beta
Device Tested On: iPhone6
Simulator Tested On: -
Would expect if I call CrossDeviceInfo.Current.Model
I would get
iPhone6
If I call CrossDeviceInfo.Current.Model
I get just
iPhone
Thanks a lot for your great work!
Copied from: jamesmontemagno/Xamarin.Plugins#176
Can you enhance this plugin to detect and return OSX as a platform? Also, another good piece of device information would be the processor architecture, i.e. X86, x64, Ia64, ARM, etc. Thanks.
Using a PCL in Xamarin.Forms, DeviceInfo Nuget was added to all three platforms.
In my Pcl class I add "using DeviceInfo.Plugin " and it doesn't exist, however,
it corrects me into adding "Plugins.DeviceInfo" but there is not a .Plugins Property after that, only a .Abstractions?
What am I doing wrong?
Hi all,
a question regarding #24: As seen in #21, there are several Android devices which return dummy serial numbers, like "0123456789ABCDEF". As @jamesmontemagno describes there, he first checks for the serial, and if not returned, the Android_Id is checked. According to the linked Android Developer docs, Android_Id seems to be much more reliable (as it's created by Android itself) than the serial number (which is no surprise because the serial number is not reliable at all as there are many devices with dummy numbers).
In https://github.com/jamesmontemagno/DeviceInfoPlugin/blob/master/src/DeviceInfo.Plugin.Android/DeviceInfoImplementation.cs, I've removed lines 106-108 and 118 so I always use the Android_Id. This works fine on the emulator, and on my Wiko Lenny 3 with serial number "0123456789abcdef" ... I now get a (hopefully) unique string back (like "4e6e....").
So why is the serial number in Android used first? Maybe because the problems of the dummy serial numbers did not exist years ago, or are there any other reasons (security or else) why the Android_Id is not used in first place?
Many thanks!
P.S. So Android does have an ID (Android_Id) which is kept until user does a factory reset. Something similar for Apple still does not exist, so DeviceID is a new one on each uninstall and new installation of the app, right?
Is it possible to get the Device Name using this plugin, if not could this be added easily, this would really be helpful
On an windows uwp application, CrossDeviceInfo.Current.Id generates different ids depending if wifi is turned on or off. Is this a wanted behavior?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.