-
public interface IOneSignal
-
-
Method Summary
Modifier and Type Method Description abstract BooleaninitWithContext(Context context, String appId)Initialize the OneSignal SDK. abstract BooleaninitWithContext(Context context)Initialize the OneSignal SDK, suspend until initialization is completed abstract Unitlogin(String externalId, String jwtBearerToken)Login to OneSignal under the user identified by the externalId provided. Unitlogin(String externalId)abstract Unitlogout()Logout the user previously logged in via login. abstract BooleaninitWithContextSuspend(Context context, String appId)Initialize the OneSignal SDK, suspend until initialization is completed abstract ISessionManagergetSession()Get the session manager without blocking the calling thread. abstract INotificationsManagergetNotifications()Get the notifications manager without blocking the calling thread. abstract ILocationManagergetLocation()Get the location manager without blocking the calling thread. abstract IInAppMessagesManagergetInAppMessages()Get the in-app messages manager without blocking the calling thread. abstract IUserManagergetUser()Get the user manager without blocking the calling thread. abstract BooleangetConsentRequired()Get the consent required flag in a thread-safe manner. abstract UnitsetConsentRequired(Boolean required)Set the consent required flag in a thread-safe manner. abstract BooleangetConsentGiven()Get the consent given flag in a thread-safe manner. abstract UnitsetConsentGiven(Boolean value)Set the consent given flag in a thread-safe manner. abstract BooleangetDisableGMSMissingPrompt()Get the disable GMS missing prompt flag in a thread-safe manner. abstract UnitsetDisableGMSMissingPrompt(Boolean value)Set the disable GMS missing prompt flag in a thread-safe manner. abstract UnitloginSuspend(String externalId, String jwtBearerToken)Login a user with external ID and optional JWT token (suspend version). abstract UnitlogoutSuspend()Logout the current user (suspend version). abstract StringgetSdkVersion()The current SDK version as a string. abstract BooleangetIsInitialized()Whether the SDK has been initialized. abstract IUserManagergetUser()The user manager for accessing user-scoped management. abstract ISessionManagergetSession()The session manager for accessing session-scoped management. abstract INotificationsManagergetNotifications()The notification manager for accessing device-scoped notification management. abstract ILocationManagergetLocation()The location manager for accessing device-scoped location management. abstract IInAppMessagesManagergetInAppMessages()The In App Messaging manager for accessing device-scoped IAP management. abstract IDebugManagergetDebug()Access to debug the SDK in the event additional information is required to diagnose any SDK-related issues. abstract BooleangetConsentRequired()Determines whether a user must consent to privacy prior to their user data being sent up to OneSignal. abstract UnitsetConsentRequired(Boolean consentRequired)Determines whether a user must consent to privacy prior to their user data being sent up to OneSignal. abstract BooleangetConsentGiven()Indicates whether privacy consent has been granted. abstract UnitsetConsentGiven(Boolean consentGiven)Indicates whether privacy consent has been granted. abstract BooleangetDisableGMSMissingPrompt()Whether to disable the "GMS is missing" prompt to the user. abstract UnitsetDisableGMSMissingPrompt(Boolean disableGMSMissingPrompt)Whether to disable the "GMS is missing" prompt to the user. -
-
Method Detail
-
initWithContext
abstract Boolean initWithContext(Context context, String appId)
Initialize the OneSignal SDK. This should be called during startup of the application.
- Parameters:
context- The Android context the SDK should use.appId- The application ID the OneSignal SDK is bound to.
-
initWithContext
abstract Boolean initWithContext(Context context)
Initialize the OneSignal SDK, suspend until initialization is completed
- Parameters:
context- The Android context the SDK should use.
-
login
abstract Unit login(String externalId, String jwtBearerToken)
Login to OneSignal under the user identified by the externalId provided. The act of logging a user into the OneSignal SDK will switch the user context to that specific user.
If the externalId exists the user will be retrieved and the context set from that user information. If operations have already been performed under a guest user, they will not be applied to the now logged in user (they will be lost).
If the externalId does not exist the user will be created and the context set from the current local state. If operations have already been performed under a guest user those operations will be applied to the newly created user.
Push Notifications and In App Messaging Logging in a new user will automatically transfer push notification and in app messaging subscriptions from the current user (if there is one) to the newly logged in user. This is because both Push and IAM are owned by the device.
- Parameters:
externalId- The external ID of the user that is to be logged in.jwtBearerToken- The optional JWT bearer token generated by your backend to establish trust for the login operation.
-
logout
abstract Unit logout()
Logout the user previously logged in via login. The user property now references a new device-scoped user. A device-scoped user has no user identity that can later be retrieved, except through this device as long as the app remains installed and the app data is not cleared.
-
initWithContextSuspend
abstract Boolean initWithContextSuspend(Context context, String appId)
Initialize the OneSignal SDK, suspend until initialization is completed
- Parameters:
context- The Android context the SDK should use.appId- The application ID the OneSignal SDK is bound to.
-
getSession
abstract ISessionManager getSession()
Get the session manager without blocking the calling thread. Suspends until the SDK is initialized.
-
getNotifications
abstract INotificationsManager getNotifications()
Get the notifications manager without blocking the calling thread. Suspends until the SDK is initialized.
-
getLocation
abstract ILocationManager getLocation()
Get the location manager without blocking the calling thread. Suspends until the SDK is initialized.
-
getInAppMessages
abstract IInAppMessagesManager getInAppMessages()
Get the in-app messages manager without blocking the calling thread. Suspends until the SDK is initialized.
-
getUser
abstract IUserManager getUser()
Get the user manager without blocking the calling thread. Suspends until the SDK is initialized.
-
getConsentRequired
abstract Boolean getConsentRequired()
Get the consent required flag in a thread-safe manner.
-
setConsentRequired
abstract Unit setConsentRequired(Boolean required)
Set the consent required flag in a thread-safe manner.
-
getConsentGiven
abstract Boolean getConsentGiven()
Get the consent given flag in a thread-safe manner.
-
setConsentGiven
abstract Unit setConsentGiven(Boolean value)
Set the consent given flag in a thread-safe manner.
-
getDisableGMSMissingPrompt
abstract Boolean getDisableGMSMissingPrompt()
Get the disable GMS missing prompt flag in a thread-safe manner.
-
setDisableGMSMissingPrompt
abstract Unit setDisableGMSMissingPrompt(Boolean value)
Set the disable GMS missing prompt flag in a thread-safe manner.
-
loginSuspend
abstract Unit loginSuspend(String externalId, String jwtBearerToken)
Login a user with external ID and optional JWT token (suspend version). Handles initialization automatically.
- Parameters:
externalId- The external ID of the user that is to be logged in.jwtBearerToken- The optional JWT bearer token generated by your backend to establish trust for the login operation.
-
logoutSuspend
abstract Unit logoutSuspend()
Logout the current user (suspend version).
-
getSdkVersion
abstract String getSdkVersion()
The current SDK version as a string.
-
getIsInitialized
abstract Boolean getIsInitialized()
Whether the SDK has been initialized.
-
getUser
abstract IUserManager getUser()
The user manager for accessing user-scoped management.
-
getSession
abstract ISessionManager getSession()
The session manager for accessing session-scoped management.
-
getNotifications
abstract INotificationsManager getNotifications()
The notification manager for accessing device-scoped notification management.
-
getLocation
abstract ILocationManager getLocation()
The location manager for accessing device-scoped location management.
-
getInAppMessages
abstract IInAppMessagesManager getInAppMessages()
The In App Messaging manager for accessing device-scoped IAP management.
-
getDebug
abstract IDebugManager getDebug()
Access to debug the SDK in the event additional information is required to diagnose any SDK-related issues.
WARNING: This should not be used in a production setting.
-
getConsentRequired
abstract Boolean getConsentRequired()
Determines whether a user must consent to privacy prior to their user data being sent up to OneSignal. This should be set to
trueprior to the invocation of initWithContext to ensure compliance.
-
setConsentRequired
abstract Unit setConsentRequired(Boolean consentRequired)
Determines whether a user must consent to privacy prior to their user data being sent up to OneSignal. This should be set to
trueprior to the invocation of initWithContext to ensure compliance.
-
getConsentGiven
abstract Boolean getConsentGiven()
Indicates whether privacy consent has been granted. This field is only relevant when the application has opted into data privacy protections. See consentRequired.
-
setConsentGiven
abstract Unit setConsentGiven(Boolean consentGiven)
Indicates whether privacy consent has been granted. This field is only relevant when the application has opted into data privacy protections. See consentRequired.
-
getDisableGMSMissingPrompt
abstract Boolean getDisableGMSMissingPrompt()
Whether to disable the "GMS is missing" prompt to the user.
-
setDisableGMSMissingPrompt
abstract Unit setDisableGMSMissingPrompt(Boolean disableGMSMissingPrompt)
Whether to disable the "GMS is missing" prompt to the user.
-
-
-
-