iBeacon: defining UUID

2019-08-08 06:38发布

In the official iBeacon guide for developer Apple states that

Application developers should define a UUID specific to their app and deployment use case.

Question:

  • Part A: How can I define a UUID in the way that I am sure it won't conflict with any others? Is there an official way to get one?
  • Part B: Assuming A is possible, how can I ensure that the UUID is unique across iOS and Android devices?

Looking at the quote above it seems up to the developer. However it feels like a non robust solutions.


If part B of question 1 is not possible then there would be the following use case that I am worried will happen:

Two companies have defined the same UUID for two different apps and a user has them both installed. The user enters in proximity with one of the iBeacons of one of the companies (both iBeacons do not have a minor and major value defined or both have the same minor and minor value).

Question 2:

  • how do iOS and Android cope with this? Is this possible at all?

3条回答
Bombasti
2楼-- · 2019-08-08 06:51

It's a 128 bit UUID. Write a five line MacOS X program that creates and prints a UUID and use it.

There is a non-zero chance that a customer will complain to you about having the same UUID as another device. It is however more likely that one meteor strikes him, and another strikes you, and you both die, five seconds before he or she manages to complain.

That's how UUIDs work.

查看更多
爷的心禁止访问
3楼-- · 2019-08-08 06:57

A UUID is 128 bits long, and can guarantee uniqueness across space and time.

See A Universally Unique IDentifier (UUID)

iOS uuid code (Google for Android):

// Create a `NSUUID
NSUUID  *uuid = [NSUUID new];

// As a string:
NSString *uuidString = [uuid UUIDString];
NSLog(@"uuidString: %@", uuidString);

// As a bytes:
uuid_t uuidBytes;
[uuid getUUIDBytes:uuidBytes];

// as `NSData`:
NSData *uuidData = [NSData dataWithBytes:uuidBytes length:sizeof(uuid_t)];
NSLog(@"uuidData: %@", uuidData);

Output:

uuidString: 8F16F262-3E60-49F4-9D1B-FC4F4975B219
uuidBytes: 8F16F2623E6049F49D1BFC4F4975B219
uuidData: <8f16f262 3e6049f4 9d1bfc4f 4975b219>
查看更多
可以哭但决不认输i
4楼-- · 2019-08-08 07:03

The only official way to get a ProximityUUID is to generate one using a (secure) random UUID generator. It is statistically extremely unlikely that you will accidentally pick the same ProximityUUID as another company if you use a random UUID generator like one here. This is true because there are so many combinations, as @gnasher729 says in his answer. The chances of an accidental overlap are so low that it simply is not worth worrying about.

That said, there is nothing to stop somebody else from deliberately using the same ProximityUUID that you define. Because an iBeacon transmission is sent in clear text with no encryption, anybody with a Bluetooth LE scanner on Android, Mac or Windows device can read your ProximityUUID from a beacon over the air.

There is no way to stop this.

The way that Android and iOS apps cope with this by only using iBeacons for use cases where this is acceptable. If it is unacceptable for your use case, then you must look for another solution than offered by iBeacons.

查看更多
登录 后发表回答