EDIT: I've found the solution.
The problem is that QBUsers:signUp doesn't perform user login. So you (and me) should do QBUsers:logIn after QBUsers:signUp
At first I login my user or signup, if user doesn't exist. My code:
qbUser = [QBUUser user];
qbUser.fullName = #"some name";
qbUser.login = #"40118285";
qbUser.password = #"worldvideovoyage";
...
[QBUsers logInWithUserLogin:qbUser.login password:qbUser.password delegate:self];
If user doesn't exist yet I perform singing up the user:
-(void)completedWithResult:(Result *)result
{
if(!result.success) {
ASLog(#"%#", result.errors);
}
if([result isKindOfClass:QBUUserLogInResult.class]) {
if(result.success) {
QBUUserLogInResult *res = (QBUUserLogInResult*)result;
qbUser = res.user;
ASLog(#"LogIn user %# completed", qbUser.email);
[self.params loadWithUserID:qbUser.ID];
} else {
// we have to signup firstly
ASLog(#"Signup user %#", qbUser.login);
[QBUsers signUp:qbUser delegate:self];
}
} else if([result isKindOfClass:QBUUserResult.class]) {
if(result.success) {
QBUUserResult *res = (QBUUserResult*)result;
qbUser = res.user;
ASLog(#"Signup user %# completed", qbUser.email);
[self.params saveWithUserID:qbUser.ID];
[[NSNotificationCenter defaultCenter] postNotificationName:nCHANGE_USER object:self];
} else {
// signup fails
ASLog(#"ERROR: signup fail!");
}
}
}
After that I have in console:
2013-09-10 13:49:42.109 DimChat[48347:1b27] Request finished, response:
RestResponse:
------
<QBASIHTTPRequest: 0xe275400>
headers:{
"Access-Control-Allow-Headers" = "QB-Token,QuickBlox-REST-API-Version";
"Access-Control-Allow-Origin" = "*";
"Access-Control-Request-Method" = "*";
"Cache-Control" = "max-age=0, private, must-revalidate";
Connection = Close;
"Content-Length" = 623;
"Content-Type" = "application/xml; charset=utf-8";
Date = "Tue, 10 Sep 2013 09:49:39 GMT";
Etag = "\"9973e1c39deddfd236cab1a0de3e4b38\"";
Location = "http://api.quickblox.com/users/503563";
"QB-Token-ExpirationDate" = "2013-09-10 11:49:39 UTC";
"QuickBlox-REST-API-Version" = "0.1.1";
Server = "nginx/1.0.15";
Status = "201 Created";
"X-Rack-Cache" = "invalidate, pass";
"X-Request-Id" = 6c8eddea8a6f7b6c03e6eb02d40472a3;
"X-Runtime" = "0.083159";
"X-UA-Compatible" = "IE=Edge,chrome=1";
}
body:<?xml version="1.0" encoding="UTF-8"?>
<user>
<blob-id type="integer" nil="true"/>
<created-at type="datetime">2013-09-10T09:49:39Z</created-at>
<email nil="true"/>
<external-user-id type="integer" nil="true"/>
<facebook-id nil="true"/>
<full-name>ÐаÑилий ÐакаÑов</full-name>
<id type="integer">503563</id>
<last-request-at type="datetime" nil="true"/>
<login>40118285</login>
<owner-id type="integer">4855</owner-id>
<phone nil="true"/>
<twitter-id nil="true"/>
<updated-at type="datetime">2013-09-10T09:49:39Z</updated-at>
<website nil="true"/>
<user-tags nil="true"/>
</user>
error:
2013-09-10 13:49:42.110 DimChat[48347:c07] -[ASUser completedWithResult:] [Line 262] Signup user (null) completed
And then I try to create QBCOCustomObject:
co = [QBCOCustomObject customObject];
co.className = #"Settings";
co.userID = userID;
co.fields[#"goal"] = [NSNumber numberWithInt:_goal];
// ... init other fields of custom object
[QBCustomObjects createObject:co delegate:self];
And I get an error:
2013-09-10 13:50:11.135 DimChat[48347:cb0f] Request finished, response:
RestResponse:
------
<QBASIHTTPRequest: 0xe275400>
headers:{
"Access-Control-Allow-Headers" = "QB-Token,QuickBlox-REST-API-Version";
"Access-Control-Allow-Origin" = "*";
"Access-Control-Request-Method" = "*";
"Cache-Control" = "no-cache";
Connection = Close;
"Content-Length" = 97;
"Content-Type" = "application/xml; charset=utf-8";
Date = "Tue, 10 Sep 2013 09:50:08 GMT";
"QB-Token-ExpirationDate" = "2013-09-10 11:49:39 UTC";
"QuickBlox-REST-API-Version" = "0.1.1";
Server = "nginx/1.0.15";
Status = "422 Unprocessable Entity";
"X-Rack-Cache" = "invalidate, pass";
"X-Request-Id" = 081ee974feacc97e8af6a2c53e1795da;
"X-Runtime" = "0.031358";
"X-UA-Compatible" = "IE=Edge,chrome=1";
}
body:<?xml version="1.0" encoding="UTF-8"?>
<errors>
<error>Forbidden. Need user.</error>
</errors>
I'm pretty sure that I have valid QBUUser and I performed login. But why I have this error?
I've found the solution.
The problem is that QBUsers:signUp doesn't perform user login. So you (and me) should do QBUsers:logIn after QBUsers:signUp
Related
I am trying to download file from private window using wkwebview unfortunately unable to download the file. this is the response which i am getting.
-[DownloadHandler saveDirectoryPathForResponse:][L:124]response <NSHTTPURLResponse: 0x600000434c20> { URL: https://osxDev.slack.com/?redir=%2Ffiles-pri%2FT0B5PPLCX-FF7NT0NNA%2Fdownload%2Fchalte_chalte_-_pagalworld.org } { Status Code: 200, Headers {
"Cache-Control" = (
"private, no-cache, no-store, must-revalidate"
);
"Content-Encoding" = (
gzip
);
"Content-Length" = (
19772
);
"Content-Type" = (
"text/html; charset=utf-8"
);
Date = (
"Wed, 23 Jan 2019 11:08:19 GMT"
);
Expires = (
"Mon, 26 Jul 1997 05:00:00 GMT"
);
Pragma = (
"no-cache"
);
Server = (
Apache
);
"Set-Cookie" = (
"d-s=1548241699; path=/; domain=.slack.com; secure; httponly",
"x=eo7res6xk440uh3keb6sggrzh.1548239853; expires=Wed, 23-Jan-2019 11:23:19 GMT; Max-Age=900; path=/; domain=.slack.com"
);
"Strict-Transport-Security" = (
"max-age=31536000; includeSubDomains; preload"
);
Vary = (
"Accept-Encoding"
);
Via = (
"1.1 5c49044a9bbc82066ce04ae597e1a6a7.cloudfront.net (CloudFront)"
);
"referrer-policy" = (
"no-referrer"
);
"x-amz-cf-id" = (
"jnczFrzoTMCmf-vZHd3M7jgYfKQEl0AEltH7fl74jZE144tGU2MvCw=="
);
"x-cache" = (
"Miss from cloudfront"
);
"x-frame-options" = (
SAMEORIGIN
);
"x-robots-tag" = (
"noindex,nofollow"
);
"x-via" = (
"haproxy-www-gd85"
);
"x-xss-protection" = (
0
);
} }
But when i am trying with non-private i am able to download and response is
-[DownloadHandler saveDirectoryPathForResponse:][L:124]response <NSHTTPURLResponse: 0x6040006244c0> { URL: https://files.slack.com/files-pri/T0B5PPLCX-FF7NT0NNA/download/chalte_chalte_-_pagalworld.org } { Status Code: 200, Headers {
"Accept-Ranges" = (
bytes
);
"Cache-Control" = (
"max-age=31536000, public"
);
Connection = (
"keep-alive"
);
"Content-Disposition" = (
"attachment; filename=\"Chalte Chalte - Pagalworld.org\"; filename*=UTF-8''Chalte%20Chalte%20-%20Pagalworld.org"
);
"Content-Length" = (
3763833
);
"Content-Type" = (
"audio/mpeg"
);
Date = (
"Wed, 23 Jan 2019 11:04:42 GMT"
);
Etag = (
"\"0c3a5aebdf8ab1acab4e098ccb77bc9a\""
);
Via = (
"1.1 b72519ee5ed84e4e3db077b5b7e93d38.cloudfront.net (CloudFront)"
);
"X-Amz-Cf-Id" = (
"aQ6auC2yu5RwLeYuEFyE3TT7tes36MTo5uGnTQ3vxXfGaZ2nAzxNJQ=="
);
"X-Backend" = (
"imgproxy-prod-pdx-lk25"
);
"X-Cache" = (
"Miss from cloudfront"
);
"X-Content-Type-Options" = (
nosniff
);
"X-Robots-Tag" = (
noindex
);
"X-Slack-Meta" = (
S3TA
);
} }
as you can see in private response which is different from non-private response and also content-disposition missing and you can also see response url is different. so in order to download the file even if the WKWebview is in private mode how to do that .
Any suggestions?
I am using TFS2018 and calling the build api like this
internal void UpdateSourceBranches(List<BuildDefinition> defs)
{
using (var handler = new HttpClientHandler { Credentials = new NetworkCredential(tfsUser, tfsPass) })
using (var client = new HttpClient(handler))
{
try
{
client.BaseAddress = new Uri(tfsServer);
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
foreach (var def in defs)
{
var buildId = def.Id;
var sourceBranch = $"$/{def.Repository.Name}/{def.Project.Name}";
var parameters = new Dictionary<string, string> { { "BuildConfiguration", "release" },
{ "BuildPlatform", "x86|x64|ARM" },
{ "system.debug", "true" }
};
var jsonParams = JsonConvert.SerializeObject(parameters);
var content = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("id", buildId.ToString()),
new KeyValuePair<string, string>("sourceBranch", sourceBranch),
new KeyValuePair<string, string>("parameters", jsonParams)
});
var response = client.PostAsync($"DefaultCollection/{def.Repository.Name}/_apis/build/builds?api-version=3.0-preview.1", content);
var s = response.Result;
}
}
catch (Exception ex)
{
}
}
}
But getting the following response
{StatusCode: 405, ReasonPhrase: 'Method Not Allowed', Version: 1.1,
Content: System.Net.Http.StreamContent, Headers: { Pragma: no-cache
X-TFS-ProcessId: ActivityId: X-TFS-Session: X-VSS-E2EID:
X-FRAME-OPTIONS: SAMEORIGIN X-VSS-UserData: :user Persistent-Auth:
true Lfs-Authenticate: NTLM X-Content-Type-Options: nosniff
Cache-Control: no-cache Date: Fri, 09 Mar 2018 14:37:16 GMT P3P:
CP="CAO DSP COR ADMa DEV CONo TELo CUR PSA PSD TAI IVDo OUR SAMi BUS
DEM NAV STA UNI COM INT PHY ONL FIN PUR LOC CNT" Server:
Microsoft-IIS/10.0 X-AspNet-Version: 4.0.30319 X-Powered-By: ASP.NET
Content-Length: 93 Allow: GET Content-Type: application/json;
charset=utf-8 Expires: -1 }}
Any idea why I am getting Method Not Allowed ?
Here is the bad response:
{StatusCode: 400, ReasonPhrase: 'Bad Request', Version: 1.1, Content:
System.Net.Http.StreamContent, Headers: { Pragma: no-cache
X-TFS-ProcessId: xxxxxx-xxxxx-xxxxx-xxxxxx-xxxxxxxxxx ActivityId:
xxxxxx-xxxxx-xxxxx-xxxxxx-xxxxxxxxxx X-TFS-Session:
xxxxxx-xxxxx-xxxxx-xxxxxx-xxxxxxxxxx X-VSS-E2EID:
xxxxxx-xxxxx-xxxxx-xxxxxx-xxxxxxxxxx X-FRAME-OPTIONS: SAMEORIGIN
X-VSS-UserData: xxxxxx-xxxxx-xxxxx-xxxxxx-xxxxxxxxxx:user
Persistent-Auth: true Lfs-Authenticate: NTLM
X-Content-Type-Options: nosniff Cache-Control: no-cache Date: Tue,
13 Mar 2018 09:21:53 GMT P3P: CP="...multiple keywords" Server:
Microsoft-IIS/10.0 X-AspNet-Version: 4.0.30319 X-Powered-By:
ASP.NET Content-Length: 547 Content-Type: application/json;
charset=utf-8 Expires: -1 }}
Sounds like your POST is the issue, try using a GET
You should use api-version=2.0 instead of 3.0-preview.1.
Update code snippet:
string con = "{\"definition\": {\"id\": 47},\"sourceBranch\":\"$/CeceScrum/TestCaseProject\",\"parameters\":\"{\\\"BuildConfiguration\\\":\\\"release\\\",\\\"BuildPlatform\\\":\\\"any cpu\\\",\\\"system.debug\\\":\\\"false\\\"}\"}";
var patchValue = new StringContent(con, Encoding.UTF8, "application/json");
HttpClient httpClient = new HttpClient();
string _credentials = Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(string.Format("{0}:{1}", "domain\\username", "password")));
httpClient.DefaultRequestHeaders.Accept.Clear();
httpClient.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", _credentials);
var method = new HttpMethod("POST");
var request = new HttpRequestMessage(method, "http://TFS2018:8080/tfs/DefaultCollection/CeceScrum/_apis/build/builds?api-version=2.0") { Content = patchValue };
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage response = httpClient.SendAsync(request).Result;
string re= response.Content.ReadAsStringAsync().Result;
I'm having a problem using suggestedFilename with Hebrew file names.
I'm sending a response like this:
_fileName = [response suggestedFilename];
but for example if the NSURLResponse is something like this:
<NSHTTPURLResponse: ........> { URL: https://SOMETHINGSOMETHINGSOMETHING/A%D7%91%D7%93%D7%99%D7%A7%D7%94%20%D7%A2%D7%9D%20%D7%90%D7%95%D7%AA.txt } { Status Code: 200, Headers {
"Accept-Ranges" = (
bytes
);
Connection = (
"Keep-Alive"
);
"Content-Disposition" = (
"Attachment; filename=\"A\U00d7\U0091\U00d7\U0093\U00d7\U0099\U00d7\U00a7\U00d7\U0094 \U00d7\U00a2\U00d7\U009d \U00d7\U0090\U00d7\U0095\U00d7\U00aa.txt\""
);
"Content-Length" = (
0
);
"Content-Type" = (
"text/plain"
);
Date = (
"Sun, 04 Mar 2018 15:20:41 GMT"
);
Etag = (
"SOMETHING"
);
"Keep-Alive" = (
"timeout=2, max=100"
);
"Last-Modified" = (
"Wed, 28 Feb 2018 12:46:52 GMT"
);
Server = (
SOMETHING
);
Vary = (
"User-Agent"
);
"X-Frame-Options" = (
SAMEORIGIN
);
}
}
I'm getting in _filename : A××××§× ×¢× ××ת.txt
instead of : Aבדיקה עם אות.txt
any ideas?
I used this code to authorize Google+ via OAuth 2.0
oauthswift = OAuth2Swift(
consumerKey: "984813079630-f828a92sqtl5lgumd4kgp9i30bs9og09.apps.googleusercontent.com",
consumerSecret: "AIzaSyD13MBv78yWIjl4TX9jOOT9AWuEkYdVSPQ",
authorizeUrl: "https://accounts.google.com/o/oauth2/v2/auth",
accessTokenUrl: "https://www.googleapis.com/oauth2/v4/token",
responseType: "code"
)
let handle = oauthswift.authorize(
withCallbackURL: URL(string: "com.googleusercontent.apps.984813079630-f828a92sqtl5lgumd4kgp9i30bs9og09:/oauth")!,
scope: "profile", state:"GOOGLE",
success: { credential, response, parameters in
print(credential.oauthToken)
// Do your request
},
failure: { error in
print(error.localizedDescription)
print((error as OAuthSwiftError).errorUserInfo)
}
)
but the result always failed
The operation couldn’t be completed. (OAuthSwiftError error -11.)
["request": https://www.googleapis.com/oauth2/v4/token, "error": Error
Domain=NSURLErrorDomain Code=401 "invalid_client Unauthorized"
UserInfo={Response-Body={ "error": "invalid_client",
"error_description": "Unauthorized" } ,
NSErrorFailingURLKey=https://www.googleapis.com/oauth2/v4/token,
Response-Headers={
"Cache-Control" = "private, max-age=0";
"Content-Encoding" = gzip;
"Content-Length" = 81;
"Content-Type" = "application/json; charset=UTF-8";
Date = "Thu, 15 Jun 2017 04:25:10 GMT";
Expires = "Thu, 15 Jun 2017 04:25:10 GMT";
Server = GSE;
Vary = "Origin, X-Origin";
"Www-Authenticate" = "Bearer realm=\"https://accounts.google.com/\"";
"alt-svc" = "quic=\":443\"; ma=2592000; v=\"38,37,36,35\"";
"x-content-type-options" = nosniff;
"x-frame-options" = SAMEORIGIN;
"x-xss-protection" = "1; mode=block"; }, OAuthSwiftError.response= { URL:
https://www.googleapis.com/oauth2/v4/token } { status code: 401,
headers {
"Cache-Control" = "private, max-age=0";
"Content-Encoding" = gzip;
"Content-Length" = 81;
"Content-Type" = "application/json; charset=UTF-8";
Date = "Thu, 15 Jun 2017 04:25:10 GMT";
Expires = "Thu, 15 Jun 2017 04:25:10 GMT";
Server = GSE;
Vary = "Origin, X-Origin";
"Www-Authenticate" = "Bearer realm=\"https://accounts.google.com/\"";
"alt-svc" = "quic=\":443\"; ma=2592000; v=\"38,37,36,35\"";
"x-content-type-options" = nosniff;
"x-frame-options" = SAMEORIGIN;
"x-xss-protection" = "1; mode=block"; } }, OAuthSwiftError.response.data=<7b0a2022 6572726f 72223a20 22696e76
616c6964 5f636c69 656e7422 2c0a2022 6572726f 725f6465 73637269
7074696f 6e223a20 22556e61 7574686f 72697a65 64220a7d 0a>,
NSLocalizedDescription=invalid_client Unauthorized}]
Could you please correct it ?
You must remove replace withCallbackURL "com.googleusercontent.apps.984813079630-f828a92sqtl5lgumd4kgp9i30bs9og09:/oauth" with "your.bundle.id:/oauth2Callback"
Commentary from demo OAuthSwift:
For googgle the redirect_uri should match your this syntax:
your.bundle.id:/oauth2Callback
In plist define a url schem with: your.bundle.id
After these changes, I still had this problem. Found solution:
I removed the customerSecret by an empty string then.. it worked.
I hope to help you with my answer above!
I am using QuickBlox for my chatting app. The app turns black screen sometimes.
New LOG:
2014-01-24 01:54:42.302 Chat[5670:310b] Performing async request:
POST http://api.quickblox.com/session.xml
headers:{
"QB-SDK" = "iOS 1.8";
"Qb-Token" = 5b25119abfa4c89aced5068a1b2d151b19b77e86;
"QuickBlox-REST-API-Version" = "0.1.1";
}
parameters:{
"application_id" = 4354;
"auth_key" = yYBXmUnyvpYPMe5;
nonce = 125;
signature = a65c0971fa81ca8c79805b3ed4d7052e0ee5c059;
timestamp = 1390499682;
}
2014-01-24 01:54:42.352 Chat[5670:7b1b] -[QBChat xmppStream:didSendPresence:] -> Presence: <presence/>
2014-01-24 01:54:42.352 Chat[5670:60b] chatDidFailWithError: 1
2014-01-24 01:54:42.353 Chat[5670:7b1b] QBChat/didDisconnect, error: Error Domain=GCDAsyncSocketErrorDomain Code=7 "Socket closed by remote peer" UserInfo=0x1565dbe0 {NSLocalizedDescription=Socket closed by remote peer}
2014-01-24 01:54:43.031 Chat[5670:60b] result is: <QBAAuthSessionCreationResult: 0x155830c0>
2014-01-24 01:54:43.032 Chat[5670:7b1b] Request finished, response:
headers:{
"Access-Control-Allow-Origin" = "*";
"Cache-Control" = "max-age=0, private, must-revalidate";
Connection = "keep-alive";
"Content-Length" = 524;
"Content-Type" = "application/xml; charset=utf-8";
Date = "Thu, 23 Jan 2014 17:54:41 GMT";
Etag = "\"3472cc7b5b8d9c8d5fff89fbfdb73931\"";
"QB-Token-ExpirationDate" = "2014-01-23 19:54:41 UTC";
"QuickBlox-REST-API-Version" = "0.1.1";
Server = "nginx/1.0.15";
Status = "201 Created";
"X-Rack-Cache" = "invalidate, pass";
"X-Request-Id" = 2048340bfb6b9a87dd400a79a4b0a40c;
"X-Runtime" = "0.014610";
"X-UA-Compatible" = "IE=Edge,chrome=1";
}
body:
<?xml version="1.0" encoding="UTF-8"?>
<session>
<_id>52e15761535c120d6e00523d</_id>
<application-id type="integer">4354</application-id>
<created-at type="datetime">2014-01-23T17:54:41Z</created-at>
<device-id type="integer">0</device-id>
<nonce type="integer">125</nonce>
<token>8564a56a8744464e61afdbb370c2d02cc3d940a6</token>
<ts type="integer">1390499682</ts>
<updated-at type="datetime">2014-01-23T17:54:41Z</updated-at>
<user-id type="integer">0</user-id>
<id type="integer">31413</id>
</session>
error:
2014-01-24 01:54:43.042 Chat[5670:7b1b] Performing async request:
POST http://api.quickblox.com/login.xml
headers:{
"QB-SDK" = "iOS 1.8";
"Qb-Token" = 8564a56a8744464e61afdbb370c2d02cc3d940a6;
"QuickBlox-REST-API-Version" = "0.1.1";
}
parameters:{
login = hehe;
password = 12345678;
}
2014-01-24 01:54:43.741 Chat[5670:7b1b] Request finished, response:
headers:{
"Access-Control-Allow-Origin" = "*";
"Cache-Control" = "no-cache";
Connection = "keep-alive";
"Content-Length" = 590;
"Content-Type" = "application/xml; charset=utf-8";
Date = "Thu, 23 Jan 2014 17:54:41 GMT";
"QB-Token-ExpirationDate" = "2014-01-23 19:54:41 UTC";
"QuickBlox-REST-API-Version" = "0.1.1";
Server = "nginx/1.0.15";
Status = "202 Accepted";
"X-Rack-Cache" = "invalidate, pass";
"X-Request-Id" = eab9d8949c044d1af3b0282222931428;
"X-Runtime" = "0.015342";
"X-UA-Compatible" = "IE=Edge,chrome=1";
}
body:
<?xml version="1.0" encoding="UTF-8"?>
<user>
<blob-id type="integer" nil="true"/>
<created-at type="datetime">2014-01-23T15:47:06Z</created-at>
<email nil="true"/>
<external-user-id type="integer" nil="true"/>
<facebook-id nil="true"/>
<full-name nil="true"/>
<id type="integer">806773</id>
<last-request-at type="datetime" nil="true"/>
<login>hehe</login>
<owner-id type="integer">5464</owner-id>
<phone nil="true"/>
<twitter-id nil="true"/>
<updated-at type="datetime">2014-01-23T15:47:06Z</updated-at>
<website nil="true"/>
<user-tags nil="true"/>
</user>
error:
2014-01-24 01:54:43.749 Chat[5670:7b1b] -[QBChat loginWithUser:] -> Chat server endpoint: muc.chat.quickblox.com, User JID: 806773-4354#chat.quickblox.com
2014-01-24 01:54:43.770 Chat[5670:7b1b] Performing async request:
POST http://api.quickblox.com/push_tokens.xml
headers:{
"QB-SDK" = "iOS 1.8";
"Qb-Token" = 8564a56a8744464e61afdbb370c2d02cc3d940a6;
"QuickBlox-REST-API-Version" = "0.1.1";
}
parameters:{
"device[platform]" = iOS;
"device[udid]" = "D44DD5B1-A5B3-4E61-B761-A4DE8BB28F72";
"push_token[client_identification_sequence]" = 8efc776c0ea913f3cd8785f68bb4d7f3bb3a5ffcfde76ed1beab1181d8aae8af;
"push_token[environment]" = development;
}
2014-01-24 01:54:44.168 Chat[5670:7b1b] Performing async request:
POST http://api.quickblox.com/session.xml
headers:{
"QB-SDK" = "iOS 1.8";
"Qb-Token" = 8564a56a8744464e61afdbb370c2d02cc3d940a6;
"QuickBlox-REST-API-Version" = "0.1.1";
}
parameters:{
"application_id" = 4354;
"auth_key" = yYBXmUnyvpYPMe5;
nonce = 524;
signature = ce2521946486c0fb579a41f56e067661c059358b;
timestamp = 1390499684;
}
2014-01-24 01:54:44.169 Chat[5670:7b1b] Performing async request:
POST http://api.quickblox.com/session.xml
headers:{
"QB-SDK" = "iOS 1.8";
"Qb-Token" = 8564a56a8744464e61afdbb370c2d02cc3d940a6;
"QuickBlox-REST-API-Version" = "0.1.1";
}
parameters:{
"application_id" = 4354;
"auth_key" = yYBXmUnyvpYPMe5;
nonce = 484;
signature = 9da8fc95d9de0819b5f12ebefdf421e569adf2f3;
timestamp = 1390499684;
}
2014-01-24 01:54:44.417 Chat[5670:7b1b] Request finished, response:
headers:{
"Access-Control-Allow-Origin" = "*";
"Cache-Control" = "max-age=0, private, must-revalidate";
Connection = "keep-alive";
"Content-Length" = 272;
"Content-Type" = "application/xml; charset=utf-8";
Date = "Thu, 23 Jan 2014 17:54:42 GMT";
Etag = "\"36f956ca6271157cf23485a0efdd1770\"";
"QB-Token-ExpirationDate" = "2014-01-23 19:54:42 UTC";
"QuickBlox-REST-API-Version" = "0.1.1";
Server = "nginx/1.0.15";
Status = "201 Created";
"X-Rack-Cache" = "invalidate, pass";
"X-Request-Id" = 6d05ab80975f4f00042664f0cbcc1896;
"X-Runtime" = "0.033340";
"X-UA-Compatible" = "IE=Edge,chrome=1";
}
body:
<?xml version="1.0" encoding="UTF-8"?>
<push-token>
<client-identification-sequence>8efc776c0ea913f3cd8785f68bb4d7f3bb3a5ffcfde76ed1beab1181d8aae8af</client-identification-sequence>
<environment>development</environment>
<id type="integer">588770</id>
</push-token>
error:
2014-01-24 01:54:44.425 Chat[5670:7b1b] Performing async request:
POST http://api.quickblox.com/subscriptions.xml
headers:{
"QB-SDK" = "iOS 1.8";
"Qb-Token" = 8564a56a8744464e61afdbb370c2d02cc3d940a6;
"QuickBlox-REST-API-Version" = "0.1.1";
}
parameters:{
"notification_channels" = apns;
}
2014-01-24 01:54:44.780 Chat[5670:310b] Request finished, response:
headers:{
"Access-Control-Allow-Origin" = "*";
"Cache-Control" = "max-age=0, private, must-revalidate";
Connection = "keep-alive";
"Content-Length" = 524;
"Content-Type" = "application/xml; charset=utf-8";
Date = "Thu, 23 Jan 2014 17:54:42 GMT";
Etag = "\"6fd90ffd8e3f5d10150f0acad6a0d46c\"";
"QB-Token-ExpirationDate" = "2014-01-23 19:54:42 UTC";
"QuickBlox-REST-API-Version" = "0.1.1";
Server = "nginx/1.0.15";
Status = "201 Created";
"X-Rack-Cache" = "invalidate, pass";
"X-Request-Id" = ce446bfab2d31c37e9e5ffc302603b8b;
"X-Runtime" = "0.015738";
"X-UA-Compatible" = "IE=Edge,chrome=1";
}
body:
<?xml version="1.0" encoding="UTF-8"?>
<session>
<_id>52e15762535c12b64600503e</_id>
<application-id type="integer">4354</application-id>
<created-at type="datetime">2014-01-23T17:54:42Z</created-at>
<device-id type="integer">0</device-id>
<nonce type="integer">524</nonce>
<token>28ccd997f46ae70d9deec08d3e4a936881357ba7</token>
<ts type="integer">1390499684</ts>
<updated-at type="datetime">2014-01-23T17:54:42Z</updated-at>
<user-id type="integer">0</user-id>
<id type="integer">17423</id>
</session>
error:
2014-01-24 01:54:44.782 Chat[5670:60b] result is: <QBAAuthSessionCreationResult: 0x155825d0>
2014-01-24 01:54:44.788 Chat[5670:310b] Performing async request:
POST http://api.quickblox.com/login.xml
headers:{
"QB-SDK" = "iOS 1.8";
"Qb-Token" = 28ccd997f46ae70d9deec08d3e4a936881357ba7;
"QuickBlox-REST-API-Version" = "0.1.1";
}
parameters:{
login = hehe;
password = 12345678;
}
2014-01-24 01:54:44.800 Chat[5670:60b] result is: <QBAAuthSessionCreationResult: 0x15589e90>
2014-01-24 01:54:44.796 Chat[5670:7b1b] Request finished, response:
headers:{
"Access-Control-Allow-Origin" = "*";
"Cache-Control" = "max-age=0, private, must-revalidate";
Connection = "keep-alive";
"Content-Length" = 524;
"Content-Type" = "application/xml; charset=utf-8";
Date = "Thu, 23 Jan 2014 17:54:42 GMT";
Etag = "\"1f4ecc5c5bded2167a761a907f23f3e3\"";
"QB-Token-ExpirationDate" = "2014-01-23 19:54:42 UTC";
"QuickBlox-REST-API-Version" = "0.1.1";
Server = "nginx/1.0.15";
Status = "201 Created";
"X-Rack-Cache" = "invalidate, pass";
"X-Request-Id" = c6da0e923aa3fc6d530f08d298c7332b;
"X-Runtime" = "0.014244";
"X-UA-Compatible" = "IE=Edge,chrome=1";
}
body:
<?xml version="1.0" encoding="UTF-8"?>
<session>
<_id>52e15762535c12df80005377</_id>
<application-id type="integer">4354</application-id>
<created-at type="datetime">2014-01-23T17:54:42Z</created-at>
<device-id type="integer">0</device-id>
<nonce type="integer">484</nonce>
<token>0744438380a2cbfadf8e859b98d8bab319dd4383</token>
<ts type="integer">1390499684</ts>
<updated-at type="datetime">2014-01-23T17:54:42Z</updated-at>
<user-id type="integer">0</user-id>
<id type="integer">27111</id>
</session>
error:
2014-01-24 01:54:44.804 Chat[5670:7b1b] Performing async request:
POST http://api.quickblox.com/login.xml
headers:{
"QB-SDK" = "iOS 1.8";
"Qb-Token" = 0744438380a2cbfadf8e859b98d8bab319dd4383;
"QuickBlox-REST-API-Version" = "0.1.1";
}
parameters:{
login = hehe;
password = 12345678;
}
2014-01-24 01:54:45.029 Chat[5670:380b] QBChat/didConnect
2014-01-24 01:54:45.059 Chat[5670:60b] Push notification subscribed
2014-01-24 01:54:45.058 Chat[5670:310b] Request finished, response:
headers:{
"Access-Control-Allow-Origin" = "*";
"Cache-Control" = "max-age=0, private, must-revalidate";
Connection = "keep-alive";
"Content-Length" = 67;
"Content-Type" = "application/xml; charset=utf-8";
Date = "Thu, 23 Jan 2014 17:54:43 GMT";
Etag = "\"4f31ca96db448bb738a3923db737871d\"";
"QB-Token-ExpirationDate" = "2014-01-23 19:54:43 UTC";
"QuickBlox-REST-API-Version" = "0.1.1";
Server = "nginx/1.0.15";
Status = "201 Created";
"X-Rack-Cache" = "invalidate, pass";
"X-Request-Id" = 9507e38031c78305d16b88a73e000557;
"X-Runtime" = "0.024274";
"X-UA-Compatible" = "IE=Edge,chrome=1";
}
body:
<?xml version="1.0" encoding="UTF-8"?>
<nil-classes type="array"/>
error:
2014-01-24 01:54:45.430 Chat[5670:380b] Request finished, response:
headers:{
"Access-Control-Allow-Origin" = "*";
"Cache-Control" = "no-cache";
Connection = "keep-alive";
"Content-Length" = 590;
"Content-Type" = "application/xml; charset=utf-8";
Date = "Thu, 23 Jan 2014 17:54:43 GMT";
"QB-Token-ExpirationDate" = "2014-01-23 19:54:43 UTC";
"QuickBlox-REST-API-Version" = "0.1.1";
Server = "nginx/1.0.15";
Status = "202 Accepted";
"X-Rack-Cache" = "invalidate, pass";
"X-Request-Id" = 4bfc06211bb0c0f97dd09f41ae92cff1;
"X-Runtime" = "0.015643";
"X-UA-Compatible" = "IE=Edge,chrome=1";
}
body:
<?xml version="1.0" encoding="UTF-8"?>
<user>
<blob-id type="integer" nil="true"/>
<created-at type="datetime">2014-01-23T15:47:06Z</created-at>
<email nil="true"/>
<external-user-id type="integer" nil="true"/>
<facebook-id nil="true"/>
<full-name nil="true"/>
<id type="integer">806773</id>
<last-request-at type="datetime" nil="true"/>
<login>hehe</login>
<owner-id type="integer">5464</owner-id>
<phone nil="true"/>
<twitter-id nil="true"/>
<updated-at type="datetime">2014-01-23T15:47:06Z</updated-at>
<website nil="true"/>
<user-tags nil="true"/>
</user>
error:
2014-01-24 01:54:45.436 Chat[5670:811b] -[QBChat loginWithUser:] -> Chat server endpoint: muc.chat.quickblox.com, User JID: 806773-4354#chat.quickblox.com
2014-01-24 01:54:45.442 Chat[5670:310b] Request finished, response:
headers:{
"Access-Control-Allow-Origin" = "*";
"Cache-Control" = "no-cache";
Connection = "keep-alive";
"Content-Length" = 590;
"Content-Type" = "application/xml; charset=utf-8";
Date = "Thu, 23 Jan 2014 17:54:43 GMT";
"QB-Token-ExpirationDate" = "2014-01-23 19:54:43 UTC";
"QuickBlox-REST-API-Version" = "0.1.1";
Server = "nginx/1.0.15";
Status = "202 Accepted";
"X-Rack-Cache" = "invalidate, pass";
"X-Request-Id" = 99a2c81bc8c28fddbcd7e3a134243ca3;
"X-Runtime" = "0.014854";
"X-UA-Compatible" = "IE=Edge,chrome=1";
}
body:
<?xml version="1.0" encoding="UTF-8"?>
<user>
<blob-id type="integer" nil="true"/>
<created-at type="datetime">2014-01-23T15:47:06Z</created-at>
<email nil="true"/>
<external-user-id type="integer" nil="true"/>
<facebook-id nil="true"/>
<full-name nil="true"/>
<id type="integer">806773</id>
<last-request-at type="datetime" nil="true"/>
<login>hehe</login>
<owner-id type="integer">5464</owner-id>
<phone nil="true"/>
<twitter-id nil="true"/>
<updated-at type="datetime">2014-01-23T15:47:06Z</updated-at>
<website nil="true"/>
<user-tags nil="true"/>
</user>
error:
2014-01-24 01:54:45.448 Chat[5670:310b] -[QBChat loginWithUser:] -> Chat server endpoint: muc.chat.quickblox.com, User JID: 806773-4354#chat.quickblox.com
2014-01-24 01:54:45.464 Chat[5670:310b] Performing async request:
POST http://api.quickblox.com/push_tokens.xml
headers:{
"QB-SDK" = "iOS 1.8";
"Qb-Token" = 0744438380a2cbfadf8e859b98d8bab319dd4383;
"QuickBlox-REST-API-Version" = "0.1.1";
}
parameters:{
"device[platform]" = iOS;
"device[udid]" = "D44DD5B1-A5B3-4E61-B761-A4DE8BB28F72";
"push_token[client_identification_sequence]" = 8efc776c0ea913f3cd8785f68bb4d7f3bb3a5ffcfde76ed1beab1181d8aae8af;
"push_token[environment]" = development;
}
2014-01-24 01:54:46.107 Chat[5670:7b1b] Request finished, response:
headers:{
"Access-Control-Allow-Origin" = "*";
"Cache-Control" = "max-age=0, private, must-revalidate";
Connection = "keep-alive";
"Content-Length" = 272;
"Content-Type" = "application/xml; charset=utf-8";
Date = "Thu, 23 Jan 2014 17:54:44 GMT";
Etag = "\"36f956ca6271157cf23485a0efdd1770\"";
"QB-Token-ExpirationDate" = "2014-01-23 19:54:44 UTC";
"QuickBlox-REST-API-Version" = "0.1.1";
Server = "nginx/1.0.15";
Status = "201 Created";
"X-Rack-Cache" = "invalidate, pass";
"X-Request-Id" = a4319db211a2253aa7e98511d449e616;
"X-Runtime" = "0.042459";
"X-UA-Compatible" = "IE=Edge,chrome=1";
}
body:
<?xml version="1.0" encoding="UTF-8"?>
<push-token>
<client-identification-sequence>8efc776c0ea913f3cd8785f68bb4d7f3bb3a5ffcfde76ed1beab1181d8aae8af</client-identification-sequence>
<environment>development</environment>
<id type="integer">588770</id>
</push-token>
error:
2014-01-24 01:54:46.110 Chat[5670:7b1b] Performing async request:
POST http://api.quickblox.com/subscriptions.xml
headers:{
"QB-SDK" = "iOS 1.8";
"Qb-Token" = 0744438380a2cbfadf8e859b98d8bab319dd4383;
"QuickBlox-REST-API-Version" = "0.1.1";
}
parameters:{
"notification_channels" = apns;
}
2014-01-24 01:54:46.266 Chat[5670:811b] -[QBChat xmppStreamDidAuthenticate:] -> user: 806773, supportsStartTLS: 1, isSecure: 0
2014-01-24 01:54:46.273 Chat[5670:310b] Performing async request:
GET http://api.quickblox.com/data/Post.xml
headers:{
"QB-SDK" = "iOS 1.8";
"Qb-Token" = 0744438380a2cbfadf8e859b98d8bab319dd4383;
"QuickBlox-REST-API-Version" = "0.1.1";
}
parameters:{
"sort_asc" = datetime;
}
2014-01-24 01:54:46.276 Chat[5670:310b] Performing async request:
GET http://api.quickblox.com/data/Contact.xml
headers:{
"QB-SDK" = "iOS 1.8";
"Qb-Token" = 0744438380a2cbfadf8e859b98d8bab319dd4383;
"QuickBlox-REST-API-Version" = "0.1.1";
}
parameters:{
"contact_id" = 806773;
}
2014-01-24 01:54:46.280 Chat[5670:310b] Performing async request:
GET http://api.quickblox.com/data/Contact.xml
headers:{
"QB-SDK" = "iOS 1.8";
"Qb-Token" = 0744438380a2cbfadf8e859b98d8bab319dd4383;
"QuickBlox-REST-API-Version" = "0.1.1";
}
parameters:{
"user_identifier" = 806773;
}
2014-01-24 01:54:46.281 Chat[5670:310b] -[QBChat xmppStream:didSendIQ:] -> IQ: <iq type="get" id="5610067"><query xmlns="jabber:iq:roster"/></iq>
2014-01-24 01:54:46.282 Chat[5670:310b] -[QBChat xmppStream:didSendPresence:] -> Presence: <presence/>
2014-01-24 01:54:46.533 Chat[5670:811b] -[QBChat xmppStream:didReceiveIQ:] -> <iq xmlns="jabber:client" id="5610067" type="result" to="806773-4354#chat.quickblox.com/tigase-20326"><query xmlns="jabber:iq:roster"/></iq>
2014-01-24 01:54:46.615 Chat[5670:60b] objects: (null)
2014-01-24 01:54:46.614 Chat[5670:7b1b] Request finished, response:
headers:{
"Access-Control-Allow-Origin" = "*";
"Cache-Control" = "max-age=0, private, must-revalidate";
Connection = "keep-alive";
"Content-Length" = 60;
"Content-Type" = "application/xml; charset=utf-8";
Date = "Thu, 23 Jan 2014 17:54:44 GMT";
Etag = "\"81779d89d928c6e830957d0cee5976fa\"";
"QB-Token-ExpirationDate" = "2014-01-23 19:54:44 UTC";
"QuickBlox-REST-API-Version" = "0.1.1";
Server = "nginx/1.0.15";
Status = "304 Not Modified";
"X-Rack-Cache" = miss;
"X-Request-Id" = 76bb535a5aa49e342dbf67fc1ae66950;
"X-Runtime" = "0.019699";
"X-UA-Compatible" = "IE=Edge,chrome=1";
}
body:
<?xml version="1.0" encoding="UTF-8"?>
<data type="array"/>
error:
2014-01-24 01:54:46.620 Chat[5670:60b] objects: (null)
2014-01-24 01:54:46.622 Chat[5670:310b] Request finished, response:
headers:{
"Access-Control-Allow-Origin" = "*";
"Cache-Control" = "max-age=0, private, must-revalidate";
Connection = "keep-alive";
"Content-Length" = 60;
"Content-Type" = "application/xml; charset=utf-8";
Date = "Thu, 23 Jan 2014 17:54:44 GMT";
Etag = "\"81779d89d928c6e830957d0cee5976fa\"";
"QB-Token-ExpirationDate" = "2014-01-23 19:54:44 UTC";
"QuickBlox-REST-API-Version" = "0.1.1";
Server = "nginx/1.0.15";
Status = "304 Not Modified";
"X-Rack-Cache" = miss;
"X-Request-Id" = ea19e51670b676c6b618662924052c99;
"X-Runtime" = "0.019819";
"X-UA-Compatible" = "IE=Edge,chrome=1";
}
body:
<?xml version="1.0" encoding="UTF-8"?>
<data type="array"/>
error:
2014-01-24 01:54:46.703 Chat[5670:60b] Push notification subscribed
2014-01-24 01:54:46.703 Chat[5670:7b1b] Request finished, response:
headers:{
"Access-Control-Allow-Origin" = "*";
"Cache-Control" = "max-age=0, private, must-revalidate";
Connection = "keep-alive";
"Content-Length" = 67;
"Content-Type" = "application/xml; charset=utf-8";
Date = "Thu, 23 Jan 2014 17:54:44 GMT";
Etag = "\"4f31ca96db448bb738a3923db737871d\"";
"QB-Token-ExpirationDate" = "2014-01-23 19:54:44 UTC";
"QuickBlox-REST-API-Version" = "0.1.1";
Server = "nginx/1.0.15";
Status = "201 Created";
"X-Rack-Cache" = "invalidate, pass";
"X-Request-Id" = e437212cb4bf3ecfc2170f85f9dbcbfb;
"X-Runtime" = "0.022193";
"X-UA-Compatible" = "IE=Edge,chrome=1";
}
body:
<?xml version="1.0" encoding="UTF-8"?>
<nil-classes type="array"/>
error:
2014-01-24 01:54:46.929 Chat[5670:310b] Request finished, response:
headers:{
"Access-Control-Allow-Origin" = "*";
"Cache-Control" = "max-age=0, private, must-revalidate";
Connection = "keep-alive";
"Content-Length" = 651;
"Content-Type" = "application/xml; charset=utf-8";
Date = "Thu, 23 Jan 2014 17:54:44 GMT";
Etag = "\"bfdd8b18a9743a7d8aa5315262ec961d\"";
"QB-Token-ExpirationDate" = "2014-01-23 19:54:44 UTC";
"QuickBlox-REST-API-Version" = "0.1.1";
Server = "nginx/1.0.15";
Status = "304 Not Modified";
"X-Rack-Cache" = miss;
"X-Request-Id" = 14ffdcfa6108ebb2614dd90721299f23;
"X-Runtime" = "0.020542";
"X-UA-Compatible" = "IE=Edge,chrome=1";
}
body:
<?xml version="1.0" encoding="UTF-8"?>
<data type="array" class_name='Post' skip='0' limit='100'>
<Post>
<_id>52e13bd8535c1278a4004f83</_id>
<_parent_id nil="true"/>
<created-at type="integer">1390492632</created-at>
<datetime type="integer">20140123235708343</datetime>
<info>entity=post type=text post_identifier=20140123235708343a806749 datetime=20140123235708343 poster_id=806749 blob_id= text=post no</info>
<post_identifier>20140123235708343a806749</post_identifier>
<poster_id>806749</poster_id>
<updated-at type="integer">1390492632</updated-at>
<user-id type="integer">806749</user-id>
</Post>
</data>
error:
2014-01-24 01:54:46.931 Chat[5670:60b] objects: (
"
className:Post
createdAt:2014-01-23 15:57:12 +0000
updatedAt:2014-01-23 15:57:12 +0000
ID:52e13bd8535c1278a4004f83
parentID:(null)
userID:806749
fields:{\n datetime = 20140123235708343;\n info = \"entity=post type=text post_identifier=20140123235708343a806749 datetime=20140123235708343 poster_id=806749 blob_id= text=post no\";\n \"post_identifier\" = 20140123235708343a806749;\n \"poster_id\" = 806749;\n}
permissions:(null)"
)
2014-01-24 01:54:47.317 Chat[5670:811b] -[QBChat xmppStream:didSendPresence:] -> Presence: <presence/>
UPDATE 2:
When I enter background, then enter foreground, I will check if chat is logged in. using this condition:
[QBChat instance].isLoggedIn
(1)If it's logged in, i fetch several tables
(2)if not, I create a session and login again
My Guess:
Is it possible that after entering the background for a while, the session has been destroyed, while [QBChat instance].isLoggedIn still returns YES? If this is the case, then how can I test whether I can safely fetch tables?
The screen always turns black within 3 seconds after entering the foreground. I tried both iOS 6/7
Note: The screen goes black, but the app does not crash. because sendPresence timer still ticking every 15 seconds:
-[QBChat xmppStream:didSendPresence:] -> Presence: <presence/>
UPDATE 3:
I just catch a crash
UPDATE 4:
Device Log (Xcode organizer)
Date/Time: 2014-01-23 23:45:40.090 +0800
OS Version: iOS 7.0.2 (11A501)
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_PROTECTION_FAILURE at 0x0000000027c1fff8
Triggered by Thread: 0
Thread 0 Crashed:
0 libobjc.A.dylib 0x39411751 lookUpImpOrForward + 5
1 libobjc.A.dylib 0x3941172b lookUpImpOrNil + 23
2 libobjc.A.dylib 0x3940acb3 class_respondsToSelector + 31
3 libobjc.A.dylib 0x3941a059 -[NSObject respondsToSelector:] + 29
4 Chat 0x00141491 -[QBApplicationRedelegate applicationWillResignActive:] (QBApplicationRedelegate.m:111)
5 Chat 0x001414cd -[QBApplicationRedelegate applicationWillResignActive:] (QBApplicationRedelegate.m:112)
6 Chat 0x001414cd -[QBApplicationRedelegate applicationWillResignActive:] (QBApplicationRedelegate.m:112)
7 Chat 0x001414cd -[QBApplicationRedelegate applicationWillResignActive:] (QBApplicationRedelegate.m:112)
8 Chat 0x001414cd -[QBApplicationRedelegate applicationWillResignActive:] (QBApplicationRedelegate.m:112)
I solved the question by registering push notification in ChatDidLogin instead of user did login delegate method.
the problem is that login use will return success even use has already logged in, which will register push notification twice. However, chat will fail if already logged in.
My app constantly checks whether the server is logged in by
+ (BOOL)isServerLoggedIn {
return [QBChat instance].isLoggedIn;
}
if not logged in, I create session with delegate again, which will then log user in upon success, and then log chat in upon success.
Edit: there is a problem with this design:
What if [QBChat instance].isLoggedIn is true but QBUser is not logged in??
How to check whether QBUser is logged in?
You can be separately logged in to Chat and to REST services.
To check if QBUser is logged in - just create a separate variable and set it to YES in delegate:
// QuickBlox queries delegate
- (void)completedWithResult:(Result *)result{
if(result.success){
// User Login
if([result isKindOfClass:QBUUserLogInResult.class]){
self.userLoggedIn = YES;
}
}
}