microsoft / WinObjC

Objective-C for Windows
MIT License
6.24k stars 808 forks source link

[BREAKING CHANGE] UIDevice identifierForVendor is based on family name and pretends it is a GUID #1440

Closed jboich closed 7 years ago

jboich commented 7 years ago

Hi. After associating our app with the Store [[UIDevice currentDevice] identifierForVendor] returns nil.

I have looked into the - (id)initWithUUIDString:(NSString*)string method of NSUUID class and there is a check for a specific string format.

Before associating app with the Store, package family name looked similar to the one in woccatalog app '7e95fefb-0094-4d3f-8327-10b2fb12fdbf_tk6g8mba0d0k4' and everything was fine, but Store changed app identity details and now Package Family Name looks like "CompanyName.NameOfTheApp_tk6g8mba0d0k4" and I think because it does not match string pattern in - (id)initWithUUIDString:(NSString*)string method , I get nil when request identifierForVendor.

I'm not sure if this is a bug in bridge or Store generated package family name in wrong format - could you investigate please?

As a workaround I have the following code

 NSString* identifierForVendor= [[[UIDevice currentDevice] identifierForVendor] UUIDString];

    #if WINOBJC
    if (identifierForVendor== nil) {
        WAPackage* currentPackage = [WAPackage current];
        WAPackageId* packageid = currentPackage.id;
        identifierForVendor= packageid.familyName;
    }
    #endif

Kind regards, Julia

rajsesh commented 7 years ago

@jboich thanks for the detailed report. The root of the problem is that the package ids are not necessarily uuids in windows - that is not a bug, it is a feature. The issue here is that indentifierForVendor assumed that this will be guid, and that is incorrect. The right thing to do on winobjc would be to have an extension api that returns the id for vendor as a string.

jboich commented 7 years ago

Hi, @rajsesh-msft . Thank you for clarification!

ArnOmsft commented 7 years ago

Thanks for reporting this and for sharing the workaround. We're adding this to our backlog but since there's a workaround this is a low priority work item for us right now. Feel free to submit a pull request for this.

DHowett-MSFT commented 7 years ago

Updating this issue to track work in #2673.

Underlying bug

UIDevice tried to parse the package's family name (unique for every package) as a GUID. This was wrong for two reasons:

  1. It is not guaranteed to be a GUID
  2. It uniquely identifies a single package, not a publisher

Resolution

Replace the awful existing implementation with one that derives an identifier that is truly vendor-specific.

Applications deployed after #2673 merges will find their vendor identifiers changed.