Top

iOS SDK 2.8.0 | kSearchDidFoundMessagesInAConversation

Comentários

6 comentários

  • Vladimir VYSKOCIL

    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

    0
    Ações de comentário Permalink
  • Patrik Spisak

    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

    0
    Ações de comentário Permalink
  • Vladimir VYSKOCIL

    Hello Patrik,

    The type of the array elements is NSNumber.

    We have started working on better support of Swift for the iOS SDK, one of the task is to type array elements, here the declaration should have been (NSArray<NSNumber *> * _Nonnull) timestamps

    0
    Ações de comentário Permalink
  • Patrik Spisak

    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.

    0
    Ações de comentário Permalink
  • Vladimir VYSKOCIL

    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)
        }

    ```

    0
    Ações de comentário Permalink
  • Patrik Spisak

    Thanks,

    This was crucial thing what I missed in my code

    10E5
    0
    Ações de comentário Permalink

Por favor, entrar para comentar.

Ainda não consegue encontrar o que você precisa?

  • Contate-nos

    Você tem alguma pergunta sobre o Rainbow? Deixe-nos uma mensagem para obter mais informações.

    Contato
  • Pergunte à Comunidade

    Você precisa de ajuda? Faça suas perguntas na Comunidade para obter respostas de outros usuários do Rainbow.

    Enviar mensagem