If your application is set to require the user's consent before
using push notifications, your app should call this method when
the user gives their consent. This will cause the OneSignal SDK
to initialize.
Allows you to delete a single key/value pair from the user's tags
by specifying the key. This method can often take more than five
seconds to complete, so please do NOT block any user-interactive
content while waiting for this request to complete.
Allows you to manually disable or enable push notifications for this user.
Note: This method does not change the user's system (iOS) push notification
permission status. If the user disabled (or never allowed) your application
to send push notifications, calling disablePush(false) will not change that.
An asynchronous method that makes an HTTP request to OneSignal's
API to retrieve the current user's tags.
This request can take a while to complete: please do NOT block
any user-interactive content while waiting for this request
to finish.
A boolean value indicating if the OneSignal SDK is waiting for the
user's consent before it can initialize (if you set the app to
require the user's consent)
Send a normal outcome event for the current session and notifications with the attribution window
Counted each time sent successfully, failed ones will be cached and reattempted in future
Send an outcome event with a value for the current session and notifications with the attribution window
Counted each time sent successfully, failed ones will be cached and reattempted in future
Sends a single key/value pair to tags to OneSignal.
Please do not send hashmaps/arrays as values as this will fail.
This method can often take more than five seconds to complete,
so please do NOT block any user-interactive content while
waiting for this request to complete.
Updates the user's OneSignal tags. This method is additive
This method can often take more than five seconds to complete,
so please do NOT block any user-interactive content while
waiting for this request to complete.
Send a unique outcome event for the current session and notifications with the attribution window
Counted once per notification when sent successfully, failed ones will be cached and reattempted in future
Sets the user's email so you can send them emails through the OneSignal dashboard
and API. The emailAuthHashToken is optional (but highly recommended) as part of
Identity Verification. The email auth hash is a hash of your app's API key and the
user ID. We recommend you generate this token from your backend server, do NOT
store your API key in your app as this is highly insecure.
The email subscription handler will be called whenever the user's email
subscription changes (OneSignal can also send emails in addition to push
notifications). For example, if you call setEmail() or logoutEmail().
OneSignal allows you to set a custom ID for your users. This makes it so that
if your app has its own user ID's, you can use your own custom user ID's with
our API instead of having to save their OneSignal user ID's.
Only applies to iOS
Sets if launch URLs should be opened within the application or in Safari.
When set to true, launch URLs will open an in-app browser.
Sets the log level for the SDK. The first parameter (logLevel) controls
how verbose logs in the console/logcat are, while the visual log level
controls if the SDK will show alerts for each logged message
The permission handler will be called whenever the user's Permission
state changes, which is applicable to iOS (Android does not prompt the
user for permission to receive push notifications).
Allows you to completely disable the SDK until your app calls the
OneSignal.consentGranted(true) function. This is useful if you want
to show a Terms and Conditions or privacy popup for GDPR.
Sets the user's SMS number so you can send them SMSs through the OneSignal dashboard
and API. The smsAuthHashToken is optional (but highly recommended) as part of
Identity Verification. The SMS auth hash is a hash of your app's API key and the
user ID. We recommend you generate this token from your backend server, do NOT
store your API key in your app as this is highly insecure.
The SMS subscription handler will be called whenever the user's SMS
subscription changes (OneSignal can also send SMSs in addition to push
notifications). For example, if you call setSMSNumber() or logoutSMSNumber().
A singleton representing the OneSignal SDK.
Note that the iOS and Android native libraries are static,
so if you create multiple instances of OneSignal, they will
mostly share the same state.