Open
Description
How can we help?
How can I set the externalId when subscribing to a new user? According to some research I did, I have to install an Eventhandler. In the handler I can get the userID and attach my own externalId, and set it. If I cannot set the externalId, that's fine, but then I need to know the OneSignal_ID, so I can send future Push messages to a single user. Seems to me the OneSignal_ID should be provided by the change Event.
Tried many setups, with await and without, but the event is never called. According to the documentation this should be the initialisation:
<script src="https://cdn.onesignal.com/sdks/web/v16/OneSignalSDK.page.js" defer></script>
<script>
window.OneSignalDeferred = window.OneSignalDeferred || [];
OneSignalDeferred.push(async function(OneSignal) {
await OneSignal.init({
appId: <MYAPPID>,
notifyButton: {
enable: true
}
});
});
OneSignalDeferred.push(function() {
OneSignal.User.addEventListener('change', function (event) {
console.log('change', { event });
});
});
</script>
Why is the change Event not called?