Article updated: February 18, 2022
Sparkcentral Messenger SDK
The Sparkcentral Messenger SDK enables you to implement a customizable, fully-featured messenger on your website or inside your mobile app. This allows any customer who visits your website or uses your app to contact your support team directly, eliminating the need for your users to use Facebook, WhatsApp, or any other messaging platform.
Create your channel
- Go to Admin settings, expand Channels & Business Hours and select Channels.
- Select Add Channel, and then select Sparkcentral Messenger.
- In the window that appears, enter a name for your messenger channel. This name should be unique and specific to the location of your messenger, such as a specific web page or your mobile app. Select Next. Note: If the window doesn't appear, make sure your browser allows pop-ups from Sparkcentral.
- Save the information provided in the window that appears. Note: This information is only displayed once, so it’s important to record it now.
Implement Messenger on your web site
Latest version
The latest version of our Web Messenger SDK can be found here:
https://cdn.sparkcentral.com/rtm/web/2.1.0/loader.json
The previous version can be found here: Sparkcentral Messenger SDK 1.25.7
Get started
The following steps are required to get Messenger to appear on your website.
- Paste the following code the end of the <head> section. (Make sure to copy it all!)
<script>
!function(s,c,o,i){var a,p,u,d=[],f=[];function e(){var n="2.1.0";try{if(!i)throw new Error(n);var e,t="https://cdn.sparkcentral.com/rtm/web/2.1.0/",r="sparkcentral";if((e="string"==typeof this.response?JSON.parse(this.response):this.response).url){var s=c.getElementsByTagName("script")[0],o=c.createElement("script");o.async=!0;var a=i.match(/([0-9]+)\.?([0-9]+)?\.?([0-9]+)?/),p=a&&a[1];if(a&&a[3])o.src=t+r+"."+i+".min.js";else{if(!(1<=p&&e["v"+p]))throw new Error(n);o.src=e["v"+p]}s.parentNode.insertBefore(o,s)}}catch(e){e.message===n&&console.error(e)}}s[o]={init:function(){a=arguments;var n={then:function(e){return f.push({type:"t",next:e}),n},catch:function(e){return f.push({type:"c",next:e}),n}};return n},on:function(){d.push(arguments)},render:function(){p=arguments},destroy:function(){u=arguments}},s.__onWebMessengerHostReady__=function(e){if(delete s.__onWebMessengerHostReady__,s[o]=e,a)for(var n=e.init.apply(e,a),t=0;t<f.length;t++){var r=f[t];n="t"===r.type?n.then(r.next):n.catch(r.next)}p&&e.render.apply(e,p),u&&e.destroy.apply(e,u);for(t=0;t<d.length;t++)e.on.apply(e,d[t])};var n=new XMLHttpRequest;n.addEventListener("load",e),n.open("GET","https://cdn.sparkcentral.com/rtm/web/2.1.0/loader.json",!0),n.responseType="json",n.send()}(window,document,"Sparkcentral","2");
</script>
- Paste the following init call code toward the end of the <body> section. This initializes a basic Web Messenger without any special customizations. (Customizations are described in the next section.)
- On the third line, insert your specific channel Integration ID. This is one of the pieces of text that is generated on channel creation.
- The region field must be set according to your Sparkcentral instance. Sparkcentral is available in the following regions:
Region identifiers Region Region identifier United States Leave unspecified European Union eu-1

