Yes, thanks James, I think I got that.

For anyone comes into this problem, this is how we, following James's 
answer, implemented the monitor of http status code in iOS:

   1. add an observer to the replication created, for keyPath @"lastError"
   2. in the observation handling code, check if the error domain of this 
   @"lastError" is @"CBLHTTP"
   3. then check the code property of this @"lastError", possible values 
   are the same as HTTP status code standard. For example, 401 means not 
   authorized. We handle this error to log out current user.

-Sean

On Friday, March 20, 2015 at 8:53:14 PM UTC+8, James Nocentini wrote:
>
> Ok, you could add an observer to the replication change notification on 
> iOS.
>
> And check if the change notification is an error and get the status code 
> from there.
>
> See this example in Todo Lite Android to check if the username/password 
> are valid when logging in with Basic Auth 
> https://github.com/couchbaselabs/ToDoLite-Android/blob/master/ToDoLite/src/main/java/com/couchbase/todolite/Application.java#L291
>
> It should work  the same on iOS.
>
> On Friday, 20 March 2015 12:27:20 UTC, SeanDev wrote:
>>
>> Thanks, James. 
>>
>> The link is really helpful. I believe that is the way to track it.
>>
>> And for http status code, can we be more specific?
>>  
>>
>>> For the unauthorized case (401), you can check the status code.
>>>
>>
>> For this one, actually I get this error message, but I don't know how can 
>> I get notified before (or just after) the following message happens.
>>
>> *2015-03-20 17:53:21.265 DemoProject[342:66956] WARNING: 
>> CBL_Puller[http://127.0.0.1:4984/votings <http://127.0.0.1:4984/votings>]: 
>> Unable to save remote checkpoint: Error Domain=CBLHTTP Code=401 "401 
>> unauthorized" UserInfo=0x170c78d80 {NSURL=http:**//127.0.0.1:4984/votings 
>> <http://127.0.0.1:4984/votings>**/_local/41ac43b2653ee4e94f16092bfeea9b9c486e7c1a,
>>  
>> NSLocalizedFailureReason=unauthorized, NSLocalizedDescription=401 
>> unauthorized}*
>>
>>>
>>>
>> -Sean
>>
>

-- 
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/19ba4175-ad4a-48d3-9b9f-c3ba49dc5302%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to