Recent searches


No recent searches

iOS chat notifications not working when app is in the foreground



Posted Dec 03, 2021

Hi there,

I hope someone can help me here. We have integrated the iOS chat v2 SDK and everything is working apart from one flow.

The notifications when an agent sends a message is working until we open up the view and connect to the chat view. If we dismiss the chat view but stay in the application no more push notifications are sent to the device therefore no new notifications come until we background the application or go back to the chat view without being prompted to.

I feel it must have something to do with the session still being open but there's nothing in the docs talking about how to handle this from what I can see.

Does anyone have any advice on what we might be doing wrong here?

Any help is greatly appreciated!


0

3

3 comments

image avatar

Mick O'Donnell

Zendesk Product Manager

Hi Jamie,

Have you enabled in-app push notifications in your app as described here?

Allow the notifications to be shown in your app by implementing the UNUserNotificationCenterDelegate method.

Swift

import UserNotifications
func userNotificationCenter(_ center: UNUserNotificationCenter,                           willPresent notification: UNNotification,                           withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {   completionHandler([.alert, .sound, .badge])}

Objective-C

#import <UserNotifications/UserNotifications.h>
// In AppDelegate.h conform AppDelegate to UNUserNotificationCenterDelegate@interface AppDelegate : UIResponder <UIApplicationDelegate, UNUserNotificationCenterDelegate>- (void)userNotificationCenter:(UNUserNotificationCenter *)center          willPresentNotification:(UNNotification *)notification        withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler {           completionHandler(UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionSound | UNNotificationPresentationOptionBadge);}

0


image avatar

Greg Katechis

Zendesk Developer Advocacy

In addition to Mick's notes above, I had another customer raise this issue recently and he found a solution! I'll paste his response to me here, let us know if the combination of these two things helps!

Needed to disconnect the session when chat controller is dismissed.

The following piece of code did the trick:

override func viewWillDisappear(_ animated: Bool) {
if let connectionProvider = Chat.connectionProvider {
connectionProvider.disconnect()
}
super.viewWillDisappear(animated)
}

0


Hi Greg, where would we be able to do this? The chat view controller is created with `Messaging.instance.buildUI` which returns a plain UIViewController - the superclass is abstracted away, we cannot subclass it (and even if we could our subclass wouldn't be initiated with the above method call). 

Thanks

0


Please sign in to leave a comment.

Didn't find what you're looking for?

New post