Hi,
So I have the Web Push working on the site but I want to get the User ID … which I think I set in the index.html below,
<script>
var OneSignal = window.OneSignal || [];
var ONE_SIGNAL_USERID = -1;
var ONE_SIGNAL_REGISTERED = false;
OneSignal.push(["init", {
appId: "xxxx",
autoRegister: true,
httpPermissionRequest: {
enable: true
},
welcomeNotification: {
disable: true
},
notifyButton: {
enable: true
}
}]);
OneSignal.push(function () {
OneSignal.isPushNotificationsEnabled(function (isEnabled) {
ONE_SIGNAL_REGISTERED = isEnabled;
});
if (ONE_SIGNAL_REGISTERED) {
OneSignal.push(function () {
OneSignal.getUserId().then(function (userId) {
if (userId == null) {
ONE_SIGNAL_USERID = -1;
}
else {
ONE_SIGNAL_USERID = userId;
}
});
});
}
</script>
but when I try to access it in app.component.ts, I always receive -1.
initializeApp() {
this.platform.ready().then(() => {
console.log(window["ONE_SIGNAL_USERID"]);
});
}
any help appreciated.
Thanks