<script>
var initPromise = Sparkcentral.init({
integrationId: 'Integration ID here',
// Leave unspecified for US region (default)
region: 'eu-1',
//This makes sure the customer is not able to create multiple conversations.
canUserCreateMoreConversations: false,
canUserSeeConversationList: false,
customColors: {
brandColor: '65758e',
conversationColor: '65758e',
actionColor: '65758e',
},
menuItems: {
imageUpload: true,
fileUpload: true,
shareLocation: true
},
fixedHeader: false,
customText: {
actionPaymentCompleted: 'Payment Completed',
actionPaymentError: 'An error occurred while processing the card. <br> Please try again or use a different card.',
actionPostbackError: 'An error occurred while processing your action. Please try again.',
clickToRetry: 'Message not delivered. Click to retry.',
clickToRetryForm: 'Form not submitted. Click anywhere on the form to retry.',
connectNotificationText: 'Sync your conversation and continue messaging us through your favorite app.',
connectNotificationSingleText: 'Be notified when you get a reply.',
conversationListHeaderText: 'My conversations',
conversationListPreviewAnonymousText: 'Someone',
conversationListPreviewCarouselText: '{user} sent a message',
conversationListPreviewFileText: '{user} sent a file',
conversationListPreviewFormText: '{user} sent a form',
conversationListPreviewFormResponseText: '{user} filled a form',
conversationListPreviewImageText: '{user} sent an image',
conversationListPreviewLocationRequestText: '{user} sent a location request',
conversationListPreviewUserText: 'You',
conversationListRelativeTimeJustNow: 'Just now',
conversationListRelativeTimeMinute: '1 minute ago',
conversationListRelativeTimeMinutes: '{value} minutes ago',
conversationListRelativeTimeHour: '1 hour ago',
conversationListRelativeTimeHours: '{value} hours ago',
conversationListRelativeTimeYesterday: 'Yesterday',
conversationListTimestampFormat: 'MM/DD/YY',
conversationTimestampHeaderFormat: 'MMMM D YYYY, h:mm A',
couldNotConnect: 'Offline. You will not receive messages.',
couldNotConnectRetry: 'Reconnecting...',
couldNotConnectRetrySuccess: "You're back online!",
couldNotLoadConversations: 'Couldn’t load conversations.',
emailChangeAddress: 'Change my email',
emailDescription: 'To be notified by email when you get a reply, enter your email address.',
emailFieldLabel: 'Email',
emailFieldPlaceholder: 'Your email address',
emailFormButton: 'Submit',
emailLinkingErrorMessage: 'Please submit a valid email address.',
fetchHistory: 'Load more',
fetchingHistory: 'Retrieving history...',
fileTooLargeError: 'Max file size limit exceeded ({size})',
fileTypeError: 'Unsupported file type.',
formErrorInvalidEmail: 'Email is invalid',
formErrorNoLongerThan: 'Must contain no more than ({characters}) characters',
formErrorNoShorterThan: 'Must contain at least ({characters}) characters',
formErrorUnknown: 'This doesn\'t look quite right',
formFieldSelectPlaceholderFallback: 'Choose one...',
frontendEmailChannelDescription: 'To talk to us using email just send a message to our email address and we\'ll reply shortly:',
headerText: 'How can we help?',
imageClickToReload: 'Click to reload image.',
imageClickToView: 'Click to view {size} image.',
imagePreviewNotAvailable: 'Preview not available.',
inputPlaceholder: 'Type a message...',
inputPlaceholderBlocked: 'Complete the form above...',
introAppText: 'Message us below or from your favorite app.',
lineChannelDescription: 'To talk to us using LINE, scan this QR code using the LINE app and send us a message.',
linkChannelPageHeader: 'Sync your conversation',
linkError: 'An error occurred when attempting to generate a link for this channel. Please try again.',
locationNotSupported: 'Your browser does not support location services or it’s been disabled. Please type your location instead.',
locationSecurityRestriction: 'This website cannot access your location. Please type your location instead.',
locationSendingFailed: 'Could not send location',
locationServicesDenied: 'This website cannot access your location. Allow access in your settings or type your location instead.',
messageIndicatorTitlePlural: '({count}) New messages',
messageIndicatorTitleSingular: '({count}) New message',
messageRelativeTimeDay: '{value}d ago',
messageRelativeTimeHour: '{value}h ago',
messageRelativeTimeJustNow: 'Just now',
messageRelativeTimeMinute: '{value}m ago',
messageTimestampFormat: 'h:mm A',
messageDelivered: 'Delivered',
messageSeen: 'Seen',
messageSending: 'Sending...',
messengerChannelDescription: 'Connect your Facebook Messenger account to be notified when you get a reply and continue the conversation on Facebook Messenger.',
newConversationButtonText: 'New Conversation',
notificationSettingsChannelsDescription: 'Sync this conversation by connecting to your favorite messaging app to continue the conversation your way.',
notificationSettingsChannelsTitle: 'Other Channels',
notificationSettingsConnected: 'Connected',
notificationSettingsConnectedAs: 'Connected as {username}',
prechatCaptureGreetingText: 'Hi there \nTo start off, we\'d like to know a little bit more about you:',
prechatCaptureNameLabel: 'Your name',
prechatCaptureNamePlaceholder: 'Type your name...',
prechatCaptureEmailLabel: 'Email',
prechatCaptureEmailPlaceholder: 'name@company.com',
prechatCaptureConfirmationText: 'Thanks for that! What can we help you with?',
prechatCaptureMailgunLinkingConfirmation: 'You\'ll be notified here and by email at {email} once we reply.',
sendButtonText: 'Send',
settingsHeaderText: 'Settings',
shareLocation: 'Location',
smsBadRequestError: 'We were unable to communicate with this number. Try again or use a different one.',
smsCancel: 'Cancel',
smsChangeNumber: 'Change my number',
smsChannelDescription: 'Connect your SMS number to be notified when you get a reply and continue the conversation over SMS.',
smsChannelPendingDescription: 'Check your messages at {number} to confirm your phone number.',
smsContinue: 'Send',
smsInvalidNumberError: 'Please submit a valid phone number.',
smsLinkCancelled: 'Link to {appUserNumber} was cancelled.',
smsLinkPending: 'Pending',
smsPingChannelError: 'There was an error sending a message to your number.',
smsSendText: 'Send me a text',
smsStartTexting: 'Start Texting',
smsTooManyRequestsError: 'A connection for that number was requested recently. Please try again in {minutes} minutes.',
smsTooManyRequestsOneMinuteError: 'A connection for that number was requested recently. Please try again in 1 minute.',
smsUnhandledError: 'Something went wrong. Please try again.',
syncConversation: 'Sync conversation',
tapToRetry: 'Message not delivered. Tap to retry.',
tapToRetryForm: 'Form not submitted. Tap anywhere on the form to retry.',
telegramChannelDescription: 'Connect your Telegram account to be notified when you get a reply and continue the conversation on Telegram',
uploadDocument: 'File',
uploadInvalidError: 'Invalid file',
uploadPhoto: 'Image',
uploadVirusError: 'A virus was detected in your file and it has been rejected',
unsupportedMessageType: 'Unsupported message type.',
unsupportedActionType: 'Unsupported action type.',
viberChannelDescription: 'Connect your Viber account to be notified when you get a reply and continue the conversation on Viber. To get started, scan the QR code using the Viber app.',
viberChannelDescriptionMobile: 'Connect your Viber account to be notified when you get a reply and continue the conversation on Viber. To get started, install the Viber app and tap Connect.',
viberQRCodeError: 'An error occurred while fetching your Viber QR code. Please try again.',
wechatChannelDescription: 'Connect your WeChat account to be notified when you get a reply and continue the conversation on WeChat. To get started, scan this QR code using the WeChat app.',
wechatChannelDescriptionMobile: 'Connect your WeChat account to be notified when you get a reply and continue the conversation on WeChat. To get started, save this QR code image and upload it in the <a href=\'weixin://dl/scan\'>QR code scanner</a>.',
wechatQRCodeError: 'An error occurred while fetching your WeChat QR code. Please try again.',
whatsappChannelDescriptionDesktop: 'Sync your account to WhatsApp by scanning the QR code or clicking the link below.\nThen, send the pre-populated message to validate the sync request. (Your code: {{code}}).',
whatsappChannelDescriptionMobile: 'Sync your account to WhatsApp by clicking the link below.\nThen, send the pre-populated message to validate the sync request. (Your code: {{code}}).',
whatsappLinkingError: 'An error occurred while fetching your WhatsApp linking information. Please try again.'
}
}).then(function() {
// Your code after init is complete
});
</script>

