Top

iOS SDK 2.8.0 | kSearchDidFoundMessagesInAConversation

Comentarios

6 comentarios

  • 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
    Acciones de comentarios 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
    Acciones de comentarios 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
    Acciones de comentarios 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
    Acciones de comentarios 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
    Acciones de comentarios Permalink
  • Patrik Spisak

    Thanks,

    This was crucial thing what I missed in my code

    10E5
    0
    Acciones de comentarios Permalink

Iniciar sesión para dejar un comentario.

¿Todavía no puedes encontrar lo que necesitas?

  • Contáctenos

    ¿Tiene alguna pregunta sobre Rainbow? Déjenos un mensaje para obtener más información.

    Contacte con
  • Pregunte a la Comunidad

    ¿Necesitas ayuda? Haz tus preguntas en la Comunidad para obtener respuestas de otros usuarios de Rainbow.

    Enviar un mensaje.