I noticed that OneSignal is creating a unique player_id and adding a column in its database when my web app is loaded for the first time by any user.
I'm trying to add a custom external_user_id into the same one signal DB field using below code (as per OneSignal docs):
<script src="https://cdn.onesignal.com/sdks/OneSignalSDK.js" ></script>
<script>
let externalUserId = "123456789";
OneSignal.push(function() {
OneSignal.setExternalUserId(externalUserId);
});
</script>
But somehow, the external_user_id field is still set to empty.
So I added the below code to it.
<script src="https://cdn.onesignal.com/sdks/OneSignalSDK.js" ></script>
<script>
let externalUserId = "123456789";
window.OneSignal = window.OneSignal || [];
OneSignal.push(function() {
OneSignal.init({
appId: "xoxoxoxoxoxoxoxoxo",
});
});
OneSignal.push(function() {
console.log("triggering");
OneSignal.setExternalUserId(externalUserId);
console.log("triggering");
});
It has no errors, yet external_user_id is still not updated.
This is the OneSignal code I have added to my Android Studio
package com.appgrep.xoxoxo;
import android.app.Application;
public class OneSignal extends Application {
private static final String ONESIGNAL_APP_ID = "xoxoxoxoxoxoxoxoxo";
@Override
public void onCreate() {
super.onCreate();
// OneSignal Initialization
com.onesignal.OneSignal.initWithContext(this);
com.onesignal.OneSignal.setAppId(ONESIGNAL_APP_ID);
}
}
I just am trying to add External_User_Id in OneSignal using Web (JS) Any help is greatly appreciated.
I think it's not possible through web buddy.
What you are trying to do is to update a field in onesignl using website. Which i don't think one signal let's you do.