diff --git a/Source/ARTRealtimePresence.m b/Source/ARTRealtimePresence.m index d9c373553..10b4def56 100644 --- a/Source/ARTRealtimePresence.m +++ b/Source/ARTRealtimePresence.m @@ -49,6 +49,16 @@ - (void)get:(void (^)(NSArray *, ARTErrorInfo *))callback - (void)get:(ARTRealtimePresenceQuery *)query callback:(void (^)(NSArray *, ARTErrorInfo *))callback { [_channel throwOnDisconnectedOrFailed]; + + switch (_channel.state) { + case ARTRealtimeChannelFailed: + case ARTRealtimeChannelDetached: + if (callback) callback(nil, [ARTErrorInfo createWithCode:0 message:@"invalid channel state"]); + return; + default: + break; + } + [_channel attach:^(ARTErrorInfo *error) { if (error) { callback(nil, error);