Subscribing Uid issuance event

    Subscribing Uid issuance event


    Article summary

    ON_UID_ISSUED

    This messageCallback is for directly receiving UID when player issues it.

    • After logging in, users are managed with userID, so uid is only for users who are not logged in.

    • When the expiration time passes, a new UID will be issued, hence the UID may change.

    ON_UID_ISSUED

    Receives the issued UID information.

    Payload

    Payload

    Type

    description

    uid

    string

    guest uid

    campaignKey

    string

    campaignKey

    Sample

    var messageCallback = {
            ON_UID_ISSUED: (payload) => {
                //If uid is not stored in localStorage, or the stored uid is different, store it with key name 'uid'
                const storedUid = localStorage.getItem('shoplive_uid');
                if (storedUid === null || storedUid !== payload.uid) {
                    localStorage.setItem('shoplive_uid', payload.uid);
                    console.log('shoplive_uid updated:', payload.uid);
                } else {
                    console.log('shoplive_uid is the same, no update needed.');
                }
            },
    }
    cloud.shoplive.init({ accessKey: "ACCESS_KEY", messageCallback: messageCallback });


    What's Next