didReceiveIncomingCall is called although it is a missed call

谁说胖子不能爱 提交于 2019-12-12 04:30:01

问题


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}];
}

回答1:


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 
}


来源:https://stackoverflow.com/questions/40423173/didreceiveincomingcall-is-called-although-it-is-a-missed-call

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!