Skip to main content

Chat

If needed, your users can chat with you to provide you more details about their reported bugs, crashes or feedback. You will be able to fix issues faster and make your customers happier.

Enable

Once your user is registered with Shake, the chat feature is enabled automatically. Each ticket they send you will be a separate conversation.

This feature is tightly integrated with and follows the lifecycle of your User registration, which means that calling Shake.unregisterUser also disconnects the current user from chat and they won't receive any new messages until registered again.

Notifications

Shake will notify your user when you send them a new message from the Shake dashboard.

note

Shake supports only local notifications. That means that your users won't get notified about new messages when your app is in the background.

To show notifications to your users, you must request a permission from them. Find a proper place and time where you will want to present that native alert dialog.

To remain customizable and minimally intrusive to an existing notification logic of your app, Shake requires additional setup. Use Shake.report(center: UNUserNotificationCenter ...) methods to delegate notification presentation logic to Shake.

AppDelegate.swift
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
UNUserNotificationCenter.current().delegate = self
Shake.start(clientId: "your_client_id", clientSecret: "your_client_secret")
return true
}
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
if response.notification.request.content.categoryIdentifier.contains(SHKNotificationCategoryIdentifierDomain) {
Shake.report(center, didReceive: response, withCompletionHandler: completionHandler)
return;
}
completionHandler()
}
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
if notification.request.content.categoryIdentifier.contains(SHKNotificationCategoryIdentifierDomain) {
Shake.report(center, willPresent: notification, withCompletionHandler: completionHandler)
return;
}
completionHandler([.badge, .sound, .alert])
}
}

With the setup like above, notifications that originate from Shake are handled by Shake, and all other notifications are handled by your app.

note

If you need to, you can skip showing notifications by simply not reporting anything to Shake, or by stubbing the received native completion handler with your own set of UNNotificationPresentationOptions which Shake will respect.

Unread messages

If you want to show number of unread chat messages somewhere in your app, you can set the unread messages listener. The listener is called immediately when set and on each change in the number of unread messages for a registered user:

ViewController.swift
Shake.unreadMessagesListener = { count in
// Update number in your text element
}

To remove the unread messages listener, use Shake.unreadMessagesListener = nil.