Contents

CNCopyCurrentNetworkInfo

Returns the current network information for a given network interface.

Declaration

CFDictionaryRef CNCopyCurrentNetworkInfo(CFStringRef interfaceName);

Parameters

  • interfaceName:

    The network interface name.

Return Value

A dictionary containing the interface’s current network information, provided certain requirements are met (see Discussion section). If the requirements are not met, the return value is either a dictionary with pseudo-values or NULL. If an error occurs, the return value is NULL.

Discussion

The returned dictionary contains the following keys and values:

Key

Value type

Kcnnetworkinfokeyssiddata

Cfdata

Kcnnetworkinfokeyssid

Cfstring

Kcnnetworkinfokeybssid

Cfstring

Ownership of the returned dictionary follows the The Create Rule. You are responsible for releasing the returned value.

Discussion

The requesting app must meet one of the following requirements:

  • The app uses Core Location, and has the user’s authorization to use location information.

  • The app uses the NEHotspotConfiguration API to configure the current Wi-Fi network.

  • The app has an active VPN configuration installed.

  • The app has an active NEDNSSettingsManager configuration installed.

If the requesting app is a Mac app built with Mac Catalyst, it must meet the following requirements:

An app that fails to meet the above requirements receives the following return value:

  • An app linked against iOS 12 or earlier receives a dictionary with pseudo-values. In this case, the SSID is Wi-Fi (or WLAN in China mainland), and the BSSID is 00:00:00:00:00:00.

  • An app linked against iOS 13 or later receives NULL.