문제

When sending a message I'm checking if opponent user is online / offline, so I can send him APNS if he's offline:

NSTimeInterval currentTimeInterval = [[NSDate date] timeIntervalSince1970];
NSTimeInterval userLastRequestAtTimeInterval  = [[self.opponent lastRequestAt] timeIntervalSince1970];
if((currentTimeInterval - userLastRequestAtTimeInterval) > 300)
{
  //SEND APNS
}

or

NSTimeInterval currentTimeInterval = ([[NSDate date] timeIntervalSince1970]);
if(currentTimeInterval - [self.opponent.lastRequestAt timeIntervalSince1970] > 300)
{
    //SEND APNS
}

Opponent user lastRequestAt is always returning 0.000000 so it's always sending APNS, even when opponent is online.

I can get my user.lastRequestAt after login with username and password.

What I'm getting "null" is the "opponent user" last request when sending him a message: opponent.lastRequestAt.

self.opponent is not null, I have it's ID but not lastRequestAt property:

[QBUUser]:  
    ID:859106   
    created at:(null)   
    updated at:(null)           
    externalUserID:0            
    blobID:0            
    facebookID:(null)           
    twitterID:(null)            
    full name:(null)            
    email:(null)            
    login:(null)            
    phone:(null)            
    tags:(null)            
    lastRequestAt:(null)            
    website:(null)

I'm just sending message to opponent using it's ID as reference:

QBChatMessage *message = [[QBChatMessage alloc] init];
message.recipientID = self.opponent.ID;
[[QBChat instance] sendMessage:message];

What I can read in Output panel about getting opponent is:

GET https://api.quickblox.com/users/859106.xml

headers:{
    "QB-SDK" = "iOS 1.8.2";
    "Qb-Token" = 41243a780d6cb457e5fe88c4cf6e4827c6f88568;
    "QuickBlox-REST-API-Version" = "0.1.1";
}

Should be necessary to get opponent QBUser data other way before sending him a message?

도움이 되었습니까?

해결책

Actually to send message you need only user ID. But if you want to use lastRequestAt field, you need to retrive QBUUser from Quickblox database. If you use [QBUUser user], you will create new user locally. Quickblox doesn't know this user yet.

다른 팁

Do you have any additional details?

I have just create new user in Admin panel, did login

  [QBUsers logInWithUserLogin:@"garrybons" password:@"garrybons"  delegate:self];

and log result:

2014-02-18 13:37:43.636 Snippets[66541:70b] QBUUserLogInResult, user=   
[QBUUser]:  
    ID:875661   
    created at:2014-02-18 11:31:00 +0000    
    updated at:2014-02-18 11:31:00 +0000            
    externalUserID:0            
    blobID:0            
    facebookID:(null)           
    twitterID:(null)            
    full name:(null)            
    email:(null)            
    login:garrybons         
    phone:(null)            
    tags:(null)            
    lastRequestAt:2014-02-18 11:31:24 +0000         
    website:(null), 
 socialProviderToken=(null), 
 socialProviderTokenExpiresAt=(null)

As you can see, lastRequestAt != null

Please provide additional details

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top