简体   繁体   English

如何使用 xamarin C# 从 iOS 上的广告中读取 kCBAdvDataManufacturerData 的值

[英]How do I read the value of kCBAdvDataManufacturerData from the advertisement on iOS using xamarin C#

I tried many things but this seems to be as close as I can get我尝试了很多东西,但这似乎是我能得到的最接近的东西

NSDictionary advertisementData = e.AdvertisementData;
NSString ns_p_mdata = new NSString("kCBAdvDataManufacturerData");
NSObject obj_mdata = advertisementData.ValueForKey(ns_p_mdata);
NSData strMdata = (NSData)obj_mdata;

byte[] result = new byte[strMdata.Length];
System.Runtime.InteropServices.Marshal.Copy(strMdata.Bytes, result, 0, (int)strMdata.Length);
string test = Convert.ToBase64String(result);

However, this does not give me the expected value.但是,这并没有给我预期的价值。

I was using obj_mdata.Description before but this no longer works on iOS 13.x我之前使用过 obj_mdata.Description 但这不再适用于 iOS 13.x

Usually those constants that are used as strings in iOS are tucked away somewhere as an enum or get only property.通常,那些在 iOS 中用作字符串的常量被隐藏在某个地方作为枚举或仅获取属性。

this one appears to be at CoreBluetooth.CBAdvertisement.DataManufacturerDataKey .这个似乎在CoreBluetooth.CBAdvertisement.DataManufacturerDataKey I think that's the one you're looking for.我想这就是你要找的那个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM