iOS SDK 2.8.0 | kSearchDidFoundMessagesInAConversation
Hello,
in SDK 2.8.0 Im not able to retrieve messages property anymore.
In 2.7.1
if let messages = (notification.object as? NSDictionary)?["occurences"] as? [Message] {
for message in messages {
if foundMessages.firstIndex(of: message) == nil {
foundMessages.append(message)
}
}
}
Message body is nil, also message peer is nil.
In SDK 2.8.0 same code, but Message object contain nils. It was something changed what was not mentioned?
2023-07-14 14:54:45.828355+0200 DholRainbow[94350:3940935] [ConversationsSearchHelper:235] searchInConversationWithPeer: e48a8352f14241bb8af9ad468fa89f2a@openrainbow.com text: Test
2023-07-14 14:54:45.828550+0200 DholRainbow[94350:3940935] [HTTP] [GET] [SENT] https://openrainbow.com/api/rainbow/enduser/v1.0/users/62552dc6c59536030e665695/conversations/search/hits?substring=Test&peer=e48a8352f14241bb8af9ad468fa89f2a@openrainbow.com&limit=100 (correlatorId: 4A5686F444)
2023-07-14 14:54:45.835003+0200 DholRainbow[94350:3940935] [RainbowContact:160] Presence Offline for jid 'e48a8352f14241bb8af9ad468fa89f2a@openrainbow.com'
2023-07-14 14:54:46.099907+0200 DholRainbow[94350:3957103] [HTTP] [GET] [RECV] https://openrainbow.com/api/rainbow/enduser/v1.0/users/62552dc6c59536030e665695/conversations/search/hits?substring=Test&peer=e48a8352f14241bb8af9ad468fa89f2a@openrainbow.com&limit=100 (reqId: vtwc3m2Xj, correlatorId: 4A5686F444)
2023-07-14 14:54:46.100225+0200 DholRainbow[94350:3957103] [ConversationsSearchHelper:253] searchInConversationWithPeer: results count: 4
Message: nil
Message: nil
Message: nil
Message: nil
Message: nil
Message: nil
Message: nil
Message: nil
2023-07-14 14:54:46.101606+0200 DholRainbow[94350:3956275] Error: execSQLStatement:onConnection:toCompletionWithRetry:writeLockHelp - SQL=BEGIN IMMEDIATE TRANSACTION;, error-code=10, error-message=disk I/O error
2023-07-14 14:54:46.102101+0200 DholRainbow[94350:3956275] Error: stepSQLStatement:toCompletionWithRetry - stepping returned unhandled result=10, DB=/Users/pasp/Library/Developer/CoreSimulator/Devices/31475E1B-95BD-4FE8-9088-C867387079D7/data/Containers/Data/Application/A69B1035-6424-432C-9289-BACF0039D767/Library/Caches/sk.dhollandia.DholRainbow/Cache.db
2023-07-14 14:54:46.102235+0200 DholRainbow[94350:3956275] Error: execSQLStatement:onConnection:toCompletionWithRetry:writeLockHelp - SQL=COMMIT TRANSACTION;, error-code=1, error-message=cannot commit - no transaction is active
2023-07-14 14:54:46.106458+0200 DholRainbow[94350:3940935] [RainbowContact:160] Presence Offline for jid 'e48a8352f14241bb8af9ad468fa89f2a@openrainbow.com'
-
Hello,
I asked the team about the issue, the response was the following :
when receiving `kSearchDidFoundMessagesInAConversation` and iterate the `occurences` you need to to get the real messages from the found results using the time stamps of the messages `-(void) searchContextMessagesWithPeer:(id<PeerProtocol> _Nonnull)peer aroundTimestamps:(NSArray * _Nonnull)timestamps`
After calling this method you will receive the same notification and could parse the result messages using `messages` key
-
What type of aroundTimestamps is expected? I see array of any
aroundTimestamps:(NSArray * _Nonnull)timestamps
But If I pass an array of [Date] I got crash.
var timeStamps = [Date]()
if let messages = (notification.object as? NSDictionary)?["occurences"] as? [Message], let peer = conversation?.peer {
for message in messages {
if let timeStamp = message.timestamp {
timeStamps.append(timeStamp)
}
}
serviceManager.conversationsSearchHelper.searchContextMessages(withPeer: peer, aroundTimestamps: timeStamps)
}Also tried convert message.tiemstamp to string in format "yyyy-MM-dd HH:mm:ss". This does not make application crash but still cant get second notification with "messages" key
-
Im still not able to get second call of notification. Something definitely Im doing wrong.
var timeStamps = [NSNumber]()
if let messages = (notification.object as? NSDictionary)?["occurences"] as? [Message], let peer = conversation?.peer {
for message in messages {
if let timeStamp = message.timestamp {
timeStamps.append((timeStamp.timeIntervalSince1970 as? NSNumber)!)
}
}
serviceManager.conversationsSearchHelper.searchContextMessages(withPeer: peer, aroundTimestamps: timeStamps)
}searchContextMessages aroundTimestamps does not triggering notification with "messages" key.
-
Here is the code we are using to achieve this :
```
/**
* Request for the messages before and after a specific date. The messages are returned in didFindMessagesInConversation.
*
* - Parameter beforeAndAfter: reference date
*
* - Returns:
*/
func getMessages(beforeAndAfter: [Date]) {
var timestamps: Array<NSNumber> = []
for date in beforeAndAfter {
let timeInterval = NSNumber(value: UInt(date.timeIntervalSince1970 * 10E5))
timestamps.append(timeInterval)
}
ServicesManager.sharedInstance()?.conversationsSearchHelper.searchContextMessages(withPeer: conversation.peer, aroundTimestamps: timestamps)
}```
Vous devez vous connecter pour laisser un commentaire.
Commentaires
6 commentaires