Top

iOS SDK 2.8.0 | kSearchDidFoundMessagesInAConversation

Commentaires

6 commentaires

  • 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
    Actions pour les commentaires Permalien
  • 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
    Actions pour les commentaires Permalien
  • 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
    Actions pour les commentaires Permalien
  • 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
    Actions pour les commentaires Permalien
  • 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
    Actions pour les commentaires Permalien
  • Patrik Spisak

    Thanks,

    This was crucial thing what I missed in my code

    10E5
    0
    Actions pour les commentaires Permalien

Vous devez vous connecter pour laisser un commentaire.

Vous n'avez pas trouvé ce que vous cherchez?

  • Contactez-nous

    Vous avez des questions? Laissez-nous un message pour obtenir plus d'informations.

    Contactez-nous
  • Demandez à la Communauté

    Vous avez besoin d'aide? Posez vos questions à la Communauté et obtenez des réponses d'autres utilisateurs Rainbow.

    Poster un message