gpt4 book ai didi

IOS 以编程方式拒绝来电?

转载 作者:行者123 更新时间:2023-11-28 08:17:00 24 4
gpt4 key购买 nike

有没有办法在 swift 中以编程方式拒绝来电。我的代码是这样的:

self.callCenter.callEventHandler = {(_ call: CTCall) -> Void in
if call.callState == CTCallStateDisconnected {
print("Call has been disconnected")
}
else if call.callState == CTCallStateConnected {
print("Call has just been connected")
}
else if call.callState == CTCallStateIncoming {
print("Call is incoming")
}
else {
print("None of the conditions")
}

我是这样检测来电状态的。但我不知道如何更改 CTCAllcallstate 。请帮助我!

最佳答案

#import <CoreTelephony/CTCall.h>
#import <CoreTelephony/CTCallCenter.h>
#import <CoreTelephony/CTCarrier.h>
#import <CoreTelephony/CTTelephonyNetworkInfo.h>

@interface MMCallNotificationManager()
@property (nonatomic, strong) CTCallCenter *callCenter;
@property (nonatomic) BOOL callWasStarted;
@end

@implementation MMCallNotificationManager

- (instancetype)init
{
self = [super init];

if (self) {

self.callCenter = [[CTCallCenter alloc] init];
self.callWasStarted = NO;

__weak __typeof__(self) weakSelf = self;

[self.callCenter setCallEventHandler:^(CTCall *call) {

if ([[call callState] isEqual:CTCallStateIncoming] ||
[[call callState] isEqual:CTCallStateDialing]) {

if (weakSelf.callWasStarted == NO) {

weakSelf.callWasStarted = YES;

NSLog(@"Call was started.");
}

} else if ([[call callState] isEqual:CTCallStateDisconnected]) {

if (weakSelf.callWasStarted == YES)
{
weakSelf.callWasStarted = NO;

NSLog(@"Call was ended.");
}
}
}];
}

return self;
}

@end

关于IOS 以编程方式拒绝来电?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42344200/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com