From cbe247f68e523b04e4349587aca16dfa2cd57c57 Mon Sep 17 00:00:00 2001 From: AR Abdul Azeez Date: Wed, 17 Jun 2026 16:11:45 +0530 Subject: [PATCH 1/3] chore: [SDK-4783] deprecate blocking OneSignal APIs in favor of suspend variants Mark the blocking (non-suspend) public APIs as @Deprecated and point them to their suspend equivalents. Adds runtime warn logs on the blocking methods (initWithContext/login/logout/updateUserJwt) so callers are informed at runtime which replacement to use. Covers initWithContext(context, appId), login, logout, updateUserJwt, the manager accessors (User/Session/Notifications/Location/InAppMessages), and the config properties (consentRequired/consentGiven/disableGMSMissingPrompt). Deprecations are applied across IOneSignal, OneSignalImp, and OneSignal. Co-authored-by: Cursor --- .../src/main/java/com/onesignal/IOneSignal.kt | 82 ++++++++++++++++ .../src/main/java/com/onesignal/OneSignal.kt | 94 ++++++++++++++++++ .../com/onesignal/internal/OneSignalImp.kt | 95 ++++++++++++++++++- 3 files changed, 267 insertions(+), 4 deletions(-) diff --git a/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/IOneSignal.kt b/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/IOneSignal.kt index 6b38326c8..10ec5ee00 100644 --- a/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/IOneSignal.kt +++ b/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/IOneSignal.kt @@ -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 /** @@ -62,17 +92,38 @@ interface IOneSignal { * should be set to `true` prior to the invocation of * [initWithContext] to ensure compliance. */ + @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 functions getConsentRequired() " + + "and setConsentRequired(required) instead.", + replaceWith = ReplaceWith("getConsentRequired()"), + ) 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]. */ + @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 functions getConsentGiven() " + + "and setConsentGiven(value) instead.", + replaceWith = ReplaceWith("getConsentGiven()"), + ) var consentGiven: Boolean /** * Whether to disable the "GMS is missing" prompt to the user. */ + @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 functions getDisableGMSMissingPrompt() " + + "and setDisableGMSMissingPrompt(value) instead.", + replaceWith = ReplaceWith("getDisableGMSMissingPrompt()"), + ) var disableGMSMissingPrompt: Boolean /** @@ -83,6 +134,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, @@ -116,11 +173,24 @@ 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, ) + @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) /** @@ -129,6 +199,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() /** @@ -140,6 +216,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, diff --git a/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/OneSignal.kt b/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/OneSignal.kt index ed049b550..1765dacbd 100644 --- a/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/OneSignal.kt +++ b/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/OneSignal.kt @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -94,6 +129,14 @@ object OneSignal { * [initWithContext] to ensure compliance. */ @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 functions getConsentRequiredSuspend() " + + "and setConsentRequiredSuspend(required) instead.", + replaceWith = ReplaceWith("getConsentRequiredSuspend()"), + ) + @Suppress("DEPRECATION") var consentRequired: Boolean get() = oneSignal.consentRequired set(value) { @@ -105,6 +148,14 @@ object OneSignal { * the application has opted into data privacy protections. See [requiresPrivacyConsent]. */ @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 functions getConsentGivenSuspend() " + + "and setConsentGivenSuspend(value) instead.", + replaceWith = ReplaceWith("getConsentGivenSuspend()"), + ) + @Suppress("DEPRECATION") var consentGiven: Boolean get() = oneSignal.consentGiven set(value) { @@ -115,6 +166,14 @@ object OneSignal { * Whether to disable the "GMS is missing" prompt to the user. */ @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 functions getDisableGMSMissingPromptSuspend() " + + "and setDisableGMSMissingPromptSuspend(value) instead.", + replaceWith = ReplaceWith("getDisableGMSMissingPromptSuspend()"), + ) + @Suppress("DEPRECATION") var disableGMSMissingPrompt: Boolean get() = oneSignal.disableGMSMissingPrompt set(value) { @@ -128,6 +187,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, @@ -305,6 +371,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) /** @@ -329,6 +402,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, @@ -341,6 +421,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() /** @@ -353,6 +440,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, diff --git a/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/internal/OneSignalImp.kt b/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/internal/OneSignalImp.kt index 89934bf9b..393792a69 100644 --- a/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/internal/OneSignalImp.kt +++ b/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/internal/OneSignalImp.kt @@ -72,6 +72,13 @@ internal class OneSignalImp( override val isInitialized: Boolean get() = initState == InitState.SUCCESS + @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 functions getConsentRequired() " + + "and setConsentRequired(required) instead.", + replaceWith = ReplaceWith("getConsentRequired()"), + ) override var consentRequired: Boolean get() = if (isInitialized) { @@ -86,6 +93,13 @@ internal class OneSignalImp( } } + @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 functions getConsentGiven() " + + "and setConsentGiven(value) instead.", + replaceWith = ReplaceWith("getConsentGiven()"), + ) override var consentGiven: Boolean get() = if (isInitialized) { @@ -104,6 +118,13 @@ internal class OneSignalImp( } } + @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 functions getDisableGMSMissingPrompt() " + + "and setDisableGMSMissingPrompt(value) instead.", + replaceWith = ReplaceWith("getDisableGMSMissingPrompt()"), + ) override var disableGMSMissingPrompt: Boolean get() = if (isInitialized) { @@ -121,22 +142,52 @@ internal class OneSignalImp( // we hardcode the DebugManager implementation so it can be used prior to calling `initWithContext` override val debug: IDebugManager = DebugManager() + @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()"), + ) override val session: ISessionManager get() = getServiceWithFeatureGate { services.getService() } + @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()"), + ) override val notifications: INotificationsManager get() = getServiceWithFeatureGate { services.getService() } + @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()"), + ) override val location: ILocationManager get() = getServiceWithFeatureGate { services.getService() } + @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()"), + ) override val inAppMessages: IInAppMessagesManager get() = getServiceWithFeatureGate { services.getService() } + @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()"), + ) override val user: IUserManager get() = getServiceWithFeatureGate { services.getService() } @@ -304,12 +355,21 @@ internal class OneSignalImp( return startupService } + @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("ReturnCount", "TooGenericExceptionCaught") override fun initWithContext( context: Context, appId: String, ): Boolean { - Logging.log(LogLevel.DEBUG, "Calling deprecated initWithContext(context: $context, appId: $appId)") + Logging.warn( + "initWithContext(context, appId) is deprecated and should no longer be used. " + + "Use the suspend function initWithContextSuspend(context, appId) instead.", + ) // Warm OneSignalDispatchers on a dedicated daemon thread so the first production caller // of suspendifyOnIO / launchOnSerialIO doesn't pay the ThreadPoolExecutor + dispatcher + @@ -446,11 +506,20 @@ internal class OneSignalImp( } } + @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)"), + ) override fun login( externalId: String, jwtBearerToken: String?, ) { - Logging.log(LogLevel.DEBUG, "Calling deprecated login(externalId: $externalId, jwtBearerToken: ...${jwtBearerToken?.takeLast(8)})") + Logging.warn( + "login(externalId, jwtBearerToken) is deprecated and should no longer be used. " + + "Use the suspend function loginSuspend(externalId, jwtBearerToken) instead.", + ) if (isBackgroundThreadingEnabled) { waitForInit(operationName = "login") @@ -471,8 +540,17 @@ internal class OneSignalImp( } } + @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()"), + ) override fun logout() { - Logging.log(LogLevel.DEBUG, "Calling deprecated logout()") + Logging.warn( + "logout() is deprecated and should no longer be used. " + + "Use the suspend function logoutSuspend() instead.", + ) if (isBackgroundThreadingEnabled) { waitForInit(operationName = "logout") @@ -493,11 +571,20 @@ internal class OneSignalImp( } } + @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)"), + ) override fun updateUserJwt( externalId: String, token: String, ) { - Logging.log(LogLevel.DEBUG, "updateUserJwt(externalId: $externalId, token: ...${token.takeLast(8)})") + Logging.warn( + "updateUserJwt(externalId, token) is deprecated and should no longer be used. " + + "Use the suspend function updateUserJwtSuspend(externalId, token) instead.", + ) if (isBackgroundThreadingEnabled) { waitForInit(operationName = "updateUserJwt") From 6e69d52855a9ae7e33a1dec50f661d2fef119158 Mon Sep 17 00:00:00 2001 From: AR Abdul Azeez Date: Wed, 17 Jun 2026 16:17:12 +0530 Subject: [PATCH 2/3] spotless run --- .../src/main/java/com/onesignal/IOneSignal.kt | 58 +++++++++---------- .../src/main/java/com/onesignal/OneSignal.kt | 58 +++++++++---------- .../com/onesignal/internal/OneSignalImp.kt | 54 ++++++++--------- 3 files changed, 85 insertions(+), 85 deletions(-) diff --git a/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/IOneSignal.kt b/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/IOneSignal.kt index 10ec5ee00..75a5b354f 100644 --- a/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/IOneSignal.kt +++ b/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/IOneSignal.kt @@ -25,8 +25,8 @@ interface IOneSignal { */ @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.", + "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 @@ -36,8 +36,8 @@ interface IOneSignal { */ @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.", + "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 @@ -48,8 +48,8 @@ interface IOneSignal { */ @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.", + "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 @@ -60,8 +60,8 @@ interface IOneSignal { */ @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.", + "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 @@ -72,8 +72,8 @@ interface IOneSignal { */ @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.", + "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 @@ -94,9 +94,9 @@ interface IOneSignal { */ @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 functions getConsentRequired() " + - "and setConsentRequired(required) instead.", + "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 functions getConsentRequired() " + + "and setConsentRequired(required) instead.", replaceWith = ReplaceWith("getConsentRequired()"), ) var consentRequired: Boolean @@ -107,9 +107,9 @@ interface IOneSignal { */ @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 functions getConsentGiven() " + - "and setConsentGiven(value) instead.", + "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 functions getConsentGiven() " + + "and setConsentGiven(value) instead.", replaceWith = ReplaceWith("getConsentGiven()"), ) var consentGiven: Boolean @@ -119,9 +119,9 @@ interface IOneSignal { */ @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 functions getDisableGMSMissingPrompt() " + - "and setDisableGMSMissingPrompt(value) instead.", + "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 functions getDisableGMSMissingPrompt() " + + "and setDisableGMSMissingPrompt(value) instead.", replaceWith = ReplaceWith("getDisableGMSMissingPrompt()"), ) var disableGMSMissingPrompt: Boolean @@ -136,8 +136,8 @@ interface IOneSignal { */ @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.", + "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( @@ -175,8 +175,8 @@ interface IOneSignal { */ @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.", + "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( @@ -186,8 +186,8 @@ interface IOneSignal { @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.", + "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") @@ -201,8 +201,8 @@ interface IOneSignal { */ @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.", + "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() @@ -218,8 +218,8 @@ interface IOneSignal { */ @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.", + "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( diff --git a/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/OneSignal.kt b/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/OneSignal.kt index 1765dacbd..f4e9ffa97 100644 --- a/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/OneSignal.kt +++ b/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/OneSignal.kt @@ -44,8 +44,8 @@ object OneSignal { @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.", + "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") @@ -59,8 +59,8 @@ object OneSignal { @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.", + "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") @@ -74,8 +74,8 @@ object OneSignal { @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.", + "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") @@ -89,8 +89,8 @@ object OneSignal { @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.", + "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") @@ -104,8 +104,8 @@ object OneSignal { @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.", + "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") @@ -131,9 +131,9 @@ object OneSignal { @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 functions getConsentRequiredSuspend() " + - "and setConsentRequiredSuspend(required) instead.", + "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 functions getConsentRequiredSuspend() " + + "and setConsentRequiredSuspend(required) instead.", replaceWith = ReplaceWith("getConsentRequiredSuspend()"), ) @Suppress("DEPRECATION") @@ -150,9 +150,9 @@ object OneSignal { @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 functions getConsentGivenSuspend() " + - "and setConsentGivenSuspend(value) instead.", + "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 functions getConsentGivenSuspend() " + + "and setConsentGivenSuspend(value) instead.", replaceWith = ReplaceWith("getConsentGivenSuspend()"), ) @Suppress("DEPRECATION") @@ -168,9 +168,9 @@ object OneSignal { @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 functions getDisableGMSMissingPromptSuspend() " + - "and setDisableGMSMissingPromptSuspend(value) instead.", + "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 functions getDisableGMSMissingPromptSuspend() " + + "and setDisableGMSMissingPromptSuspend(value) instead.", replaceWith = ReplaceWith("getDisableGMSMissingPromptSuspend()"), ) @Suppress("DEPRECATION") @@ -189,8 +189,8 @@ object OneSignal { @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.", + "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") @@ -373,8 +373,8 @@ object OneSignal { @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.", + "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") @@ -404,8 +404,8 @@ object OneSignal { @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.", + "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") @@ -423,8 +423,8 @@ object OneSignal { @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.", + "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") @@ -442,8 +442,8 @@ object OneSignal { @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.", + "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") diff --git a/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/internal/OneSignalImp.kt b/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/internal/OneSignalImp.kt index 393792a69..4452a20c8 100644 --- a/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/internal/OneSignalImp.kt +++ b/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/internal/OneSignalImp.kt @@ -74,9 +74,9 @@ internal class OneSignalImp( @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 functions getConsentRequired() " + - "and setConsentRequired(required) instead.", + "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 functions getConsentRequired() " + + "and setConsentRequired(required) instead.", replaceWith = ReplaceWith("getConsentRequired()"), ) override var consentRequired: Boolean @@ -95,9 +95,9 @@ internal class OneSignalImp( @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 functions getConsentGiven() " + - "and setConsentGiven(value) instead.", + "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 functions getConsentGiven() " + + "and setConsentGiven(value) instead.", replaceWith = ReplaceWith("getConsentGiven()"), ) override var consentGiven: Boolean @@ -120,9 +120,9 @@ internal class OneSignalImp( @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 functions getDisableGMSMissingPrompt() " + - "and setDisableGMSMissingPrompt(value) instead.", + "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 functions getDisableGMSMissingPrompt() " + + "and setDisableGMSMissingPrompt(value) instead.", replaceWith = ReplaceWith("getDisableGMSMissingPrompt()"), ) override var disableGMSMissingPrompt: Boolean @@ -144,8 +144,8 @@ internal class OneSignalImp( @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.", + "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()"), ) override val session: ISessionManager @@ -154,8 +154,8 @@ internal class OneSignalImp( @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.", + "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()"), ) override val notifications: INotificationsManager @@ -164,8 +164,8 @@ internal class OneSignalImp( @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.", + "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()"), ) override val location: ILocationManager @@ -174,8 +174,8 @@ internal class OneSignalImp( @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.", + "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()"), ) override val inAppMessages: IInAppMessagesManager @@ -184,8 +184,8 @@ internal class OneSignalImp( @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.", + "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()"), ) override val user: IUserManager @@ -357,8 +357,8 @@ internal class OneSignalImp( @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.", + "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("ReturnCount", "TooGenericExceptionCaught") @@ -508,8 +508,8 @@ internal class OneSignalImp( @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.", + "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)"), ) override fun login( @@ -542,8 +542,8 @@ internal class OneSignalImp( @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.", + "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()"), ) override fun logout() { @@ -573,8 +573,8 @@ internal class OneSignalImp( @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.", + "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)"), ) override fun updateUserJwt( From 109fb0abdfb699814755b9d0683ba5944746134a Mon Sep 17 00:00:00 2001 From: AR Abdul Azeez Date: Wed, 17 Jun 2026 16:24:25 +0530 Subject: [PATCH 3/3] chore: [SDK-4783] add KDoc to login(externalId) to satisfy detekt Adding @Deprecated/@Suppress to login(externalId) changed detekt's computed signature, un-matching its UndocumentedPublicFunction baseline entry and pushing :OneSignal:core over the maxIssues=10 threshold. Documenting the function resolves the finding at the source. Co-authored-by: Cursor --- .../core/src/main/java/com/onesignal/IOneSignal.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/IOneSignal.kt b/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/IOneSignal.kt index 75a5b354f..bc6200e02 100644 --- a/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/IOneSignal.kt +++ b/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/IOneSignal.kt @@ -184,6 +184,12 @@ interface IOneSignal { 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 " +