Opens the conversation widget (NOOP when embedded)
Sparkcentral.open();
Closes the conversation widget (NOOP when embedded)
Sparkcentral.close();
Tells if the widget is currently opened or closed.
Sparkcentral.isOpened();
Logs a user in the Web Messenger, retrieving the conversations the user already had on other browser sessions and/or devices. Note that you don't need to call this after `init` if you already passed the external id and jwt as arguments in the call to `init`, in which case it's done internally as part of the initialization sequence. This returns a `Promise` that resolves when the Web Messenger is ready again.
Sparkcentral.login('externa-id', 'some-jwt');
Logs out the current user and reinitialize the widget with an anonymous user. This returns a promise that resolves when the Web Messenger is ready again.
Sparkcentral.logout();
Destroys the Web Messenger and makes it disappear. The Web Messenger has to be reinitialized with `init` to be working again because it also clears up the integration id from the Web Messenger. It will also unbind all listeners you might have with `Sparkcentral.on`.
Sparkcentral.destroy();
Sends a message to the targeted conversation on the user's behalf.
Sparkcentral.sendMessage(
{
type: 'text',
text: 'hello'
},
'<conversation-id>'
);
// OR
Sparkcentral.sendMessage('hello', '<conversation-id>');
Customize Web Messenger options
Several options are available for customizing your Web Messenger. The following is an example of a fully customized Web Messenger. Every option used is documented following the code snippet.

