HSBeacon
Objective-C
@interface HSBeacon : NSObject
Swift
class HSBeacon : NSObject
HSBeacon provides the APIs necessary to display the Beacon SDK. It allows you
to open the Beacon from the current view controller on screen, or a specific
view controller of your choice.
Opening the Beacon From The Current View Controller
The Beacon SDK requires an HSBeaconSettings object, which can be initialized
using your Beacon ID.
HSBeaconSettings *settings = [[HSBeaconSettings alloc] initWithBeaconId:@"beacon-id"];
[HSBeacon openBeacon:settings];
Authenticating Users
Authenticating with Beacon is optional, but if you have information you’d like
to associate with users, you can do so using HSBeaconUser and the login:
method before showing the Beacon.
HSBeaconUser *user = [[HSBeaconUser alloc] init];
user.email = self.emailTextField.text;
user.name = self.nameTextField.text;
[HSBeacon login:user];
HSBeaconSettings *settings = [[HSBeaconSettings alloc] initWithBeaconId:@"beacon-id"];
[HSBeacon openBeacon:settings];
-
Opens the Beacon SDK from the current view controller.
Note
Displays Beacon from the application delegate’s window root view controller.
Declaration
Objective-C
+ (void)openBeacon:(nonnull HSBeaconSettings *)settings;Swift
class func open(_ settings: HSBeaconSettings)Parameters
settingsThe Beacon settings from which to load Beacon.
-
Opens the Beacon SDK from the current view controller, using a signature.
Note
Displays Beacon from the application delegate’s window root view controller.
Declaration
Objective-C
+ (void)openBeacon:(nonnull HSBeaconSettings *)settings signature:(nonnull NSString *)signature;Swift
class func open(_ settings: HSBeaconSettings, signature: String)Parameters
settingsThe Beacon settings from which to load Beacon.
signatureThe signature to provide, if you are using secure mode.
-
Opens the Beacon SDK from a specific view controller. The Beacon view controller will be presented as a modal.
Declaration
Objective-C
+ (void)openBeacon:(nonnull HSBeaconSettings *)settings fromViewController:(nonnull UIViewController *)viewController;Swift
class func open(_ settings: HSBeaconSettings, from viewController: UIViewController)Parameters
settingsThe Beacon settings from which to load Beacon.
viewControllerThe view controller to display Beacon from.
-
Opens the Beacon SDK from a specific view controller. The Beacon view controller will be presented as a modal.
Declaration
Objective-C
+ (void)openBeacon:(nonnull HSBeaconSettings *)settings fromViewController:(nonnull UIViewController *)viewController signature:(nonnull NSString *)signature;Swift
class func open(_ settings: HSBeaconSettings, from viewController: UIViewController, signature: String)Parameters
settingsThe Beacon settings from which to load Beacon.
viewControllerThe view controller to display Beacon from.
signatureThe signature to provide, if you are using secure mode.
-
Hides the SDK modal window if present. Useful for when the app is returning from the background.
Declaration
Objective-C
+ (void)dismissBeacon:(void (^_Nullable)(void))completion;Swift
class func dismiss(_ completion: (() -> Void)? = nil) -
Deprecated
Please use HSBeacon.identify instead
Signs in with a Beacon user. This gives Beacon access to the user’s name, email address, and signature.
Declaration
Objective-C
+ (nonnull instancetype)login:(nonnull HSBeaconUser *)user;Swift
class func login(_ user: HSBeaconUser) -> SelfParameters
userThe Beacon user to login
-
Signs in with a Beacon user. This gives Beacon access to the user’s name, email address, and signature.
Declaration
Objective-C
+ (void)identify:(nonnull HSBeaconUser *)user;Swift
class func identify(_ user: HSBeaconUser)Parameters
userThe Beacon user to identify
-
Returns the current user, providing they are signed in.
Declaration
Objective-C
+ (HSBeaconUser *_Nullable)currentUser;Swift
class func currentUser() -> HSBeaconUser? -
Logs the current Beacon user out and clears out their information from local storage.
Declaration
Objective-C
+ (void)logout;Swift
class func logout() -
Programmatically change the suggestted articles displayed. If the Beacon is visible, the change will take place right away. Otherwise, the article data will change on the next open.
Passing in an empty array will restore the default list.
Declaration
Objective-C
+ (void)suggest:(nonnull NSArray<NSString *> *)articleIds;Swift
class func suggest(_ articleIds: [String])Parameters
articleIdsAn array of article ids to override suggestions
-
Programmatically change the suggestted items displayed. This implementation accepts either
HSBeaconArticleSuggestionorHSBeaconLinkSuggestionobjects in the array.If the Beacon is visible the change will take place right away. Otherwise, the article data will change on the next open.
Passing in an empty array will restore the default list.
Declaration
Objective-C
+ (void)suggestWithItems: (nonnull NSArray<id<HSBeaconSuggestionItem>> *)suggestions;Parameters
suggestionsAn array of HSBeaconArticleSuggestion or HSBeaconLinkSuggestion objects
-
Initializes push notifications for the Beacon SDK. This should be called if you intend to receive push notifications with a manual setup.
Declaration
Objective-C
+ (void)initializeBeaconPushNotificationSupport;Swift
class func initializeBeaconPushNotificationSupport() -
+initializeAutomaticPushNotificationHandlingWithMethodSwizzling:overrideUserNotificationCenterDelegate: Initializes automatic push notification handling for the Beacon SDK.
This will wrap the following methods on UIApplicationDelegage with method swizzling:
application:didReceiveRemoteNotification: application:didRegisterForRemoteNotificationsWithDeviceToken: application:didFailToRegisterForRemoteNotificationsWithError:
In addition, this wraps all of methods on UNUserNotificationCenterDelegate.
Declaration
Objective-C
+ (void)initializeAutomaticPushNotificationHandlingWithMethodSwizzling: (BOOL)methodSwizzling overrideUserNotificationCenterDelegate: (BOOL)overrideDelegate;Swift
class func initializeAutomaticPushNotificationHandling(withMethodSwizzling methodSwizzling: Bool, overrideUserNotificationCenterDelegate overrideDelegate: Bool)Parameters
methodSwizzlingWhether to override push notification methods on the App Delegate.
overrideDelegateWhether to override
UNUserNotificationCenter‘s delegate method for automatic handling of push notifications. -
This lets Beacon know about the user’s notification token, so the Beacon backend can send push notifications on behalf of the app. You only need to call this for manual push notification handling.
Declaration
Objective-C
+ (void)setDeviceToken:(nonnull NSData *)deviceToken;Swift
class func setDeviceToken(_ deviceToken: Data) -
This lets Beacon know that a potential device token is not forthcoming, so dependent processes can continue. You only need to call this for manual push notification handling.
Declaration
Objective-C
+ (void)failedToRegisterForRemoteNotificationsWithError: (nonnull NSError *)error;Swift
class func failedToRegisterForRemoteNotificationsWithError(_ error: Error) -
Checks whether a given push notification came from Help Scout. You should call this method before calling
handlePushNotification:.Declaration
Objective-C
+ (BOOL)isBeaconPushNotification:(nonnull NSDictionary *)userInfo;Swift
class func isBeaconPushNotification(_ userInfo: [AnyHashable : Any]) -> Bool -
Handles a Beacon push notification. If the user info dictionary does not match the expected format, this method does nothing.
Note
Displays Beacon from the application delegate’s window root view controller.
Declaration
Objective-C
+ (void)handlePushNotification:(nonnull NSDictionary *)userInfo beaconSettings:(nonnull HSBeaconSettings *)settings;Swift
class func handlePushNotification(_ userInfo: [AnyHashable : Any], beaconSettings settings: HSBeaconSettings)Parameters
userInfoThe user info payload from the notification.
settingsThe Beacon settings from which to load Beacon.
-
Handles a Beacon push notification. If the user info dictionary does not match the expected format, this method does nothing.
Declaration
Objective-C
+ (void)handlePushNotification:(nonnull NSDictionary *)userInfo beaconSettings:(nonnull HSBeaconSettings *)settings viewController:(nonnull UIViewController *)viewController;Swift
class func handlePushNotification(_ userInfo: [AnyHashable : Any], beaconSettings settings: HSBeaconSettings, viewController: UIViewController)Parameters
userInfoThe user info payload from the notification.
settingsThe Beacon settings from which to load Beacon.
viewControllerThe view controller to display Beacon from.
-
Handles a Beacon push notification. If the user info dictionary does not match the expected format, this method does nothing.
Note
Displays Beacon from the application delegate’s window root view controller.
Declaration
Objective-C
+ (void)handlePushNotification:(nonnull NSDictionary *)userInfo beaconSettings:(nonnull HSBeaconSettings *)settings signature:(NSString *_Nullable)signature;Swift
class func handlePushNotification(_ userInfo: [AnyHashable : Any], beaconSettings settings: HSBeaconSettings, signature: String?)Parameters
userInfoThe user info payload from the notification.
settingsThe Beacon settings from which to load Beacon.
signatureThe signature to provide, if you are using secure mode.
-
Handles a Beacon push notification. If the user info dictionary does not match the expected format, this method does nothing.
Declaration
Objective-C
+ (void)handlePushNotification:(nonnull NSDictionary *)userInfo beaconSettings:(nonnull HSBeaconSettings *)settings viewController:(nonnull UIViewController *)viewController signature:(NSString *_Nullable)signature;Swift
class func handlePushNotification(_ userInfo: [AnyHashable : Any], beaconSettings settings: HSBeaconSettings, viewController: UIViewController, signature: String?)Parameters
userInfoThe user info payload from the notification.
settingsThe Beacon settings from which to load Beacon.
viewControllerThe view controller to display Beacon from.
signatureThe signature to provide, if you are using secure mode.
-
Determines whether or not a push notification should be shown to the user. The
completionHandler will only be called in the case thatUNNotfication` is a Beacon notification.Declaration
Objective-C
+ (void)handleWillPresentNotification:(nonnull UNNotification *)notification withCompletionHandler: (nonnull void (^)(UNNotificationPresentationOptions)) completionHandler;Swift
class func handleWillPresent(_ notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void)Parameters
notificationThe UNNotification received by the UNUserNotificationCenterDelegate
completionHandlerThe completion block passed to the UNUnserNotificationCenterDelegate
-
Opens the Beacon window to search results for the provided string.
Note
Displays Beacon from the application delegate’s window root view controller.
Declaration
Objective-C
+ (void)search:(nonnull NSString *)text beaconSettings:(nonnull HSBeaconSettings *)settings;Swift
class func search(_ text: String, beaconSettings settings: HSBeaconSettings)Parameters
textThe text to search with
settingsThe Beacon settings from which to load Beacon.
-
Opens the Beacon window to search results for the provided string.
Declaration
Objective-C
+ (void)search:(nonnull NSString *)text beaconSettings:(nonnull HSBeaconSettings *)settings viewController:(nonnull UIViewController *)viewController;Swift
class func search(_ text: String, beaconSettings settings: HSBeaconSettings, viewController: UIViewController)Parameters
textThe text to search with
settingsThe Beacon settings from which to load Beacon.
viewControllerThe view controller to display Beacon from.
-
Opens the Beacon window to search results for the provided string.
Note
Displays Beacon from the application delegate’s window root view controller.
Declaration
Objective-C
+ (void)search:(nonnull NSString *)text beaconSettings:(nonnull HSBeaconSettings *)settings signature:(NSString *_Nullable)signature;Swift
class func search(_ text: String, beaconSettings settings: HSBeaconSettings, signature: String?)Parameters
textThe text to search with
settingsThe Beacon settings from which to load Beacon.
signatureThe signature to provide, if you are using secure mode.
-
Opens the Beacon window to search results for the provided string.
Declaration
Objective-C
+ (void)search:(nonnull NSString *)text beaconSettings:(nonnull HSBeaconSettings *)settings viewController:(nonnull UIViewController *)viewController signature:(NSString *_Nullable)signature;Swift
class func search(_ text: String, beaconSettings settings: HSBeaconSettings, viewController: UIViewController, signature: String?)Parameters
textThe text to search with
settingsThe Beacon settings from which to load Beacon.
viewControllerThe view controller to display Beacon from.
signatureThe signature to provide, if you are using secure mode.
-
Navigates to a specific screen. Available routes are: “/” - welcome screen “/ask/message/” - message screen “/docs/search?query=help” - this is the same as the HSBeacon search method
Note
Displays Beacon from the application delegate’s window root view controller.
Declaration
Objective-C
+ (void)navigate:(nonnull NSString *)route beaconSettings:(nonnull HSBeaconSettings *)settings;Swift
class func navigate(_ route: String, beaconSettings settings: HSBeaconSettings)Parameters
routeThe screen to navigate to - “/”, “/ask/message”, “/previous-messages”, or “/docs/search?query=help”
settingsThe Beacon settings from which to load Beacon.
-
Navigates to a specific screen. Available routes are: “/” - welcome screen “/ask/message/” - message screen “/docs/search?query=help” - this is the same as the HSBeacon search method
Declaration
Objective-C
+ (void)navigate:(nonnull NSString *)route beaconSettings:(nonnull HSBeaconSettings *)settings viewController:(nonnull UIViewController *)viewController;Swift
class func navigate(_ route: String, beaconSettings settings: HSBeaconSettings, viewController: UIViewController)Parameters
routeThe screen to navigate to - “/”, “/ask/message”, “/previous-messages”, or “/docs/search?query=help”
settingsThe Beacon settings from which to load Beacon.
viewControllerThe view controller to display Beacon from.
-
Navigates to a specific screen. Available routes are: “/” - welcome screen “/ask/message/” - message screen “/docs/search?query=help” - this is the same as the HSBeacon search method
Note
Displays Beacon from the application delegate’s window root view controller.
Declaration
Objective-C
+ (void)navigate:(nonnull NSString *)route beaconSettings:(nonnull HSBeaconSettings *)settings signature:(NSString *_Nullable)signature;Swift
class func navigate(_ route: String, beaconSettings settings: HSBeaconSettings, signature: String?)Parameters
routeThe screen to navigate to - “/”, “/ask/message”, “/previous-messages”, or “/docs/search?query=help”
settingsThe Beacon settings from which to load Beacon.
signatureThe signature to provide, if you are using secure mode.
-
Navigates to a specific screen. Available routes are: “/” - welcome screen “/ask/message/” - message screen “/docs/search?query=help” - this is the same as the HSBeacon search method
Declaration
Objective-C
+ (void)navigate:(nonnull NSString *)route beaconSettings:(nonnull HSBeaconSettings *)settings viewController:(nonnull UIViewController *)viewController signature:(NSString *_Nullable)signature;Swift
class func navigate(_ route: String, beaconSettings settings: HSBeaconSettings, viewController: UIViewController, signature: String?)Parameters
routeThe screen to navigate to - “/”, “/ask/message”, “/previous-messages”, or “/docs/search?query=help”
settingsThe Beacon settings from which to load Beacon.
viewControllerThe view controller to display Beacon from.
signatureThe signature to provide, if you are using secure mode.
-
You can use this method to open a specific Docs Article within Beacon, using the Article’s ID.
Note
Displays Beacon from the application delegate’s window root view controller.
Declaration
Objective-C
+ (void)openArticle:(nonnull NSString *)articleId beaconSettings:(nonnull HSBeaconSettings *)settings;Swift
class func openArticle(_ articleId: String, beaconSettings settings: HSBeaconSettings)Parameters
articleIdThe id of the article to open up
settingsThe Beacon settings from which to load Beacon.
-
You can use this method to open a specific Docs Article within Beacon, using the Article’s ID.
Declaration
Objective-C
+ (void)openArticle:(nonnull NSString *)articleId beaconSettings:(nonnull HSBeaconSettings *)settings viewController:(nonnull UIViewController *)viewController;Swift
class func openArticle(_ articleId: String, beaconSettings settings: HSBeaconSettings, viewController: UIViewController)Parameters
articleIdThe id of the article to open up
settingsThe Beacon settings from which to load Beacon.
viewControllerThe view controller to display Beacon from.
-
You can use this method to open a specific Docs Article within Beacon, using the Article’s ID.
Note
Displays Beacon from the application delegate’s window root view controller.
Declaration
Objective-C
+ (void)openArticle:(nonnull NSString *)articleId beaconSettings:(nonnull HSBeaconSettings *)settings signature:(NSString *_Nullable)signature;Swift
class func openArticle(_ articleId: String, beaconSettings settings: HSBeaconSettings, signature: String?)Parameters
articleIdThe id of the article to open up
settingsThe Beacon settings from which to load Beacon.
signatureThe signature to provide, if you are using secure mode.
-
You can use this method to open a specific Docs Article within Beacon, using the Article’s ID.
Declaration
Objective-C
+ (void)openArticle:(nonnull NSString *)articleId beaconSettings:(nonnull HSBeaconSettings *)settings viewController:(nonnull UIViewController *)viewController signature:(NSString *_Nullable)signature;Swift
class func openArticle(_ articleId: String, beaconSettings settings: HSBeaconSettings, viewController: UIViewController, signature: String?)Parameters
articleIdThe id of the article to open up
settingsThe Beacon settings from which to load Beacon.
viewControllerThe view controller to display Beacon from.
signatureThe signature to provide, if you are using secure mode.
-
Resets the contact form by clearing all of its fields, custom fields and attachments. If your Beacon is in Normal Mode, calling reset will clear all contact form fields, including name and email address.
If your Beacon is in Secure Mode, calling reset will not clear the customer’s name or email address. Those inputs will remain hidden.
Declaration
Objective-C
+ (void)reset;Swift
class func reset() -
Unavailable
HSBeacon cannot be created directly
-[HSBeacon init]is not available becauseHSBeaconcannot be created directly. Use theopenBeacon:methods to display the Beacon SDK.Declaration
Objective-C
- (nonnull instancetype)init;
View on GitHub
HSBeacon Class Reference