当应用程序处于后台并且来电已经发生并且用户没有接听时。当用户返回应用程序- (void)client:(id<SINCallClient>)client didReceiveIncomingCall:(id<SINCall>)call
时,正在调用。
重现的步骤
- (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
self.push = [Sinch managedPushWithAPSEnvironment:SINAPSEnvironmentAutomatic];
self.push.delegate = self;
[self.push setDesiredPushTypeAutomatically];
初始化Sinch客户端:用户登录后
- (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 - &gt;如果呼叫不再“存在”,则会调用此方法
- (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}];
}
答案 0 :(得分:0)
您是否将推送数据转发给客户端?如果是这样,您可以检查结果中的有效负载
使用示例:
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
}