Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by mateiasu · Aug 12, 2013 at 01:34 PM · ios74.2xcode5ipad minidevicesettings.mm

UnityDeviceUniqueIdentifier() on iOS7

We can't deploy on iOS7 devices due the following issue:

 extern "C" const char*    UnityDeviceUniqueIdentifier()
 {
     QueryDeviceID();
     return [_DeviceID UTF8String]; <-- EXC_BAD_ACCESS (code=1,...)
 }

We already adapted the DeviceSettings.mm like mentioned in this post: 192113-Unity-4-2-Seeing-Crash-on-iOS-Device-when-using-SystemInfo-deviceUniqueIdentifier which solved the issue for < iOS7 devices:

 #if UNITY_PRE_IOS7_TARGET
     static void _InitDeviceIDPreIOS7()
     {
         static const int MD5_DIGEST_LENGTH = 16;
 
         // macaddr: courtesy of FreeBSD hackers email list
         int mib[6] = { CTL_NET, AF_ROUTE, 0, AF_LINK, NET_RT_IFLIST, 0 };
         mib[5] = ::if_nametoindex("en0");
 
         size_t len = 0;
         ::sysctl(mib, 6, NULL, &len, NULL, 0);
 
         char* buf = (char*)::malloc(len);
         ::sysctl(mib, 6, buf, &len, NULL, 0);
 
         sockaddr_dl*   sdl = (sockaddr_dl*)((if_msghdr*)buf + 1);
         unsigned char* mac = (unsigned char*)LLADDR(sdl);
 
         char macaddr_str[18]={0};
         ::sprintf(macaddr_str, "%02X:%02X:%02X:%02X:%02X:%02X", *mac, *(mac+1), *(mac+2), *(mac+3), *(mac+4), *(mac+5));
         ::free(buf);
 
         unsigned char hash_buf[MD5_DIGEST_LENGTH];
         CC_MD5(macaddr_str, sizeof(macaddr_str)-1, hash_buf);
 
         char uid_str[MD5_DIGEST_LENGTH*2 + 1] = {0};
         for(int i = 0 ; i < MD5_DIGEST_LENGTH ; ++i)
             ::sprintf(uid_str + 2*i, "%02x", hash_buf[i]);
 
         // FROM http://forum.unity3d.com/threads/192113-Unity-4-2-Seeing-Crash-on-iOS-Device-when-using-SystemInfo-deviceUniqueIdentifier
         _DeviceID = [[NSString stringWithUTF8String:uid_str] retain];
     }
 #endif

But in this case (we try to build to iOS7) this function shouldn't be called at all. We should get the VendorID instead (which works correctly if target version is set properly ;) ).

 static void QueryDeviceID()
 {
     if(_DeviceID == nil)
     {
     #if UNITY_PRE_IOS7_TARGET
         if(!_ios70orNewer)
             _InitDeviceIDPreIOS7();
     #endif
 
         // first check vendor id
         if(_DeviceID == nil)
         {
             QueryVendorID();
             _DeviceID = _VendorID;
         }
 
         // then ad id if smth went wrong
         if(_DeviceID == nil)
         {
             QueryAdID();
             _DeviceID = _ADID;
         }
     }
 }

Unfortunetly while I breakpointing the execution I see the UUID beeing received by the VendorID but in the end I still get the error. I saw _DeviceID being filled in corretly with a hash like string (I assume that's the UUID) but then its gone again?

Please help :)


Further related post:

  • 194045-Unity-4-2-SystemInfo-deviceUniqueIdentifier-regression

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image mateiasu · Aug 13, 2013 at 11:13 AM 0
Share

Thanks for setting up appropriate tags :)

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

15 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

ios 7 and xcode5 2 Answers

iOS 7 .. Xcode5 .. now have error 0 Answers

Upgraded to unity 4.2. Now all existing particle effects are ignoring 'Color Over Time' 1 Answer

Unity3D 3.5.7 - iOS 7 1 Answer

Unity Exception with ios 7 device..? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges