获取在线用户列表 PubNub 始终为零 Objective C
Get list of online users PubNub always nil Objective C
我的问题与 相同,但似乎没有有用的答案。
- I registed client with Pub & Sub key with Presence = YES
- I subsrcibed to "My channel" and could send msg to it
- I used debug console in PubNub admin to create 2 others clients, I could send msg together
- I enable Presence in Admin (http://prntscr.com/iyv7b1)
- I get list user that subscribe "My channel" by function:
[client hereNowForChannel:@"My channel" withVerbosity:PNHereNowState completion:^(PNPresenceChannelHereNowResult *result, PNErrorStatus *status)
{
if (!status) {
}
else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Couldn't get list of user." delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:nil];
[alert show];
}
}];
我试着改变
PNHereNowState -> PNHereNowUUID -> PNHereNowOccupancy
但是我的结果总是NIL。
任何人帮助我,请
我找到了问题的答案,希望对需要的人有所帮助
[client hereNowForChannel:client.globalChannel withCompletion:^(PNPresenceChannelHereNowResult *result, PNErrorStatus *status)
{
if (!status) {
PNPresenceChannelHereNowData *data = result.data;
if (data) {
NSArray *list = [data uuids];
}
}
else {
}
}];
属性data,如果还没有访问它,它不会被设置值,所以我调用了PNPresenceChannelHereNowData *data = result.data; 它有数据。
我的问题与
- I registed client with Pub & Sub key with Presence = YES
- I subsrcibed to "My channel" and could send msg to it
- I used debug console in PubNub admin to create 2 others clients, I could send msg together
- I enable Presence in Admin (http://prntscr.com/iyv7b1)
- I get list user that subscribe "My channel" by function:
[client hereNowForChannel:@"My channel" withVerbosity:PNHereNowState completion:^(PNPresenceChannelHereNowResult *result, PNErrorStatus *status)
{
if (!status) {
}
else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Couldn't get list of user." delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:nil];
[alert show];
}
}];
我试着改变
PNHereNowState -> PNHereNowUUID -> PNHereNowOccupancy
但是我的结果总是NIL。
任何人帮助我,请
我找到了问题的答案,希望对需要的人有所帮助
[client hereNowForChannel:client.globalChannel withCompletion:^(PNPresenceChannelHereNowResult *result, PNErrorStatus *status)
{
if (!status) {
PNPresenceChannelHereNowData *data = result.data;
if (data) {
NSArray *list = [data uuids];
}
}
else {
}
}];
属性data,如果还没有访问它,它不会被设置值,所以我调用了PNPresenceChannelHereNowData *data = result.data; 它有数据。