objective c - Send Bird didReceiveMessage Not Works -


so created simple application test out sendbird services, best, have read documentation, , @ moment. made something.. , got problem there, when have call didreceivemessage or why mine not working?

mycode

    - (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 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 %@ message : %@ in channel :",sender.description,message.description);     } else {         nslog(@"failed");     } } @end 

did register current class channel's delegate? need when channel receives message, call delegate received message.

so in class, assuming it's uiviewcontroller, declare conform so:

@interface openchannelviewcontroller : viewcontroller<sbdchanneldelegate> @end 

somewhere in viewdidload, should add class channel delegate.

- (void)viewdidload {   [sbdmain addchanneldelegate:self identifier:unique_handler_id]; } 

now should receive messages. info taken here: https://docs.sendbird.com/ios?_ga=1.152151677.594130729.1491427400#open_channel_3_receiving_messages

good luck!


Comments