Can you enable 'Database' and 'Model' logging as below and see if there are 
any log messages printed out?

CBLManager.enableLogging("Database")
CBLManager.enableLogging("Model")

On Saturday, March 18, 2017 at 8:28:20 AM UTC-7, [email protected] 
wrote:
>
>
>
> Recently, I started exploring couchbase lite mobile sdk for iOS. The sync 
> server and gateway are also up and running. I am going through the couch 
> chat sample. There are few questions:
>
> 1. I am checking the basic authentication (CBLAuthentication). What is the 
> correct way to check authentication success ? Do we have to rely on the 
> status of push / pull replication as reported in the notification 
> corresponding to replication progress ? If Yes then which status should be 
> used for this ? If No then what is the other way to do this ?
> 2. I am trying to create a simple chat application in iOS swift whose data 
> model resembles that of couchchat. The database setup is also successful. 
> The replication is also accomplished. The chat room model is as below:
>
> public class ChatRoom: CBLModel{    @NSManaged var title: String!    
> @NSManaged var channel_id: String!    @NSManaged var owners: [String]!    
> @NSManaged var members: [String]!}
>
> Is above model structure correct ?
>
> Then I tried to create a chatroom based on loggedInusername & another user 
> name as in the function
>
> public func chatRoom(forUser aUserName: String)->ChatRoom?{
>         let chatRoomTitleToMatch = loggedInUserName + "_" + aUserName
>         var chatRoom: ChatRoom? = nil
>
> //myChatRoomsQuery is also created prior to its use here
>
>         if let existingChatRooms = myChatRoomsQuery?.rows{
>             while let aRow = existingChatRooms.nextRow() {
>                 let existingRoom = ChatRoom(for: aRow.document!)
>                 if (existingRoom?.owners.contains(loggedInUserName)) == true 
> || (existingRoom?.owners.contains(aUserName)) == true{
>                     chatRoom = existingRoom
>                     break
>                 }
>             }
>         }
>         if chatRoom == nil {
>             let aNewChatRoom = ChatRoom(forNewDocumentIn: self.database!)
>             aNewChatRoom.title = chatRoomTitleToMatch
>             aNewChatRoom.owners = [loggedInUserName,aUserName]
>             aNewChatRoom.members = aNewChatRoom.owners
>             aNewChatRoom.channel_id = aNewChatRoom.document?.documentID
>             aNewChatRoom.type = "room"
>             do{
>                 try aNewChatRoom.save()
>             }catch{
>                 print("Encountered error: \(error) while saving chat room.")
>             }
>             chatRoom = aNewChatRoom
>         }
>         return chatRoom
>     }
>
> But the room is not getting saved. Also there is no error returned in the 
> save operation. What can be the probable issue ? The application has 
> successfully connected to the database & push / pull replication has also 
> occured.
>
> I have also registered the above model class (ChatRoom) as below:
>
> fileprivate func registerModelClasses(){        
> self.database?.modelFactory?.registerClass("UserProfile", forDocumentType: 
> "profile")        self.database?.modelFactory?.registerClass("ChatRoom", 
> forDocumentType: "room")}
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mobile-couchbase/24bacb86-effe-4dfb-8779-1e662594bd77%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to