所以创建了一个简单的应用程序来测试 sendbird 服务,它们看起来最好,所以我已经阅读了他们的文档,并且在这一刻。我做了一些东西..我在那里遇到了问题,我什么时候必须打电话给 didReceiveMessage 或者为什么我的不工作?
我的代码
- (IBAction)connnect:(id)sender {
[SBDOpenChannel getChannelWithUrl:@"iDict" completionHandler:^(SBDOpenChannel * _Nullable channel, SBDError * _Nullable error) {
if (error != nil) {
NSLog(@"Error 1 : %@", error.localizedDescription);
return;
}
[channel enterChannelWithCompletionHandler:^(SBDError * _Nullable error) {
if (error != nil) {
NSLog(@"Error: %@", error);
return;
}
NSLog(@"Connected to Channel : %@",channel.channelUrl);
// ...
}];
}];
}
- (IBAction)sendMessage:(id)sender {
[self.channel sendUserMessage:@"pop" data:@"Hey" completionHandler:^(SBDUserMessage * _Nullable userMessage, SBDError * _Nullable error) {
if (error != nil) {
NSLog(@"Error: %@", error);
return;
}
}];
}
- (void)channel:(SBDBaseChannel * _Nonnull)sender didReceiveMessage:(SBDBaseMessage * _Nonnull)message {
if (sender == self.channel) {
NSLog(@"From Button.Message Received From %@ message is : %@ in channel :",sender.description,message.description);
} else {
NSLog(@"Failed");
}
}
@end