Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move server url to be explicit during initialisation #70

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion dev-app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
tools:targetApi="31">

<!-- The metadata consumed by the Dev App + SDK -->
<meta-data android:name="uid2_api_url" android:value="https://operator-integ.uidapi.com"/>
<meta-data android:name="uid2_api_key" android:value=""/>
IanDBird marked this conversation as resolved.
Show resolved Hide resolved
<meta-data android:name="uid2_api_secret" android:value=""/>

Expand Down
8 changes: 6 additions & 2 deletions dev-app/src/main/java/com/uid2/dev/DevApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ class DevApplication : Application() {

// Initialise the UID2Manager class. We will use it's DefaultNetworkSession rather than providing our own
// custom implementation. This can be done to allow wrapping something like OkHttp.
UID2Manager.init(context = this, isLoggingEnabled = true)
UID2Manager.init(context = this, serverUrl = INTEG_SERVER_URL, isLoggingEnabled = true)

// Alternatively, we could initialise the UID2Manager with our own custom NetworkSession...
// UID2Manager.init(this.applicationContext, OkNetworkSession(), true)
// UID2Manager.init(this, INTEG_SERVER_URL, OkNetworkSession(), true)

// For the development app, we will enable a strict thread policy to ensure we have suitable visibility of any
// issues within the SDK.
Expand All @@ -30,4 +30,8 @@ class DevApplication : Application() {
}.build(),
)
}

private companion object {
const val INTEG_SERVER_URL = "https://operator-integ.uidapi.com"
}
}
11 changes: 4 additions & 7 deletions sdk/src/main/java/com/uid2/UID2Manager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import com.uid2.data.IdentityStatus.OPT_OUT
import com.uid2.data.IdentityStatus.REFRESHED
import com.uid2.data.IdentityStatus.REFRESH_EXPIRED
import com.uid2.data.UID2Identity
import com.uid2.extensions.getMetadata
import com.uid2.network.DefaultNetworkSession
import com.uid2.network.NetworkSession
import com.uid2.storage.StorageManager
Expand Down Expand Up @@ -446,7 +445,6 @@ public class UID2Manager internal constructor(
private const val TAG = "UID2Manager"

// The default API server.
private const val UID2_API_URL_KEY = "uid2_api_url"
private const val UID2_API_URL_DEFAULT = "https://prod.uidapi.com"

private const val PACKAGE_NOT_AVAILABLE = "Identity not available"
Expand All @@ -466,7 +464,7 @@ public class UID2Manager internal constructor(
// The additional time we will allow to pass before checking the expiration of the Identity.
private const val EXPIRATION_CHECK_TOLERANCE_MS = 50

private var api: String = UID2_API_URL_DEFAULT
private var serverUrl: String = UID2_API_URL_DEFAULT
private var networkSession: NetworkSession = DefaultNetworkSession()
private var storageManager: StorageManager? = null
private var isLoggingEnabled: Boolean = false
Expand All @@ -487,16 +485,15 @@ public class UID2Manager internal constructor(
@Throws(InitializationException::class)
public fun init(
context: Context,
serverUrl: String = UID2_API_URL_DEFAULT,
IanDBird marked this conversation as resolved.
Show resolved Hide resolved
networkSession: NetworkSession = DefaultNetworkSession(),
isLoggingEnabled: Boolean = false,
) {
if (instance != null) {
throw InitializationException()
}

val metadata = context.getMetadata()

this.api = metadata?.getString(UID2_API_URL_KEY, UID2_API_URL_DEFAULT) ?: UID2_API_URL_DEFAULT
this.serverUrl = serverUrl
this.networkSession = networkSession
this.storageManager = StorageManager.getInstance(context.applicationContext)
this.isLoggingEnabled = isLoggingEnabled
Expand All @@ -520,7 +517,7 @@ public class UID2Manager internal constructor(

return instance ?: UID2Manager(
UID2Client(
api,
serverUrl,
networkSession,
logger,
),
Expand Down
23 changes: 0 additions & 23 deletions sdk/src/main/java/com/uid2/extensions/ContextEx.kt

This file was deleted.

Loading