IOS APIs
I can see that the ‘conversationsManagerDidAckMessage’ notification is used to notify the sender when the message status changes from sent to received. When I look at the status in my app on the sender side, I can see that state change in real time. But this notification doesn’t get fired when I read that message on the receiving side, even though I am calling the SDK function to Mark it’s read.
Also, in iOS I can see that on login, the sdk retrieves all conversations automatically. But I cannot see a way to retrieve the conversation list at any time after login. In the Android sdk, there is a method called ‘getAllConversations’ which does exactly this but an equivalent method does not seem to be available in the IOS sdk. Could you please ask your technical team about this?
-
> I can see that the ‘conversationsManagerDidAckMessage’ notification is used to notify the sender when the message status
> changes from sent to received. When I look at the status in my app on the sender side, I can see that state change in real time.
> But this notification doesn’t get fired when I read that message on the receiving side, even though I am calling the SDK function
> to Mark it’s read.The state of the message on the sending side is update when the receiver read it throught the CKItemsBrowser update callback :
func itemsBrowser(_ browser: CKItemsBrowser!, didUpdateCacheItems changedItems: [Any]!, at indexes: IndexSet!) {
...
}
changedItems is a array of updated Message objects
You might have a look at the ChatViewController class of the Swift sample : https://github.com/Rainbow-CPaaS/Rainbow-iOS-SDK-Samples/tree/master/Rainbow-iOS-SDK-Sample-Swift
> Also, in iOS I can see that on login, the sdk retrieves all conversations automatically. But I cannot see a way to retrieve the
> conversation list at any time after login. In the Android sdk, there is a method called ‘getAllConversations’ which does exactly
> this but an equivalent method does not seem to be available in the IOS sdk. Could you please ask your technical team about this?With the iOS SDK you have access to a array property that contains all the user's conversations :
/** List of all conversations */
@property (nonatomic, readonly) NSArray<Conversation *> *conversations;You should have a look on the samples, in particular the ConversationsTableViewController class of the Swift sample : https://github.com/Rainbow-CPaaS/Rainbow-iOS-SDK-Samples/tree/master/Rainbow-iOS-SDK-Sample-Swift and how the code should wait for the kConversationsManagerDidEndLoadingConversations notification before trying to access the conversations.
-
Hi Vladimir,
Thank you for your reply.
On the first question:
I've upgraded my iOS SDK to version 1.73 and I can see now that the conversationsManagerDidAckMessage is also fired when the receiver reads the message. So it seems the issue has been resolved in the latest SDK update.
On the second question:
I understand that 'conversations' array exists and that the 'kConversationsManagerDidEndLoadingConversations' event needs to be listened for before accessing the array. The issue is that after login, there doesn't seem to be a way to reload the conversations from the server so that the 'kConversationsManagerDidEndLoadingConversations' event is fired again. I would have thought there would be a 'getAllConversations' method available for this purpose, like there is in the Android SDK, but that doesn't seem to be the case. If I simply access the 'conversations' array again, it just gives me the cached conversations that were last fetched from the server.
-
Hi Rick !
> If I simply access the 'conversations' array again, it just gives me the cached conversations that were last fetched from the server.The SDK manage the conversations array by listening events after the login, it should be updated with all the change in conversations. You may also listen to these events from ConversationsManager like : kConversationsManagerDidAddConversation, kConversationsManagerDidRemoveConversation, kConversationsManagerDidRemoveAllConversations,... then your app could react accordingly.
-
Hi Vladimir,
There is still an issue here with the conversation array. In order to prevent users from having to log in every time they open our app, I am bypassing the login process if there is a cached user (i.e. username and password are not nil) and also a valid auth token. If these conditions are met, then the user is taken into the app immediately.
The issue is that, in this case, when I access the 'conversations' array it is empty. I am listening for all of the conversation notifications i.e. kConversationsManagerDidEndLoadingConversations, kConversationsManagerDidEndLoadingConversationsFromCache, kConversationsManagerDidAddConversation, etc. but none of them are fired, presumably because a formal login/connect process is not being performed. It seems that the SDK only retrieves the conversation list if a full login process is done every time the app is open, but we do not want our users to have to login every time.
Do you have any ideas on how to retrieve the conversation history if the login/connect process is bypassed?
Thanks
Please sign in to leave a comment.
Comments
4 comments