To meet the laws and regulations of different countries or regions, the Agora RTC SDK supports geofencing. After enabling geofencing, the Agora SDK only connects to Agora servers within the specified region.
To meet the laws and regulations of different countries or regions, the Agora RTC SDK supports geofencing. After enabling geofencing, the SDK only connects to Agora servers within the specified region, regardless of where your app users are located.
For example, if you specify North America as the region for connection, when two users attempt to connect to Agora servers from different locations, the result is as follows:
Specified region for connection | App user location | Actual region for connection | User experience after connection 1 |
---|---|---|---|
North America | North America | North America | Normal |
China | Can be less than optimal 2 |
Before adjusting the audio volume, ensure that you have implemented the basic real-time communication functions in your project. For details, see the following quickstart guides:
When creating an AgoraRtcEngineKit
instance by calling sharedEngineWithConfig
, set the areaCode
parameter in AgoraRtcEngineConfig
to specify the region for connection.
AgoraAreaCodeGLOB
: (Default) GlobalAgoraAreaCodeCN
: Mainland ChinaAgoraAreaCodeNA
: North AmericaAgoraAreaCodeEU
: EuropeAgoraAreaCodeAS
: Asia, excluding Mainland ChinaAgoraAreaCodeJP
: JapanAgoraAreaCodeIN
: IndiaTo specify a region for connection (such as North America), add config.areaCode = AgoraAreaCode.NA.rawValue
before creating an instance of AgoraRtcEngineKit
.
// Initializes AgoraEngine
func initializeAgoraEngine(){
let config = AgoraRtcEngineConfig()
// Pass in your App ID here.
config.appId = "YourAppId"
//Sets the channel profile as live broadcast.
config.channelProfile = .liveBroadcasting
// Specifies North America as the region for connection
config.areaCode = AgoraAreaCode.NA.rawValue
agoraKit = AgoraRtcEngineKit.sharedEngine(with: config, delegate: self)
}
To exclude a region for connection (such as Mainland China), add config.areaCode = AgoraAreaCode.GLOB.rawValue ^ AgoraAreaCode.CN.rawValue
before creating an instance of AgoraRtcEngineKit
.
// Initializes AgoraEngine
func initializeAgoraEngine(){
let config = AgoraRtcEngineConfig()
// Pass in your App ID here.
config.appId = "YourAppId"
// Sets the channel profile as live broadcast.
config.channelProfile = .liveBroadcasting
// Excludes Mainland China from the regions for connection.
config.areaCode = AgoraAreaCode.GLOB.rawValue ^ AgoraAreaCode.CN.rawValue
agoraKit = AgoraRtcEngineKit.sharedEngine(with: config, delegate: self)
}
This section includes links to related pages.