didReceiveIncomingCall被调用,虽然它是一个未接来电
当应用程序在后台,并且来电已经发生,用户没有拿起。 当用户回到应用程序- (void)client:(id<SINCallClient>)client didReceiveIncomingCall:(id<SINCall>)call
正在被调用。
重现步骤
- 用户来电者
- 用户B接收器
- 用户B在后台有应用程序
- 用户B呼叫用户A.
- 用户B在用户A接通之前挂断电话
- 用户B打开应用程序和
- (void)client:(id<SINCallClient>)client didReceiveIncomingCall:(id<SINCall>)call
立即被调用,并且call.status
为0,所以SINCallStateInitiating
这是正常的行为? 有没有办法知道这个电话是不是“可用”了?
我正在使用iOS 10和Sinch版本:3.9.7-26289c8
谢谢!
编辑
显示如何初始化Sinch客户端,Manged Push,Notifications等代码下面的所有代码都发生在AppDelegate
AppDelegate中
@interface AppDelegate ()<SINCallClientDelegate,SINManagedPushDelegate,SINClientDelegate>
初始化SINManagedPush :
在didFinishLaunchingWithOptions
中的didFinishLaunchingWithOptions
self.push = [Sinch managedPushWithAPSEnvironment:SINAPSEnvironmentAutomatic]; self.push.delegate = self; [self.push setDesiredPushTypeAutomatically];
初始化Sinch客户端 :用户login后
- (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]; } }
注册远程通知
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { [self.push application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken]; }
接收推送通知
- (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 – >不pipe呼叫是否“存在”,都会调用此函数
- (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}]; }
你是否将推送数据传递给客户? 如果是这样,你可以检查结果中的有效载荷
使用示例:
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 }