didReceiveIncomingCall is called although it is a

2019-09-15 15:58发布

When the app is in background and an incoming call has happened and the user didn't pick up. When the user gets back into the app - (void)client:(id<SINCallClient>)client didReceiveIncomingCall:(id<SINCall>)call is being invoked.

Steps to reproduce

  • User A caller
  • User B receiver
  • User B has the app in background
  • User B calls user A
  • User B hangs up the call before user A picks up
  • User B opens the app and - (void)client:(id<SINCallClient>)client didReceiveIncomingCall:(id<SINCall>)call gets immediately called and the call.status is 0 so SINCallStateInitiating

Is this the normal behaviour? Is there a way to know this call is not "available" anymore?

I am working with iOS 10 and Sinch version: 3.9.7-26289c8

Thanks!

EDIT

Showing the code on how I initialize Sinch client, Manged Push, Notifications, etc. All the below code takes place inside the AppDelegate

AppDelegate

@interface AppDelegate ()<SINCallClientDelegate,SINManagedPushDelegate,SINClientDelegate>

Initializing SINManagedPush:

AppDelegate in didFinishLaunchingWithOptions

self.push = [Sinch managedPushWithAPSEnvironment:SINAPSEnvironmentAutomatic];
self.push.delegate = self;
[self.push setDesiredPushTypeAutomatically];

Initializing Sinch Client: once the user is logged in

- (void)initSinchClientWithUserId:(NSString *)userId {

    if (!_client) {
        _client = [Sinch clientWithApplicationKey:[BCEnvironment sinchAppKey]
                                applicationSecret:[BCEnvironment sinchAppSecret]
                                  environmentHost:[BCEnvironment sinchEnvHost]
                                           userId:userId];

        BCUser *user = [BCDataProvider loggedInUser];
        [self.push setDisplayName:[user displayName]];

        _client.delegate = self;
        _client.callClient.delegate = self;
        [_client setSupportCalling:YES];
        [_client enableManagedPushNotifications];
        [_client start];
    }
}

Registering for remote notifications

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    [self.push application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}

Receiving push notification

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
    [self.push application:application didReceiveRemoteNotification:userInfo];
}

SINManagedPushDelegate

- (void)managedPush:(id<SINManagedPush>)unused didReceiveIncomingPushWithPayload:(NSDictionary *)payload forType:(NSString *)pushType {
    [self.client relayRemotePushNotification:payload];
}

SINCallClientDelegate -> This is called no matter if the call doesn't "exist" anymore

- (void)client:(id<SINCallClient>)client didReceiveIncomingCall:(id<SINCall>)call {
    //This opens the calling screen, even if the call is "old" and the caller has already hangup or the call timed out, etc. Here is where I am having the issue
    [[NSNotificationCenter defaultCenter] postNotificationName:@"DidReceiveCall" object:nil userInfo:@{@"call":call}];
}

标签: ios voip sinch
1条回答
地球回转人心会变
2楼-- · 2019-09-15 16:41

Are you relaying the push data to the client your self? If so you can check the payload in the result

https://download.sinch.com/docs/iOS/latest/reference/html/Protocols/SINNotificationResult.html#//api/name/isValid

Example use:

id result = [self.client relayLocalNotification:notification];
if ([result isCall] && [[result callResult] isTimedOut]) { 
    NSString remoteUserId = [[result callResult] remoteUserId]; // present       
    UIAlert indicating user has a missed call. } 
else if([result isMessage]){ 
    NSString messageId = [[result messageResult] messageId]; // show view controller that highlights the particular message 
}
查看更多
登录 后发表回答