Is there any unique device ID (UDID) or any similar ID I can read out on Windows Phone 8 (WP8) that doesn't change with hardware changes, app-reinstallation etc.?
In older Windows Phone versions there were such IDs:
WP7: Device Status for Windows Phone
WP7.1: DeviceStatus Class
But they doesn't work anymore with SDK 8.0.
Why I ask:
The idea is that a user gets some free credits with the first start of the the app and I want to avoid that the user just re-installs the app for getting new free credits. A registration with email or phone number could solve this, but if I can, I don't want do bother users at the first start with a registration.
---///---SOLUTION----------
I can confirm that DeviceExtendedProperties.GetValue("DeviceUniqueId") still works in WP 8.0. Got a little bit confused when I read the following text:
In Windows Phone OS 7.0, this class was used to query device-specific
properties. In Windows Phone OS 7.1, most of the properties in
DeviceExtendedProperties were deprecated, and the new DeviceStatus
class should be used instead. However, where appropriate, you can
still use any of the below properties that are not deprecated.
MSDN:DeviceExtendedProperties Class
I can run the following code, delete the app and re-install it and get the same ID:
byte[] myDeviceID = (byte[])Microsoft.Phone.Info.DeviceExtendedProperties.GetValue("DeviceUniqueId");
string DeviceIDAsString = Convert.ToBase64String(myDeviceID);
MessageBox.Show(DeviceIDAsString);
I haven't yet started to develop for Windows Phone 8, still on 7, but you still should be able to use the original DeviceExtendedProperties class to pull back the Device Unique ID.
DeviceExtendedProperties.GetValue("DeviceUniqueId")
I've had this issue with returning the null value. Then remembered that it needs to be switched on.
In WMAppManifest.xml -> Capabilities tab -> switch on ID_CAP_IDENTITY_DEVICE
There's a twist to this DeviceUniqueId - it is unique only for one publisher. So it is not really device-wide unique identifier but unique device id for one publisher. We have noticed when we worked on some customer project where we tried to identify the same phone from different accounts (customer publishes under two different accounts).
You can get your own wp8 device Id by DeviceExtendedProperties.GetValue("DeviceUniqueId")
Here is the simple way to get deviceId as a string
byte[] id = (byte[])Microsoft.Phone.Info.DeviceExtendedProperties.GetValue("DeviceUniqueId");
string deviceID = Convert.ToBase64String(id);
By not providing DeviceUniqueId in Windows Phone 8 and Windows 8, Microsoft tried to avoid User Tracking but with increased pressure from Dev community, they are bringing it back again.
In Windows 8.1, Microsoft has introduced a new AdvertisingId API and may also bring similar Id to identify a unique user across apps in subsequent Windows Phone 8.1/9 versions.
I used this:
private static String getDeviceId()
{
byte[] id = (byte[])Microsoft.Phone.Info.DeviceExtendedProperties.GetValue("DeviceUniqueId");
return BitConverter.ToString(id).Replace("-", string.Empty);
}
But the key is to Check the ID_CAP_IDENTITY_DEVICE in WMAppManifest, or else it throws error.
I found this a new HostInformation.PublisherHostId property
More info at
http://msdn.microsoft.com/en-us/library/windowsphone/develop/windows.phone.system.analytics.hostinformation.publisherhostid.aspx..
string myDeviceID = (byte[])DeviceExtendedProperties.GetValue("DeviceUniqueId");
string DeviceIDAsString = Convert.ToBase64String(myDeviceID);
I have used this for windows phone unique device Id.
The answers above work for Windows Phone 7 and 8 Silverlight. However, they will not work for Windows Phone RT (Universal) or Store Apps since the SDK does not have this dll library (Microsoft.Phone).
This is how you get the device ID and Name (and possibly other info) on Windows Phone 8.1 RT (Universal/Store Apps).
private string GetHardwareId()
{
var token = HardwareIdentification.GetPackageSpecificToken(null);
var hardwareId = token.Id;
var dataReader = Windows.Storage.Streams.DataReader.FromBuffer(hardwareId);
byte[] bytes = new byte[hardwareId.Length];
dataReader.ReadBytes(bytes);
return BitConverter.ToString(bytes);
}
More details about reading the device info on Windows RT can be found here
Related
To launch another specific app we can set the other app's package family name:
var options = new LauncherOptions();
options.TargetApplicationPackageFamilyName = packageFamilyName;
Uri uri = new Uri(protocol);
var succeeded = await Windows.System.Launcher.LaunchUriAsync(uri, options);
If the other app wasn't installed, Store download page opens. But this happens only on Windows 10 desktop, on the phone nothing happens, it just fails.
However if we remove options parameter it searches for any app on Store.
await Windows.System.Launcher.LaunchUriAsync(uri);
Is there anyway to have Desktop behavior on Mobile too? I mean open exactly a specific app not any app that registered for that protocol
The documentation states this is for Desktop only at this point in time. Potentially the feature will make it to Mobile (and other Windows flavours) in the future.
I'm writing Universal app (WinStore 8.1 + WinPhone 8.1). For my requirements I need to retrieve all device contacts. It's OK on WinPhone - here is code how I do that:
var contactStore = await ContactManager.RequestStoreAsync();
var contacts = await contactStore.FindContactsAsync();
But how to do that in WinStore app?
It is not possible by design I am afraid.
Tt's not possible to get the information from the people app. It works within calendar, mail or messenger because they're all technically contained within the same app and are able to use each other's data and violate normal rules.
You can always use the ContactPicker.
This might help.
I am using Windows 8.1 and Visual Studio 2013. As far as I know, everything is update to date. So what I wanted is to fetch contact list, but I am not able to the that even after googling.
According to MSDN, all I have to do is put using Microsoft.Phone.UserData and after that I can happily get contacts. The problem is, I can't, because there is an error which says that Microsoft.Phone.* doesn't exist.
Am I missing something or what. According to site above, it applies to Windows Phone 8 and Windows Phone Silverlight 8.1 | Windows Phone OS 7.1.
P.S. It's about blank app (Windows Phone) project
You are looking at the tutorial for Windows Phone 8 as against the fact that most probably you are using WinRT for Windows phone 8.1
You need to use the ContactStore class by using the ContactManager class.
Here is a code snippet from MSDN
public async void FindContacts(string searchText)
{
ContactStore contactStore = await ContactManager.RequestStoreAsync();
IReadOnlyList<Contact> contacts = null;
if(String.IsNullOrEmpty(searchText))
{
// Find all contacts
contacts = await contactStore.FindContactsAsync();
}
else
{
// Find contacts based on a search string
contacts = await contactStore.FindContactsAsync(searchText);
}
MyContactListBox.ItemsSource = contacts;
}
In case you want to target older versions of windows phone you might want to read this
In case there is a confusion in regards to what version of SDK do I use for targeting a specific version of windows phone , here is the help.
I have had the same issue, think it might be because if I look for the Microsoft.Phone class, I find it in a 8.0 directory. In my case
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\WindowsPhone\v8.0\
I then just referenced it by browsing for the file. I'm not sure what you're intending to use it for, and if the classes will be compatible with 8.1. But I hope this helps.
Recently I was thinking of a way to confirm the user info inside an app.
Is the typed email, the windows phone live-id of the device?
Is the typed number, the windows phone card-number of the device?
All I know until now is that I can get some info from windows phone SDK.
For DeviceId (hash) I use DeviceEctendedProperties, based on device serial i suppose
For UserId (hash) I use UserExtendedProperties, based on user live id i suppose
And with that we can identify a user and a device.
To get the right info from user like email and phone number you must ask him.
So the question: Is there any way to validate the user entry?
For example:
App -> Form - > form_info(email, phone) -> Validate(form_info) -> Success OR Unsuccess
For Validate() i was thinking of something like:
form_info -> function_hasher() -> form_info_hash -> IF form_info_hash MATCHES with UserId (hash) and UserPhone (hash)
If there is a UserPhone hash to match the number of card!
I'm pretty sure there's no way to get this data or even verify that it's right, short of asking the user to email/SMS a particular address/phone number. If you want to go that route you can use a SmsComposeTask or an EmailComposeTask.
I have a C# application which is expected to run in both WIn 7 & Win XP. I need to check the OS NAME in my C# source code before distributing the MSI & EXE to customers.
Without getting into finer versioning
details my code wants to check if it
is a 32 bit WINDOWS XP or a 64-bit
WINDOWS 7.
Can I kindly get help regarding this.
OS under consideration is 64-bit Win7 & 32-bit Win XP.
You could get the Operating System 's friendly name by using WMI.
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT Caption FROM Win32_OperatingSystem");
String operatingSystem = String.Empty;
foreach (ManagementObject query in searcher.Get())
{
operatingSystem = query["Caption"].ToString();
break;
}
You could use WMI Code Creator, a great tool from Microsoft to generate WMI queries.
You should be able to get all the information you need from the Environment class, specifically, the OSVersion and Is64BitOperatingSystem properties.
Yes all give you right direction Environment.OSVersion gives you OS version, but how to know if its windows XP or 7
You need to compare for versions, here is concerned list
Windows XP 5.1.2600 Current SP3
Windows XP Professional x64 Edition 5.2.3790
Windows Vista 6.0.6000 Current Version changed to 6.0.6002 with SP2
Windows 7 6.1.7600
More Windows OS Version Numbers
if (Environment.OSVersion.Version.ToString().Equals("5.1.2600"))
{
// windows xp 32-Bit with service pack 3
}
else if (Environment.OSVersion.Version.ToString().Equals(" 6.1.7600"))
{
// windows 7
}
Have a look on the System.Environment.OSVersion property. It is of type OperatingSystem which should contain all relevant information.
You should check out Environment.OSVersion and Environment.Is64BitOperatingSystem.
Though you'll need to manually map the returned information to an appropriate string.
Take a look at the Environment class. It contains methods for what you need.
Short Answer:
Console.WriteLine("OSVersion: {0}", Environment.OSVersion.ToString());
You can get the OS Name from registry.
string productName = Registry.GetValue(#"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ProductName", "").ToString();
Console.WriteLine(productName);
Output:
//For my windows 10 i got
Windows 10 Enterprise
Try this for getting the Windows product name