Custom SDK Endpoint
How to configure a custom Appodeal SDK endpoint?
In some cases, the default Appodeal server endpoint may become unreachable in certain regions or locations. To resolve this, SDK 4.1.0 introduced the Set Endpoint API, which allows you to override the default server endpoint with a custom one provided by Appodeal support.
Set Endpoint must be called before Appodeal initialization. If called after initialization, the endpoint change will be ignored.
API Reference
- Android
- iOS
- Unity
- Kotlin
- Java
// Set custom endpoint before initialization
Appodeal.setEndpoint("https://provided-endpoint.example.com")
// Initialize SDK as usual
Appodeal.initialize(this, "YOUR_APP_KEY", adTypes)
// Verify the current endpoint (optional)
val currentEndpoint = Appodeal.getEndpoint()
// Set custom endpoint before initialization
Appodeal.setEndpoint("https://provided-endpoint.example.com");
// Initialize SDK as usual
Appodeal.initialize(this, "YOUR_APP_KEY", adTypes);
// Verify the current endpoint (optional)
String currentEndpoint = Appodeal.getEndpoint();
- Swift
- Objective-C
// Set custom endpoint before initialization
Appodeal.setEndpoint("https://provided-endpoint.example.com")
// Initialize SDK as usual
Appodeal.initialize(withApiKey: "YOUR_APP_KEY", types: adTypes)
// Verify the current endpoint (optional)
let currentEndpoint = Appodeal.getEndpoint()
// Set custom endpoint before initialization
[Appodeal setEndpoint:@"https://provided-endpoint.example.com"];
// Initialize SDK as usual
[Appodeal initializeWithApiKey:@"YOUR_APP_KEY" types:adTypes];
// Verify the current endpoint (optional)
NSString *currentEndpoint = [Appodeal getEndpoint];
// Set custom endpoint before initialization
Appodeal.SetEndpoint("https://provided-endpoint.example.com");
// Initialize SDK as usual
Appodeal.Initialize("YOUR_APP_KEY", adTypes);
// Verify the current endpoint (optional)
string currentEndpoint = Appodeal.GetEndpoint();
Configuring Endpoint Remotely
We recommend managing the endpoint URL through a remote configuration service rather than hardcoding it. This allows you to update the endpoint without releasing a new version of your app.
The general approach is:
- Create a remote configuration parameter (e.g.,
appodeal_endpoint) with an empty default value. - On app launch, fetch the configuration values.
- If the parameter is non-empty, call Set Endpoint with the fetched value before Appodeal initialization.
Firebase Remote Config
See Firebase Remote Config documentation for setup instructions.
- Android
- iOS
- Unity
- Kotlin
- Java
val remoteConfig = Firebase.remoteConfig
// Set default value (empty string means use SDK default endpoint)
remoteConfig.setDefaultsAsync(mapOf("appodeal_endpoint" to ""))
remoteConfig.fetchAndActivate().addOnCompleteListener { task ->
val endpoint = remoteConfig.getString("appodeal_endpoint")
if (endpoint.isNotEmpty()) {
Appodeal.setEndpoint(endpoint)
}
Appodeal.initialize(this, "YOUR_APP_KEY", adTypes)
}
FirebaseRemoteConfig remoteConfig = FirebaseRemoteConfig.getInstance();
// Set default value (empty string means use SDK default endpoint)
Map<String, Object> defaults = new HashMap<>();
defaults.put("appodeal_endpoint", "");
remoteConfig.setDefaultsAsync(defaults);
remoteConfig.fetchAndActivate().addOnCompleteListener(task -> {
String endpoint = remoteConfig.getString("appodeal_endpoint");
if (!endpoint.isEmpty()) {
Appodeal.setEndpoint(endpoint);
}
Appodeal.initialize(this, "YOUR_APP_KEY", adTypes);
});
- Swift
- Objective-C
let remoteConfig = RemoteConfig.remoteConfig()
// Set default value (empty string means use SDK default endpoint)
remoteConfig.setDefaults(["appodeal_endpoint": "" as NSObject])
remoteConfig.fetchAndActivate { status, error in
let endpoint = remoteConfig.configValue(forKey: "appodeal_endpoint").stringValue ?? ""
if !endpoint.isEmpty {
Appodeal.setEndpoint(endpoint)
}
Appodeal.initialize(withApiKey: "YOUR_APP_KEY", types: adTypes)
}
FIRRemoteConfig *remoteConfig = [FIRRemoteConfig remoteConfig];
// Set default value (empty string means use SDK default endpoint)
[remoteConfig setDefaults:@{@"appodeal_endpoint": @""}];
[remoteConfig fetchAndActivateWithCompletionHandler:^(FIRRemoteConfigFetchAndActivateStatus status, NSError *error) {
NSString *endpoint = [remoteConfig configValueForKey:@"appodeal_endpoint"].stringValue;
if (endpoint.length > 0) {
[Appodeal setEndpoint:endpoint];
}
[Appodeal initializeWithApiKey:@"YOUR_APP_KEY" types:adTypes];
}];
var remoteConfig = FirebaseRemoteConfig.DefaultInstance;
// Set default value (empty string means use SDK default endpoint)
var defaults = new Dictionary<string, object> {
{ "appodeal_endpoint", "" }
};
remoteConfig.SetDefaultsAsync(defaults).ContinueWithOnMainThread(task => {
remoteConfig.FetchAndActivateAsync().ContinueWithOnMainThread(fetchTask => {
string endpoint = remoteConfig.GetValue("appodeal_endpoint").StringValue;
if (!string.IsNullOrEmpty(endpoint)) {
Appodeal.SetEndpoint(endpoint);
}
Appodeal.Initialize("YOUR_APP_KEY", adTypes);
});
});
AppMetrica Startup Parameters
See AppMetrica Startup Parameters usage examples for Android, iOS, and Unity.
- Android
- iOS
- Unity
- Kotlin
- Java
val callback = object : StartupParamsCallback {
override fun onReceive(result: StartupParamsCallback.Result?) {
val endpoint = result?.parameterForKey("appodeal_endpoint") ?: ""
if (endpoint.isNotEmpty()) {
Appodeal.setEndpoint(endpoint)
}
Appodeal.initialize(this@MainActivity, "YOUR_APP_KEY", adTypes)
}
override fun onRequestError(
reason: StartupParamsCallback.Reason,
result: StartupParamsCallback.Result?
) {}
}
AppMetrica.requestStartupParams(this, callback, listOf("appodeal_endpoint"))
StartupParamsCallback callback = new StartupParamsCallback() {
@Override
public void onReceive(@Nullable StartupParamsCallback.Result result) {
String endpoint = result != null ? result.parameterForKey("appodeal_endpoint") : null;
if (endpoint != null && !endpoint.isEmpty()) {
Appodeal.setEndpoint(endpoint);
}
Appodeal.initialize(MainActivity.this, "YOUR_APP_KEY", adTypes);
}
@Override
public void onRequestError(
@NonNull StartupParamsCallback.Reason reason,
@Nullable StartupParamsCallback.Result result
) {}
};
AppMetrica.requestStartupParams(this, callback, Arrays.asList("appodeal_endpoint"));
- Swift
- Objective-C
let endpointKey = StartupKey("appodeal_endpoint")
AppMetrica.requestStartupIdentifiers(
for: [endpointKey],
on: .main
) { identifiers, error in
if let endpoint = identifiers?[endpointKey] as? String, !endpoint.isEmpty {
Appodeal.setEndpoint(endpoint)
}
Appodeal.initialize(withApiKey: "YOUR_APP_KEY", types: adTypes)
}
AMAStartupKey endpointKey = @"appodeal_endpoint";
[AMAAppMetrica requestStartupIdentifiersWithKeys:@[endpointKey]
completionQueue:dispatch_get_main_queue()
completionBlock:^(NSDictionary<AMAStartupKey, id> *identifiers, NSError *error) {
NSString *endpoint = identifiers[endpointKey];
if (endpoint.length > 0) {
[Appodeal setEndpoint:endpoint];
}
[Appodeal initializeWithApiKey:@"YOUR_APP_KEY" types:adTypes];
}];
AppMetrica.RequestStartupParams(
(result, errorReason) => {
if (result != null) {
string endpoint = result.ParameterForKey("appodeal_endpoint");
if (!string.IsNullOrEmpty(endpoint)) {
Appodeal.SetEndpoint(endpoint);
}
}
Appodeal.Initialize("YOUR_APP_KEY", adTypes);
},
new[] { "appodeal_endpoint" }
);
Important Notes
- The custom endpoint URL will be provided by Appodeal support when needed — do not set arbitrary URLs.
- Use Get Endpoint to verify the currently active endpoint for debugging purposes.