I discovered tonight in iOS 13 beta 8 that there is a new key and value in the advertisement payload. I didn't notice it before and it very well may have been there prior.
The key is visible when printing out the advertisementData dict, and a typecast passes as TimeInterval
if let timespan = advertisementData["kCBAdvDataTimestamp"] as? TimeInterval {
print("Adv date intv \(timespan)")
}
I didn't see this documented in the API reference under new or old keys. Is this going to be in production? Android API captures timestamp of adv packet since boot--it would be nice to have something similar on iOS (point of reference can be epoch).
These are the values that it was decoding as:
Adv date intv 588221792.199425
Adv date intv 588221793.25799
Adv date intv 588221794.237889
Adv date intv 588221795.255606
Adv date intv 588221796.249666
Adv date intv 588221797.243745
They're nothing close to the epoch or seconds since boot. I got this out of the payload on my polar HR7.
["kCBAdvDataManufacturerData": <6b000900 0000>, "kCBAdvDataTimestamp": 588222227.821503, "kCBAdvDataServiceUUIDs": <__NSArrayM 0x280657cf0>(
Heart Rate
)
, "kCBAdvDataLocalName": Polar H7 --------, "kCBAdvDataIsConnectable": 1, "kCBAdvDataTxPowerLevel": 0]
The kCBAdvDataTimestamp field is added to the advertisement by iOS. It is just the time stamp of when the advertisement was received and can be converted to a NSDate using:
NSNumber *number = advertisementData["kCBAdvDataTimestamp"];
NSTimeInterval absoluteTime = number.doubleValue;
NSDate *date = [NSDate dateWithTimeIntervalSinceReferenceDate:absoluteTime];
Apple also adds kCBAdvDataRxPrimaryPHY and kCBAdvDataRxSecondaryPHY to the advertisement data. Both are NSNumber values and are set to 0 in all the devices I have seen. Their purpose remains a mystery.