Browse SDKs · iOS
Platform
SDKsiOSEnterprise

Handle call events

Add and remove the OpenIM iOS SDK call signaling delegate in one place.

Copy

Implement the OIMSignalingListener protocol in your call state controller to observe incoming call invitations, participant acceptance or rejection, timeouts, and stream updates. Register and unregister the listener using the same retained instance via [OIMManager callbacker].

Code example

@interface CallStore () <OIMSignalingListener>
@end

@implementation CallStore

- (void)startListening {
    [[OIMManager callbacker] addSignalingListener:self];
}

- (void)stopListening {
    [[OIMManager callbacker] removeSignalingListener:self];
}

- (void)onReceiveNewInvitation:(OIMSignalingInfo *)info {
    [self upsertCall:info state:@"ringing"];
}

- (void)onInviteeAccepted:(OIMSignalingInfo *)info {
    [self mergeCall:info state:@"accepted"];
}

- (void)onInviteeRejected:(OIMSignalingInfo *)info {
    [self mergeCall:info state:@"rejected"];
}

- (void)onInvitationCancelled:(OIMSignalingInfo *)info {
    [self finishCall:info.invitation.roomID];
}

- (void)onInvitationTimeout:(OIMSignalingInfo *)info {
    [self finishCall:info.invitation.roomID];
}

- (void)onInviteeAcceptedByOtherDevice:(OIMSignalingInfo *)info {
    [self stopRinging:info.invitation.roomID];
}

- (void)onInviteeRejectedByOtherDevice:(OIMSignalingInfo *)info {
    [self stopRinging:info.invitation.roomID];
}

- (void)onHunguUp:(OIMSignalingInfo *)info {
    [self finishCall:info.invitation.roomID];
}

- (void)onRoomParticipantConnected:(OIMParticipantConnectedInfo *)info {
    [self mergeParticipants:info roomID:info.roomID];
}

- (void)onRoomParticipantDisconnected:(OIMParticipantConnectedInfo *)info {
    [self removeParticipants:info roomID:info.roomID];
}

- (void)onStreamChange:(OIMMeetingStreamEvent *)event {
    [self updateStream:event roomID:event.roomID];
}

@end

State changes after the call

  • State merge key: Merge all incoming signaling events using roomID as the primary key. For participant rosters within multi-party calls, combine roomID and userID.
  • Lifecycle management: When logging out, switching user accounts, or tearing down the call controller, invoke removeSignalingListener: with the exact listener instance registered earlier to avoid memory leaks or cross-account event collisions.