Top

iOS SDK 2.8.0 | kSearchDidFoundMessagesInAConversation

Kommentare

6 Kommentare

  • 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
    Aktionen für Kommentare 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
    Aktionen für Kommentare 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
    Aktionen für Kommentare 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
    Aktionen für Kommentare 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
    Aktionen für Kommentare Permalink
  • Patrik Spisak

    Thanks,

    This was crucial thing what I missed in my code

    10E5
    0
    Aktionen für Kommentare Permalink

Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.

Sie können immer noch nicht finden, was Sie brauchen?

  • Kontaktieren Sie uns

    Haben Sie eine Frage zu Rainbow? Hinterlassen Sie uns eine Nachricht, um weitere Informationen zu erhalten.

    Kontakt
  • Fragen Sie die Gemeinschaft

    Brauchen Sie Hilfe? Stellen Sie Ihre Fragen in der Community, um Antworten von anderen Rainbow-Benutzern zu erhalten.

    Nachricht posten