Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,59 @@ interface IOneSignal {
* The user manager for accessing user-scoped
* management.
*/
@Deprecated(
message =
"Accessing this property may block the calling thread until the SDK is initialized and " +
"cause ANRs when called on the main thread. Use the suspend function getUser() instead.",
replaceWith = ReplaceWith("getUser()"),
)
val user: IUserManager

/**
* The session manager for accessing session-scoped management.
*/
@Deprecated(
message =
"Accessing this property may block the calling thread until the SDK is initialized and " +
"cause ANRs when called on the main thread. Use the suspend function getSession() instead.",
replaceWith = ReplaceWith("getSession()"),
)
val session: ISessionManager

/**
* The notification manager for accessing device-scoped
* notification management.
*/
@Deprecated(
message =
"Accessing this property may block the calling thread until the SDK is initialized and " +
"cause ANRs when called on the main thread. Use the suspend function getNotifications() instead.",
replaceWith = ReplaceWith("getNotifications()"),
)
val notifications: INotificationsManager

/**
* The location manager for accessing device-scoped
* location management.
*/
@Deprecated(
message =
"Accessing this property may block the calling thread until the SDK is initialized and " +
"cause ANRs when called on the main thread. Use the suspend function getLocation() instead.",
replaceWith = ReplaceWith("getLocation()"),
)
val location: ILocationManager

/**
* The In App Messaging manager for accessing device-scoped
* IAP management.
*/
@Deprecated(
message =
"Accessing this property may block the calling thread until the SDK is initialized and " +
"cause ANRs when called on the main thread. Use the suspend function getInAppMessages() instead.",
replaceWith = ReplaceWith("getInAppMessages()"),
)
val inAppMessages: IInAppMessagesManager

/**
Expand All @@ -62,17 +92,47 @@ interface IOneSignal {
* should be set to `true` prior to the invocation of
* [initWithContext] to ensure compliance.
*/
@get:Deprecated(
message =
"Reading this property may block the calling thread until the SDK is initialized and " +
"cause ANRs when called on the main thread. Use the suspend function getConsentRequired() instead.",
replaceWith = ReplaceWith("getConsentRequired()"),
)
@set:Deprecated(
message = "Use the suspend function setConsentRequired(value) instead.",
replaceWith = ReplaceWith("setConsentRequired(value)"),
)
var consentRequired: Boolean

/**
* Indicates whether privacy consent has been granted. This field is only relevant when
* the application has opted into data privacy protections. See [consentRequired].
*/
@get:Deprecated(
message =
"Reading this property may block the calling thread until the SDK is initialized and " +
"cause ANRs when called on the main thread. Use the suspend function getConsentGiven() instead.",
replaceWith = ReplaceWith("getConsentGiven()"),
)
@set:Deprecated(
message = "Use the suspend function setConsentGiven(value) instead.",
replaceWith = ReplaceWith("setConsentGiven(value)"),
)
var consentGiven: Boolean

/**
* Whether to disable the "GMS is missing" prompt to the user.
*/
@get:Deprecated(
message =
"Reading this property may block the calling thread until the SDK is initialized and " +
"cause ANRs when called on the main thread. Use the suspend function getDisableGMSMissingPrompt() instead.",
replaceWith = ReplaceWith("getDisableGMSMissingPrompt()"),
)
@set:Deprecated(
message = "Use the suspend function setDisableGMSMissingPrompt(value) instead.",
replaceWith = ReplaceWith("setDisableGMSMissingPrompt(value)"),
)
var disableGMSMissingPrompt: Boolean

/**
Expand All @@ -83,6 +143,12 @@ interface IOneSignal {
*
* @return true if the SDK could be successfully initialized, false otherwise.
*/
@Deprecated(
message =
"This blocking method may block the calling thread and cause ANRs when called on the " +
"main thread. Use the suspend function initWithContextSuspend(context, appId) instead.",
replaceWith = ReplaceWith("initWithContextSuspend(context, appId)"),
)
fun initWithContext(
context: Context,
appId: String,
Expand Down Expand Up @@ -116,11 +182,30 @@ interface IOneSignal {
* trust for the login operation. Required when identity verification has been enabled. See
* [Identity Verification | OneSignal](https://documentation.onesignal.com/docs/identity-verification)
*/
@Deprecated(
message =
"This blocking method may block the calling thread and cause ANRs when called on the " +
"main thread. Use the suspend function loginSuspend(externalId, jwtBearerToken) instead.",
replaceWith = ReplaceWith("loginSuspend(externalId, jwtBearerToken)"),
)
fun login(
externalId: String,
jwtBearerToken: String? = null,
)

/**
* Login to OneSignal under the user identified by the [externalId] provided, without a JWT
* bearer token. Convenience overload of [login] equivalent to calling it with a `null` token.
*
* @param externalId The external ID of the user that is to be logged in.
*/
@Deprecated(
message =
"This blocking method may block the calling thread and cause ANRs when called on the " +
"main thread. Use the suspend function loginSuspend(externalId) instead.",
replaceWith = ReplaceWith("loginSuspend(externalId)"),
)
@Suppress("DEPRECATION")
fun login(externalId: String) = login(externalId, null)

/**
Expand All @@ -129,6 +214,12 @@ interface IOneSignal {
* be retrieved, except through this device as long as the app remains installed and the app
* data is not cleared.
*/
@Deprecated(
message =
"This blocking method may block the calling thread and cause ANRs when called on the " +
"main thread. Use the suspend function logoutSuspend() instead.",
replaceWith = ReplaceWith("logoutSuspend()"),
)
fun logout()

/**
Expand All @@ -140,6 +231,12 @@ interface IOneSignal {
* @param externalId The external ID the JWT belongs to.
* @param token The new JWT bearer token issued by your backend.
*/
@Deprecated(
message =
"This blocking method may block the calling thread and cause ANRs when called on the " +
"main thread. Use the suspend function updateUserJwtSuspend(externalId, token) instead.",
replaceWith = ReplaceWith("updateUserJwtSuspend(externalId, token)"),
)
fun updateUserJwt(
externalId: String,
token: String,
Expand Down
103 changes: 103 additions & 0 deletions OneSignalSDK/onesignal/core/src/main/java/com/onesignal/OneSignal.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ object OneSignal {
* called.
*/
@JvmStatic
@Deprecated(
message =
"Accessing this property may block the calling thread until the SDK is initialized and " +
"cause ANRs when called on the main thread. Use the suspend function getUserSuspend() instead.",
replaceWith = ReplaceWith("getUserSuspend()"),
)
@Suppress("DEPRECATION")
val User: IUserManager
get() = oneSignal.user

Expand All @@ -50,6 +57,13 @@ object OneSignal {
* has been called.
*/
@JvmStatic
@Deprecated(
message =
"Accessing this property may block the calling thread until the SDK is initialized and " +
"cause ANRs when called on the main thread. Use the suspend function getSessionSuspend() instead.",
replaceWith = ReplaceWith("getSessionSuspend()"),
)
@Suppress("DEPRECATION")
val Session: ISessionManager
get() = oneSignal.session

Expand All @@ -58,6 +72,13 @@ object OneSignal {
* only after [initWithContext] has been called.
*/
@JvmStatic
@Deprecated(
message =
"Accessing this property may block the calling thread until the SDK is initialized and " +
"cause ANRs when called on the main thread. Use the suspend function getNotificationsSuspend() instead.",
replaceWith = ReplaceWith("getNotificationsSuspend()"),
)
@Suppress("DEPRECATION")
val Notifications: INotificationsManager
get() = oneSignal.notifications

Expand All @@ -66,6 +87,13 @@ object OneSignal {
* only after [initWithContext] has been called.
*/
@JvmStatic
@Deprecated(
message =
"Accessing this property may block the calling thread until the SDK is initialized and " +
"cause ANRs when called on the main thread. Use the suspend function getLocationSuspend() instead.",
replaceWith = ReplaceWith("getLocationSuspend()"),
)
@Suppress("DEPRECATION")
val Location: ILocationManager
get() = oneSignal.location

Expand All @@ -74,6 +102,13 @@ object OneSignal {
* only after [initWithContext] has been called.
*/
@JvmStatic
@Deprecated(
message =
"Accessing this property may block the calling thread until the SDK is initialized and " +
"cause ANRs when called on the main thread. Use the suspend function getInAppMessagesSuspend() instead.",
replaceWith = ReplaceWith("getInAppMessagesSuspend()"),
)
@Suppress("DEPRECATION")
val InAppMessages: IInAppMessagesManager
get() = oneSignal.inAppMessages

Expand All @@ -94,6 +129,17 @@ object OneSignal {
* [initWithContext] to ensure compliance.
*/
@JvmStatic
@get:Deprecated(
message =
"Reading this property may block the calling thread until the SDK is initialized and " +
"cause ANRs when called on the main thread. Use the suspend function getConsentRequiredSuspend() instead.",
replaceWith = ReplaceWith("getConsentRequiredSuspend()"),
)
@set:Deprecated(
message = "Use the suspend function setConsentRequiredSuspend(value) instead.",
replaceWith = ReplaceWith("setConsentRequiredSuspend(value)"),
)
@Suppress("DEPRECATION")
var consentRequired: Boolean
get() = oneSignal.consentRequired
set(value) {
Expand All @@ -105,6 +151,17 @@ object OneSignal {
* the application has opted into data privacy protections. See [requiresPrivacyConsent].
*/
@JvmStatic
@get:Deprecated(
message =
"Reading this property may block the calling thread until the SDK is initialized and " +
"cause ANRs when called on the main thread. Use the suspend function getConsentGivenSuspend() instead.",
replaceWith = ReplaceWith("getConsentGivenSuspend()"),
)
@set:Deprecated(
message = "Use the suspend function setConsentGivenSuspend(value) instead.",
replaceWith = ReplaceWith("setConsentGivenSuspend(value)"),
)
@Suppress("DEPRECATION")
var consentGiven: Boolean
get() = oneSignal.consentGiven
set(value) {
Expand All @@ -115,6 +172,17 @@ object OneSignal {
* Whether to disable the "GMS is missing" prompt to the user.
*/
@JvmStatic
@get:Deprecated(
message =
"Reading this property may block the calling thread until the SDK is initialized and " +
"cause ANRs when called on the main thread. Use the suspend function getDisableGMSMissingPromptSuspend() instead.",
replaceWith = ReplaceWith("getDisableGMSMissingPromptSuspend()"),
)
@set:Deprecated(
message = "Use the suspend function setDisableGMSMissingPromptSuspend(value) instead.",
replaceWith = ReplaceWith("setDisableGMSMissingPromptSuspend(value)"),
)
@Suppress("DEPRECATION")
var disableGMSMissingPrompt: Boolean
get() = oneSignal.disableGMSMissingPrompt
set(value) {
Expand All @@ -128,6 +196,13 @@ object OneSignal {
* @param appId The application ID the OneSignal SDK is bound to.
*/
@JvmStatic
@Deprecated(
message =
"This blocking method may block the calling thread and cause ANRs when called on the " +
"main thread. Use the suspend function initWithContextSuspend(context, appId) instead.",
replaceWith = ReplaceWith("initWithContextSuspend(context, appId)"),
)
@Suppress("DEPRECATION")
fun initWithContext(
context: Context,
appId: String,
Expand Down Expand Up @@ -305,6 +380,13 @@ object OneSignal {
* @param externalId The external ID of the user that is to be logged in.
*/
@JvmStatic
@Deprecated(
message =
"This blocking method may block the calling thread and cause ANRs when called on the " +
"main thread. Use the suspend function loginSuspend(externalId) instead.",
replaceWith = ReplaceWith("loginSuspend(externalId)"),
)
@Suppress("DEPRECATION")
fun login(externalId: String) = oneSignal.login(externalId)

/**
Expand All @@ -329,6 +411,13 @@ object OneSignal {
* [Identity Verification | OneSignal](https://documentation.onesignal.com/docs/identity-verification)
*/
@JvmStatic
@Deprecated(
message =
"This blocking method may block the calling thread and cause ANRs when called on the " +
"main thread. Use the suspend function loginSuspend(externalId, jwtBearerToken) instead.",
replaceWith = ReplaceWith("loginSuspend(externalId, jwtBearerToken)"),
)
@Suppress("DEPRECATION")
fun login(
externalId: String,
jwtBearerToken: String? = null,
Expand All @@ -341,6 +430,13 @@ object OneSignal {
* data is not cleared.
*/
@JvmStatic
@Deprecated(
message =
"This blocking method may block the calling thread and cause ANRs when called on the " +
"main thread. Use the suspend function logoutSuspend() instead.",
replaceWith = ReplaceWith("logoutSuspend()"),
)
@Suppress("DEPRECATION")
fun logout() = oneSignal.logout()

/**
Expand All @@ -353,6 +449,13 @@ object OneSignal {
* @param token The new JWT bearer token issued by your backend.
*/
@JvmStatic
@Deprecated(
message =
"This blocking method may block the calling thread and cause ANRs when called on the " +
"main thread. Use the suspend function updateUserJwtSuspend(externalId, token) instead.",
replaceWith = ReplaceWith("updateUserJwtSuspend(externalId, token)"),
)
@Suppress("DEPRECATION")
fun updateUserJwt(
externalId: String,
token: String,
Expand Down
Loading
Loading