How to set up email messaging on your app or website
setEmail
MethodsetEmail
called previously and the user changes their email, callingsetEmail
again will update that record with the new email address.
setExternalUserId
again within the setEmail
callback to link the records together.logoutEmail
MethodlogoutEmail
to dissociate the email from the device:
Event Object Property | Type |
---|---|
email | string |
getEmailId
MethodPromise
that resolves to the stored OneSignal Subscription ID of the Email Record if one is set using the setEmail
method. Otherwise the Promise resolves to null
. If the user isn’t already subscribed, this function will resolve to null
immediately.
Once created, the Email Record Subscription ID will not change. If the user unsubscribes from web push, for example by clearing their browser data, you should call setEmail
with the same email as before to maintain the same Email Record Subscription ID and tie it to the new Push Subscription ID.
Callback function sets the first parameter to the stored Email Record’s OneSignal Subscription ID if one is set, otherwise the first parameter is set to null.