You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I have a notification service extension which is working fine when i receive a notification, but when i access the channelController, it gives me this error here only in this class.
"The operation couldn’t be completed. (StreamChat.ClientError.MissingConnectionId error 1.)".
How can i get the channelController and get it to work here in this extension didReceiveCall()?
This is the class below:
import StreamChat
import UserNotifications
class NotificationService: UNNotificationServiceExtension {
var contentHandler: ((UNNotificationContent) -> Void)?
var request: UNNotificationRequest?
override func didReceive(
_ request: UNNotificationRequest,
withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void
) {
self.contentHandler = contentHandler
self.request = request
guard let content = request.content.mutableCopy() as? UNMutableNotificationContent else {
// contentHandler(request.content)
return
}
guard let userCredentials = UserDefaults.shared.currentUserToken else {
contentHandler(content)
return
}
let apiKeyString = "7msuhtr26b4q"
let applicationGroupIdentifier = "group.com.sigdev.tie"
var config = ChatClientConfig(apiKey: .init(apiKeyString))
// config.isLocalStorageEnabled = true
config.applicationGroupIdentifier = applicationGroupIdentifier
let client = ChatClient(config: config)
// : usertoken : " , userCredentials)
client.setToken(token: Token(stringLiteral: userCredentials))
let chatHandler = ChatRemoteNotificationHandler(client: client, content: content)
let chatNotification = chatHandler.handleNotification { chatContent in
switch chatContent {
case let .unknown(messageNotification):
contentHandler(content)
case let .message(messageNotification , channelID , client):
if messageNotification.channel?.membership != nil{
if((messageNotification.channel?.membership?.isInvited == true && messageNotification.channel?.membership?.inviteAcceptedAt == nil && messageNotification.channel?.membership?.inviteRejectedAt == nil)){
content.body = "You are invited to "+(messageNotification.channel?.name ?? "Chat room")
let muteController = client.channelController(for: channelID)
muteController.muteChannel { error in
if let _ = error {
// handle error
muteController.muteChannel { error in
if let error = error {
// handle error
print(error)
}
}
}
}
contentHandler(content)
return
}
}
if let activityMembers = messageNotification.message.activityMembers {
content.body = self.dynamicActivtyTextParser(activityString: messageNotification.message.text, activtyMembers: activityMembers, channel: messageNotification.channel!)
content.subtitle = ""
contentHandler(content)
} else {
contentHandler(content)
}
// if normal message its throws bug
// }
default:
content.title = "default"
contentHandler(content)
}
}
if !chatNotification {
content.title = "nochat notification"
// : line 123")
// this was not a notification from Stream Chat
// perform any other transformation to the notification if needed
contentHandler(content)
}
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
I have a notification service extension which is working fine when i receive a notification, but when i access the channelController, it gives me this error here only in this class.
How can i get the channelController and get it to work here in this extension didReceiveCall()?
This is the class below:
// }
}
Beta Was this translation helpful? Give feedback.
All reactions