/*
iOS app development process, sometimes for bug tracking or to obtain the need for feedback to automatically collect user devices, System information, application information, etc., this information to facilitate the developer to diagnose the problem, of course, this information is the user's non-private information, through the development API can be obtained. With those APIs you can get this information, Uidevice,nsbundle,nslocale is available in the iOS SDK.
Uidevice
Uidevice provides a variety of properties, class functions, and status notifications to help us understand the state of the device in all directions. From detecting battery power to locating devices and proximity sensing, Uidevice's job is to provide users and devices with some information about the application. The Uidevice class is also capable of collecting specific details about the device, such as the model and iOS version. Most of these properties have a positive effect on development efforts. The following code simply uses Uidevice to get the phone properties.
*/
Get Mobile Info
NSString *strname = [[Uidevice currentdevice] name];
NSLog (@ "Device name:%@", strName);
/*
NSString *strid = [[Uidevice currentdevice] uniqueidentifier];
NSLog (@ "Device unique ID:%@", Strid),//uuid,5.0 not available
*/
Get device-related information
NSString *strsysname = [[Uidevice currentdevice] systemName];
NSLog (@ "system name:%@", strsysname);
NSString *strsysversion = [[Uidevice currentdevice]systemversion];
NSLog (@ "System version number:%@", strsysversion);
NSString *strmodel = [[Uidevice currentdevice] model];
NSLog (@ "Device mode:%@", Strmodel);
NSString *strlocmodel = [[Uidevice currentdevice] Localizedmodel];
NSLog (@ "Local device mode:%@", Strlocmodel);
/*
A bundle is a directory that contains the resources that the program will use. These resources include like, sound, compiled code, NIB files (the user will also refer to bundles as plug-in). The corresponding BUNDLE,COCOA provides class NSBundle. An application looks no different from other files. But it's actually a directory that contains nib files, compiled code, and other resources. We call this directory the program's main bundle. This path allows you to get information about your app, such as the app name, version number, and so on.
*/
Nsdictionary *dict = [[NSBundle mainbundle]infodictionary];
NSString *strappname = [dict objectforkey:@ "Cfbundledisplayname"];
NSLog (@ "app app Name:%@", strappname);
NSString *strappversion = [dict objectforkey:@ "cfbundleshortversionstring"];
NSLog (@ "app version:%@", strappversion);
NSString *strappbuild = [dict objectforkey:@ "cfbundleversion"];
NSLog (@ "app build version:%@", strappbuild);
/*
Nslocale
Nslocale can obtain the user's localization information settings, such as currency type, country, language, number, format of date format, provide correct geographical location display and so on. The following code gets the machine's current language and country code.
*/
Getting the User ' s Language
Nsarray *languagearray = [Nslocale preferredlanguages];
NSString *language = [Languagearray objectatindex:0];
NSLog (@ "Language:%@", language);
Nslocale *locale = [Nslocale Currentlocale];
NSString *country = [locale localeidentifier];
NSLog (@ "Country:%@", country); en_US
PS: Our macro definition is essentially the same
Ns_inline nsstring* UDID () {
#if Kusetestudid
return ktestudid;
#else
return [[Uidevice Currentdevice] serialnumber];
#endif
}
Ns_inline NSString * DeviceType () {
return [[Uidevice Currentdevice] model];
}
Ns_inline NSString * Deviceos () {
return [[Uidevice Currentdevice] systemName];
}
Ns_inline NSString * Deviceosversion () {
return [[Uidevice Currentdevice] systemversion];
}