Is there any way to fetch the unique device id in .NET MAUI 8?

Satya 160 Reputation points
2025-01-28T05:29:51.3566667+00:00

Is there any way to fetch the unique device id in .NET MAUI 8?

If yes, Will the unique device id changes when user factory resets the phone?

Will Play store and App store allows this fetching unique device id and storing it in secure storage?

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,927 questions
0 comments No comments
{count} votes

Accepted answer
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 48,421 Reputation points Microsoft Vendor
    2025-01-29T00:48:17.3+00:00

    Hello,

    For developers, the unique device ID we can obtain will be reset after restoring the factory settings. This is because for privacy reasons, Apple and Google do not want developers to track the behavior of a specific device for a long time from a system level.

    For how to obtain these unique device identifiers, you can refer to the following code.

    #if ANDROID
    
    string deviceID = Android.Provider.Settings.Secure.GetString(Platform.CurrentActivity.ContentResolver, Android.Provider.Settings.Secure.AndroidId);
     
    #elif IOS
                string deviceID = UIKit.UIDevice.CurrentDevice.IdentifierForVendor.ToString();
    #endif
    

    Best Regards,

    Alec Liu.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


1 additional answer

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.