Remove external user ID from OneSignal

Turn your website into an app in 60 seconds!
Preview My App
Jack & Jones' desktop website and mobile app.

If you would like to remove the external user ID from a user profile in OneSignal you can trigger the nativeFunctions.onesignalRemoveExternalUserId() function.

This can be helpful in case you don’t want users that are not logged in to receive push notifications, for example.

If that is the case, whenever you log a user out of his account you would also call the nativeFunctions.onesignalRemoveExternalUserId() function, as follows:

<script type="text/javascript">
    // Listen to events
    window.addEventListener("message", (event) => {
        runNativeFunctions(event);
    }, false);

    // Set the user ID
    var userId = "1"

    // Function that runs when the event is triggered
    function runNativeFunctions(event) {
        try {

            // Check if the native functions are ready to be used
            if (event.data && event.data == 'nativeFunctionsLoaded') {
                // Native function can be called here
                nativeFunctions.onesignalRemoveExternalUserId($userId);
            }

        } catch (ex) {
            // Log any error messages for easier debugging
            console.log(ex.message;);
        }
    }
</script>

Launch your brand's mobile app with a team of experts by your side.

Our team holds your hand through every step of the process to make building an app a no-brainer.
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
  • Preview your app yourself or get a live demo on a call.
  • Learn about our platform and process to help you launch with minimal work required.
  • Risk free - 100% app approval guaranteed or your money back.
Only and Bestseller's iOS and Android apps.
Thank you! We'll be in touch within 48 hours :)
Oops! Something went wrong while submitting the form.
Chat icon.