6️Callbacks

List of available callbacks:

1. Imported callback

This callback will be executed after the contacts are imported.

SocialInviter.set({
    authUrl: {
        development: 'http://127.0.0.1:5501/oauth.html',
        stage: 'https://stage.yourdomain.com/oauth.html',
    },
    style: {
        'font-family': 'Arial'
    },
    callbacks: {
        imported: (service, profile, addressbook) => {
            console.log('service', service);
            console.log('addressbook', addressbook);
        }
    }
});

2. Connect callback

SocialInviter.set({
    authUrl: {
        development: 'http://127.0.0.1:5501/oauth.html',
        stage: 'https://stage.yourdomain.com/oauth.html',
    },
    style: {
        'font-family': 'Arial'
    },
    callbacks: {
        connect: (service, profile) => {
            if (service === "email") {
                // Your logic here for continue button click
                console.log(service, profile.email);
            } else {
                // Your logic here
            }
        }
    }
});

3. Proceed callback

This callback will be executed once a user clicks on the "Proceed" button on the contacts screen

SocialInviter.set({
    authUrl: {
        development: 'http://127.0.0.1:5501/oauth.html',
        stage: 'https://stage.yourdomain.com/oauth.html',
    },
    style: {
        'font-family': 'Arial'
    },
    callbacks: {
        proceed: (service, profile, addressbook, selected) => {
            console.log('service', service);
            console.log('addressbook', addressbook);
        }
    }
});

4. Send callback

This callback will be executed after the user clicks the "Send" button on the mail screen

SocialInviter.set({
    authUrl: {
        development: 'http://127.0.0.1:5501/oauth.html',
        stage: 'https://stage.yourdomain.com/oauth.html',
    },
    style: {
        'font-family': 'Arial'
    },
    callbacks: {
        send: (service, profile, addressbook, selected, successObjects, errorObjects) => {
            // Your logic here
        }
    }
});

5. Service invite button callback

SocialInviter.set({
    authUrl: {
        development: 'http://127.0.0.1:5501/oauth.html',
        stage: 'https://stage.yourdomain.com/oauth.html',
    },
    style: {
        'font-family': 'Arial'
    },
    callbacks: {
        button: (product, service, e, profile, addressbook, selected) => {
            // Your logic here
        }
    }
});

6. Full example

You can use imported, proceed, send callback methods to receive the callback execution.

SocialInviter.set({
    authUrl: {
        development: 'http://127.0.0.1:5501/oauth.html',
        stage: 'https://stage.yourdomain.com/oauth.html',
    },
    style: {
        'font-family': 'Arial'
    },
    callbacks: {
        imported: (service, profile, addressbook) => {
            console.log('service', service);
            console.log('addressbook', addressbook);
        },
        proceed: (service, profile, addressbook, selected) => {
            console.log('service', service);
            console.log('addressbook', addressbook);
        },
        send: (service, profile, addressbook, selected, successObjects, errorObjects) => {
            console.log('service', service);
        },
        connect: (service, profile) => {
            if (service === "email") {
                // Your logic here for continue button click
                console.log(service, profile.email);
            } else {
                // Your logic here
            }
        },
        button: (product, service, e, profile, addressbook, selected) => {
            // Your logic here
        }
    }
});

Last updated