How to get live incoming messages in IOS SDK?
Hi @Raj here’s the docs for handling live objects : https://docs.amity.co/chat/ios/live-objects if you have further question, please let us know.
can you please mention the method that called when any message comes? . i have tried with the following code but not succeed.
Note- Sending a message is working fine, issue with only incoming messages.
private func observeMessages() {
if self.chatInitData?.custSupportChannel != nil {
messageRepository = AmityMessageRepository(client: AmityManager.shared.client!)
let userDefaults: UserDefaults = .standard
let includingTags: [String] = userDefaults.channelPreferenceIncludingTags[(self.chatInitData?.custSupportChannel)!] ?? []
let excludingTags: [String] = userDefaults.channelPreferenceExcludingTags[(self.chatInitData?.custSupportChannel)!] ?? []
let filterByParentIdActive: Bool = userDefaults.channelPreferenceFilterByParentIdActive[(self.chatInitData?.custSupportChannel)!] ?? false
let parentId: String? = userDefaults.channelPreferenceFilterByParentId[(self.chatInitData?.custSupportChannel)!]
let messagesCollection: AmityCollection<AmityMessage>
messagesCollection = messageRepository!.getMessages(channelId: (self.chatInitData?.custSupportChannel)!,
includingTags: includingTags,
excludingTags: excludingTags,
filterByParentId: filterByParentIdActive,
parentId: parentId,
reverse: reversePreference)
messagesCollection.observe { [weak self] messages, _, _ in
Console.log("Message Changed ")
}
}
}
@SocialPlus_Support , can you please look here , please provide the solution for this.
Hi @Raj have you declared the AmityNotificationToken ? pls see the reference here: https://docs.amity.co/chat/ios/live-objects#amitynotificationtoken
@SocialPlus_Support Thanks , working fine now.
1 Like