Sparkcentral.init({
integrationId: '<integration-id>',
// Leave unspecified for US region (default)
region: 'eu-1',
// For authenticated mode
jwt: 'your_jwt',
userId: 'user_id',
locale: 'en-US',
customColors: {
brandColor: '65758e',
conversationColor: '65758e',
actionColor: '65758e',
},
menuItems: {
imageUpload: true,
fileUpload: true,
shareLocation: true
},
fixedIntroPane: false,
prechatCapture: {
enabled: true,
fields: [
{
type: 'email',
name: 'email',
label: 'Email',
placeholder: 'your@email.com'
},
{
type: 'text',
name: 'company-website',
label: 'Company website',
placeholder: 'mycompany.com'
},
{
type: 'select',
name: 'company-size',
label: 'Company size',
placeholder: 'Choose a number...',
options: [
{
name: '1-10',
label: '1-10 employees'
},
{
name: '11-50',
label: '11-50 employees'
},
{
name: '51+',
label: '51+ employees'
}
]
}
]
},
customText: {
actionPostbackError: 'An error occurred while processing your action. Please try again.',
clickToRetry: 'Message not delivered. Click to retry.',
connectNotificationText: 'Be notified inside your other apps when you get a reply.',
connectNotificationSingleText: 'Be notified when you get a reply.',
connectNotificationSingleButtonText: 'Turn on <name> notifications',
connectNotificationOthersText: 'others',
conversationTimestampHeaderFormat: 'MMMM D YYYY, h:mm A',
fetchHistory: 'Load more',
fetchingHistory: 'Retrieving history...',
fileTooLargeError: 'Max file size limit exceeded ({size})',
fileTypeError: 'Unsupported file type.',
headerText: 'How can we help?',
imageClickToReload: 'Click to reload image.',
imageClickToView: 'Click to view {size} image.',
imagePreviewNotAvailable: 'Preview not available.',
inputPlaceholder: 'Type a message...',
introductionText: 'We\'re here to talk, so ask us anything!',
invalidFileError: 'Only images are supported. Choose a file with a supported extension (jpg, jpeg, png, gif, or bmp).',
locationNotSupported: 'Your browser does not support location services or it’s been disabled. Please type your location instead.',
locationSecurityRestriction: 'This website cannot access your location. Please type your location instead.',
locationSendingFailed: 'Could not send location',
locationServicesDenied: 'This website cannot access your location. Allow access in your settings or type your location instead.',
messageError: 'An error occurred while sending your message. Please try again.',
messageIndicatorTitlePlural: '({count}) New messages',
messageIndicatorTitleSingular: '({count}) New message',
messageRelativeTimeDay: '{value}d ago',
messageRelativeTimeHour: '{value}h ago',
messageRelativeTimeJustNow: 'Just now',
messageRelativeTimeMinute: '{value}m ago',
messageTimestampFormat: 'h:mm A',
messageSending: 'Sending...',
messageDelivered: 'Delivered',
prechatCaptureGreetingText: 'Hi there \nTo start off, we\'d like to know a little bit more about you:',
prechatCaptureConfirmationText: 'Thanks for that! What can we help you with?',
sendButtonText: 'Send',
settingsHeaderText: 'Settings',
shareLocation: 'Share location',
tapToRetry: 'Message not delivered. Tap to retry.',
unsupportedMessageType: 'Unsupported message type.',
unsupportedActionType: 'Unsupported action type.',
uploadDocument: 'Upload document',
uploadInvalidError: 'Invalid file',
uploadPhoto: 'Upload photo',
}
}).then(function() {
// Your code after init is complete
});
initPromise.then(function() {
// do something
});
// pass it around...
initPromise.then(function() {
//do something else
});
Options
The following general settings can be changed.
Option | Optional? | Default value | Description |
---|---|---|---|
integrationID | No | - | Your app/integration ID. |
region | Yes | - | The target region in which the app is located. |
jwt | Yes | - | The token to authenticate your communication with the server. |
userId | Yes | - | The user’s ID. |
authCode | Yes | - | An auth code for linking to an existing conversation. |
locale | Yes | en-US | The locale used for date formatting using the `-` format. See language codes and country codes. Note: The country part is optional, and if a country is either not recognized or not supported, the app falls back to the generic language. If the language isn’t supported, the app falls back to `en-US`. Note: This is only used for date formatting and doesn’t provide built-in translations for Web Messenger. |
soundNotificationEnabled | Yes | TRUE | Enables the sound notification for new messages. |
imageUploadEnabled | Yes | TRUE | Enables the image upload feature. |
embedded | Yes | FALSE | Tells the widget it is embedded (see following Embedded section). |
displayStyle | Yes | button | How the messenger appears on your website. Must be either button or tab. |
buttonIconUrl | Yes | - | When the displayStyle is "button", you can select your own button icon. The image must be at least 200 x 200 pixels in JPG, PNG, or GIF format. |
buttonWidth | Yes | 58px | When the displayStyle is "button", you have the option of specifying the button width. |
buttonHeight | Yes | 58px | When the displayStyle is "button", you have the option of specifying the button height. |
businessName | Yes | - | A custom business name. |
businessIconUrl | Yes | - | A custom business icon URL. The image must be at least 200 x 200 pixels and must be in JPG, PNG, or GIF format. |
backgroundImageUrl | Yes | - | A background image URL for the conversation. The image is tiled to fit the window. |
customColors | Yes | See following section | Colors used in the Web Messenger UI. |
customText | Yes | See the following example | Strings used in the Web Messenger UI. You can use these to either customize the text or translate it. Note: Some strings include variables (surrounded by {}), which must remain in your customized text. |
menuItems | Yes | See the following section | |
prechatCapture | Yes | See the following section |
Color options
You can give your Web Messenger a custom look by editing the following settings.
Option | Optional? | Default value | Description |
---|---|---|---|
brandColor | Yes | 65758e | This color is used in the messenger header and the button or tab in idle state. Must be a 3- or 6-character hexadecimal color. |
conversationColor | Yes | 0099ff | This color is used for customer messages, quick replies, and actions in the footer. Must be a 3- or 6-character hexadecimal color. |
actionColor | Yes | 0099ff | This color is used for calls-to-action inside your messages. Must be a 3- or 6-character hexadecimal color. |
Text options
Web Messenger has many text options to choose from. Here are a few examples.
Option | Default value if not used |
---|---|
actionPostbackError | An error occurred while processing your action. Please try again. |
clickToRetry | Message not delivered. Click to retry. |
connectNotificationText | Be notified inside your other apps when you get a reply. |
connectNotificationSingleText | Be notified when you get a reply. |
connectNotificationSingleButtonText | Turn on <name> notifications |
connectNotificationOthersText | others |
conversationTimestampHeaderFormat | MMMM D YYYY, h:mm A |
fetchHistory | Load more |
fetchingHistory | Retrieving history… |
headerText | How can we help? |
inputPlaceholder | Type a message… |
introductionText | We’re here to talk, so ask us anything! |
invalidFileError | Only images are supported. Choose a file with a supported extension (jpg, jpeg, png, gif, or bmp). |
locationNotSupported | Your browser does not support location services or it’s been disabled. Please type your location instead. |
locationSecurityRestriction | This website cannot access your location. Please type your location instead. |
locationSendingFailed | Could not send location |
locationServicesDenied | This website cannot access your location. Allow access in your settings or type your location instead. |
messageError | An error occurred while sending your message. Please try again. |
messageIndicatorTitlePlural | ({count}) New messages |
messageIndicatorTitleSingular | ({count}) New message |
messageRelativeTimeDay | {value}d ago |
messageRelativeTimeHour | {value}h ago |
messageRelativeTimeJustNow | Just now |
messageRelativeTimeMinute | {value}m ago |
messageTimestampFormat | h:mm A |
messageSending | Sending… |
messageDelivered | Delivered |
sendButtonText | Send |
settingsHeaderText | Settings |
tapToRetry | Message not delivered. Tap to retry. |
unsupportedMessageType | Unsupported message type. |
unsupportedActionType | Unsupported action type. |
uploadDocument | Upload document. |
uploadInvalidError | Invalid file. |
uploadPhoto | Upload photo. |
Menu options
Menu items can be enabled or disabled.
Option | Optional? | Default value | Description |
---|---|---|---|
imageUpload | Yes | TRUE | Enables the image upload menu item |
fileUpload | Yes | TRUE | Enables the file upload menu item |
shareLocation | Yes | TRUE | Enables the share location menu item |
Prechat capture option
This option allows you to have the Web Messenger automatically post a message to the user. You can implement a variety of messages. The following code snippet is the same as the one used in the earlier example.
prechatCapture: {
enabled: true,
fields: [
{
type: 'email',
name: 'email',
label: 'Email',
placeholder: 'your@email.com'
},
{
type: 'text',
name: 'company-website',
label: 'Company website',
placeholder: 'mycompany.com'
},
{
type: 'select',
name: 'company-size',
label: 'Company size',
placeholder: 'Choose a number...',
options: [
{
name: '1-10',
label: '1-10 employees'
},
{
name: '11-50',
label: '11-50 employees'
},
{
name: '51+',
label: '51+ employees'
}
]
}
]
}
Field | Information |
---|---|
name: ‘Name of the field’,
| |
Text | name: ‘Name of the field’,
label: ‘Label name’, placeholder: ‘Placeholder text here'” |
Select | This is the format in which multiple options are added:
options: [
{
name: ‘Name of the first option’,
|
Embedded mode option
You have the option to set up the Web Messenger in an embedded mode. This lets you choose where you want the widget to be visible.
The following example illustrates what you need to set it up.
Note that for embedded mode to work, you must set the parameter of embedded to true and call the Sparkcentral.render() function manually.
Sparkcentral.init({
integrationId: 'INTEGRATION_ID_HERE',
embedded: true,
region: 'eu-1'
}).then(() => {
// Your code after init is complete
}
Sparkcentral.render(document.getElementById('chat-container'));
JavaScript
This sample embeds the Sparkcentral messenger within a DOM element with the id “chat-container”. If you open the web page, you will notice that it is no longer showing a button on the bottom right, but it is visible in the container element.
Use Contact Attributes to save specific messenger data
You can store information about the webpage and the user by using the Contact Attributes feature. To enable this, do the following:
- On the Settings tab, expand Agent Workspace and select Contact Attributes.
- Find one of the premade Contact Attributes in the list and toggle it to Enabled.
Now, when a client contacts you via the Sparkcentral Messenger plugin, that specific data will be stored inside of a Contact Attribute.
Available Contact Attributes for the Web Messenger plugin- Browser Language
- First Name
- Last Name
- Page Domain
- Page Title
- Page URL
- User Id
Use shortcodes to create a rich messaging experience
Shortcodes are a useful way to create a beautiful messaging interface.
Available shortcodes
Element | Syntax | Example |
---|---|---|
Link button | %[]() | %[Button label](http://anyurl.com) |
Reply button | %[](reply:) | %[Button label](reply:PAYLOAD) |
Location request button | %[](location) | %[Button label](location) |
Image | ![]() |  |
Link button
By using multiple Link button shortcodes, you can send the user multiple links in one message. An example:
%[Link to Facebook](https://facebook.com)
%[Link to Twitter](https://twitter.com)
%[Link to LinkedIn](https://linkedin.com)
Reply button
By using multiple Reply button shortcodes under each other in one message, you can offer the user a choice. For example:
%[Sales](reply:Sales)
%[Support](reply:Support)
%[Engineering](reply:Engineering)
Location sharing button
This code allows you to ‘invite’ the user to share their location with you.
Images
You can send images and gifs using this shortcode.
Implement Messenger in your mobile app
A great way to integrate Sparkcentral into your processes is by incorporating our In-App Messenger. This is an SDK we created that our clients can implement on their apps.
Available platforms
- iOS
- Android
Get started
iOS
To use our SDK with your iOS application, you need to add it to your Xcode project.
Install the SDK dependency
Install CocoaPods.
CocoaPods is a dependency manager for Swift and Objective C Cocoa projects.
Run the following command in your terminal:
gem install cocoapods
Tell Xcode you are using this pod/dependancy.
To do so, create a file called podfile in the source folder of your project. In it, enter the following and save it:
Copyproject 'Location of your .xcproj file'
target 'YourApp' do
pod 'Sparkcentral'
endRun a command to tell Xcode to install the pod so you can use it.
In your terminal, navigate to the source folder of your project.
Type the following command in the terminal:
pod install
Navigate to your source folder and open Info.plist. In it, add the following keys and values and save it.
Copy<key>NSPhotoLibraryUsageDescription</key>
<string>${PRODUCT_NAME} will read your photo library to gather additional information</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>${PRODUCT_NAME} will write to your photo library to gather additional information</string>
<key>NSCameraUsageDescription</key>
<string>${PRODUCT_NAME} will use your camera to gather additional information</string>
Use the framework in your project
Objective C
Import the framework in your source code:
#import "Sparkcentral/Sparkentral.h"
Objective-C
The first function to run is the following . Your integration ID should be changed accordingly.
[Sparkcentral initWithSettings:[SKCSettings settingsWithIntegrationId:@"YOUR_INTEGRATION_ID"] completionHandler:^(NSError * _Nullable error, NSDictionary * _Nullable userInfo) {
// Your code after init is complete
}];
Swift
Sparkcentral.initWith(SKCSettings(integrationId: "YOUR_INTEGRATION_ID")) { (error: Error?, userInfo: [AnyHashable : Any]?) in
// Your code after init is complete
}
Class reference
Download the class references for iOS and Android: https://www.hootsuite.com/uploads/downloadable-assets/sparkcentral-API-mobile-class-references.6.30.2021.zip.
Android
Link the SDK dependency using Gradle. You can find the Sparkcentral SDK dependency on mavencentral (https://repo.maven.apache.org/maven2).
For more information about Gradle and declaring publicly-available repositories, see https://docs.gradle.org/current/userguide/declaring_repositories.html#sec:declaring_public_repository
Use the SDK
Initialize from your Application class. Add the following lines of code to your onCreate
method on your Application class:
Sparkcentral.init(this, new Settings("YOUR_INTEGRATION_ID"), new SparkcentralCallback() {
@Override
public void run(Response response) {
// Your code after init is complete
}
});
Make sure to replace YOUR_INTEGRATION_ID with the integration ID you generate when adding a new Web Messenger channel.
If you don’t have an Application class, you must create one to make sure Sparkcentral is always initialized properly.
Class reference
Download the class references for iOS and Android: https://www.hootsuite.com/uploads/downloadable-assets/sparkcentral-API-mobile-class-references.6.30.2021.zip.
Can't find what you're looking for? We're here to help