For some use cases, you might want to get the entire address book before the user has a chance to review and select the contacts that they want to share with your app.
If your app has a social networking componenet, you’ll need the entire address book so you can look for matches in your own network. Or you may have a CRM and want the user’s address book to be accessible all the time. Or it might be because you’d rather display the contacts in your own UI.
Whatever the use case, you can accomplish it by doing these two things:
- Close the widget before the contacts selection screen shows, and
- Accept the contacts data in your application. You can do this with either a javascript callback or having our widget post the data directly to your backend via webhook.
<script src="https://api.cloudsponge.com/widget/localhost-only.js"></script>
<script>
cloudsponge.init({
// suppress the contacts list UI so that the user doesn't have a chance to select from their address book.
skipContactsDisplay: true,
// receive the contacts into your javascript and do what you like with them.
beforeDisplayContacts: function(contacts, source, owner) {
$('#exampleContacts').text(JSON.stringify(contacts.slice(0,10)));
},
// OR post the data to the given URL directly:
webhooks: {
// the entire address book will be posted to this endpoint:
beforeDisplayContacts: "http://example.org/contacts"
}
})
</script>