Solution to the problem of IOS Bluetooth device name cache


1. Background

  • After the device has been successfully connected in the app
  • Modify device name
  • The device name scanned by app is still the previous name
  • The way to get the name in app code is (perpheral. Name)

2. Problem analysis

When app is the center to connect other Bluetooth devices.

After the first successful connection, the peripheral cache will be recorded in the IOS system.

The next time you search again, when you find the Bluetooth device, you will print (peripheral. Name) directly, and you will get the Bluetooth name in the previous cache.

If the Bluetooth device updates its name during this period, the parameter (peripheral. Name) will not change, so you need to get the name of the device in another way. In the broadcast packet, there is a field called kcbaddatalocalname, which can get the current device name in real time.

3. Problem solving

Here are solutions for OC and swift:


-(void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary<NSString *,id> *)advertisementData RSSI:(NSNumber *)RSSI{
    NSString *localName = [advertisementData objectForKey:@"kCBAdvDataLocalName"];


func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) {
    let localName = advertisementData["kCBAdvDataLocalName"]


Here is the solution to the problem of IOS Bluetooth device name cache. For more information about IOS Bluetooth device name cache, please search previous articles of developer or continue to browse the following articles. I hope you can support developer more in the future!

Recommended Today

What is “hybrid cloud”?

In this paper, we define the concept of “hybrid cloud”, explain four different cloud deployment models of hybrid cloud, and deeply analyze the industrial trend of hybrid cloud through a series of data and charts. 01 introduction Hybrid cloud is a computing environment that integrates multiple platforms and data centers. Generally speaking, hybrid cloud is […]