---
schema_version: "1"
id: 5b5c7061769fe94566f7ddce8b2bd90868de923b55fd69aee9cae07b52fd9b88
title: Business Hours for iOS
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/service-cloud/messaging-in-app/guides/ios-business-hours.md
canonical_url: https://developer.salesforce.com/docs/service/messaging-in-app/guide/ios-business-hours.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 5f8b723eb05160a1c8f83678110e5caece0f6cbe5c93190451aa7077759f33cf
products:
  - Enhanced In-App Chat
  - Service Cloud Developer Content
---
# 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](https://help.salesforce.com/s/articleView?id=service.miaw_business_hours.htm).


**important:** This feature requires version 1.3.0 or later of the Enhanced In-App Chat SDK.


This article applies to the following implementations:

| UI SDK | Core SDK |
| :----: | :------: |
|   ✅   |    ✅    |


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.

**note:** 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](https://developer.salesforce.com/docs/service/messaging-in-app/guide/ios-ui-sdk.md) or [Build a Core SDK App](https://developer.salesforce.com/docs/service/messaging-in-app/guide/ios-core-sdk.md) for more information.

```swift
// Create a core client from a config
let coreClient = CoreFactory.create(withConfig: config)

// Get business hours info
coreClient.retrieveBusinessHours { (businessHoursInfo, error) in

    // Determine whether we're currently within business hours
    if businessHoursInfo?.isWithinBusinessHours(comparisonTime: nil) ?? true {
        // TO DO: Handle when we're within business hours
    } else {
        // TO DO: Handle when we're outside of business hours
    }

    // Alternatively, you can inspect the business hours info.
    // For instance, get specific business hours time periods
    // using the businessHoursInfo.businessHours list.
}
```
