If you’ve found yourself on this page, please check out the following documentation pages:

What was deprecated?

The setExternalUserId method will be deprecated in version 5+ of our SDKs.

Instead, the External User ID will now be called External ID and will be used as the default alias for the new OneSignal.login method.

See the User Model Migration Guide for more details.

setExternalUserId Method

The OneSignal SDK setExternalUserId method should be called when the user logs into the app/site and within the callback of the setEmail and setSMSNumber methods to link the records together.

let externalUserId = "123456789"; // You will supply the external user id to the OneSignal SDK

OneSignal.push(function() {
  OneSignal.setExternalUserId(externalUserId);
});

If you have a backend server, we strongly recommend using Identity Verification with your users. Your backend can generate an identifier authentication token and send it to your site.

Disassociating the External User Id

External User Ids can be disassociated from the current device’s subscription_id record using the OneSignal SDK removeExternalUserId method.

removeExternalUserId Method

It is recommended to call this method when the user logs out of your app.

OneSignal.push(function() {
  OneSignal.removeExternalUserId();
});