虽然是未接来电,但会调用 didReceiveIncomingCall [英] didReceiveIncomingCall is called although it is a missed call
问题描述
当应用在后台并且有来电但用户没有接听时.当用户重新进入应用时 - (void)client:(id
正在被调用.
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.
重现步骤
- 用户 A 呼叫者
- 用户 B 接收者
- 用户 B 在后台运行该应用
- 用户 B 呼叫用户 A
- 用户 B 在用户 A 接听前挂断电话
- 用户 B 打开应用程序,
- (void)client:(id
立即被调用,)client didReceiveIncomingCall:(id )call call.status
是 0 所以SINCCallStateInitiating
- 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 thecall.status
is 0 soSINCallStateInitiating
这是正常行为吗?有没有办法知道这个电话不再可用"?
Is this the normal behaviour? Is there a way to know this call is not "available" anymore?
我正在使用 iOS 10 和 Sinch 版本:3.9.7-26289c8
I am working with iOS 10 and Sinch version: 3.9.7-26289c8
谢谢!
编辑
显示我如何初始化 Sinch 客户端、托管推送、通知等的代码.以下所有代码都发生在 AppDelegate 中
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()
初始化 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 -> 无论调用是否不再存在",都会调用此方法
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}];
}
推荐答案
您是否自己将推送数据中继到客户端?如果是这样,您可以检查结果中的有效负载
Are you relaying the push data to the client your self? If so you can check the payload in the result
示例使用:
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
}
这篇关于虽然是未接来电,但会调用 didReceiveIncomingCall的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!