Skip to main content

Initialization

Every AFCore feature starts with one call: AFCore.initialize(config), made once at app launch with an AFCoreConfig. From then on the SDK keeps the member's session across launches and resumes the work it was doing -- visit detection, step sync, offline deliveries -- even when the OS relaunches your app in the background.

What you can do​

  • Configure the environment, the realm and logging with a single builder.
  • Initialize once in Application.onCreate() (Android) or at app launch (iOS, watchOS); the SDK restores the previous session by itself.
  • Route SDK logs to your own logging framework.
  • Opt in to reads that throw on failure instead of returning an empty result.
  • Switch environments at runtime with reconfigure().

Key APIs​

CallWhat it is for
AFCoreConfig.builder() / AFCoreConfig.Builder()Build the configuration
baseUrl(...)The API base URL for your environment (HTTPS, required)
clientId(...) / clientSecret(...)Your organization's credentials from AIDE, needed for External ID sign-in; username + password sign-in needs neither
realm(...)The Advanta platform your members belong to -- see Realm
throwOnReadFailure(...)true makes the reads that existed in 1.11 throw on failure (default false)
locationSharingEnabled(...)Share the member's location after they consent (default false)
enableLogging(...), logLevel(...), logWriter(...)SDK logging and where it goes
AFCore.initialize(config)Start the SDK; returns false if it could not
AFCore.isInitialized()Guard before calling a feature accessor
AFCore.isReadyTurns true once the previous session has been restored at launch
AFCore.reconfigure(config)Re-initialize with another configuration (signs the member out)

Example​

class MyApp : Application() {
override fun onCreate() {
super.onCreate()
val config = AFCoreConfig.builder()
.baseUrl("https://api.example.com")
.realm(AFRealm.BISMUTH)
.enableLogging(BuildConfig.DEBUG)
.logLevel(AFLogLevel.DEBUG)
.build()
if (!AFCore.initialize(config)) Log.e("MyApp", "AFCore initialization failed")
}
}

Calling initialize() again with the same configuration is a no-op. Before initialization, feature accessors such as authentication() throw, so check AFCore.isInitialized() first in code that can run early. On iOS, also register the background-task handler at launch -- see Install on iOS.

Realm​

Advanta runs two member platforms, Bismuth and Horizon, behind the same gateway, and the realm tells it where your members belong. Apps whose members are on Horizon must set realm(AFRealm.HORIZON) (Swift: .realm(value: .horizon)). Without a realm, requests are routed to Bismuth, so existing Bismuth integrations keep working unchanged. Configure the realm your app actually signs members in against.

Learn more​

See the API Reference for every AFCoreConfig option. Complete integration guides are in AIDE Docs.