Business Hours for iOS
If you’ve set up business hours in Salesforce, use the retrieveBusinessHours method to check for business hours and handle things accordingly. For instance, you can hide the chat button outside of business hours. When using the UI SDK, customers see a banner in the chat window when it’s outside of business hours.
To configure business hours for your deployment, see Set Business Hours in Enhanced Chat.
This feature requires version 1.3.0 or later of the Enhanced In-App Chat SDK.
This article applies to the following implementations:
Retrieve the business hours from the core client object using the retrieveBusinessHours method, and then determine how to proceed based on that information. This method returns the business hours over the next 24 hours. You can use the helper method isWithinBusinessHours to determine whether a time is within business hours; specify nil for the comparisonTime to use the current time.
This sample requires the configuration object that you created when setting up the UI SDK or the Core SDK. See Build a UI SDK App or Build a Core SDK App for more information.
1// Create a core client from a config
2let coreClient = CoreFactory.create(withConfig: config)
3
4// Get business hours info
5coreClient.retrieveBusinessHours { (businessHoursInfo, error) in
6
7 // Determine whether we're currently within business hours
8 if businessHoursInfo?.isWithinBusinessHours(comparisonTime: nil) ?? true {
9 // TO DO: Handle when we're within business hours
10 } else {
11 // TO DO: Handle when we're outside of business hours
12 }
13
14 // Alternatively, you can inspect the business hours info.
15 // For instance, get specific business hours time periods
16 // using the businessHoursInfo.businessHours list.
17}