gpt4 book ai didi

ios - 如何使用 PushKit 的完成处理程序来报告NewIncomingCallWithUUID

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

我正在为我的应用程序使用 CallKit。

- (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(NSString *)type withCompletionHandler:(nonnull void (^)(void))completion
{
NSDictionary *payloadDict = payload.dictionaryPayload[@"aps"];

[self reportIncomingCallFrom:callerName withUUID:self.uuidCallkit completion:^(NSError * _Nullable error) {

}];
if (completion) {
completion();
}
}

我的问题是:我应该写ifcompletion然后调用completion,还是直接调用completion();?那么哪个是正确的?

- (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(NSString *)type withCompletionHandler:(nonnull void (^)(void))completion
{
NSDictionary *payloadDict = payload.dictionaryPayload[@"aps"];

[self reportIncomingCallFrom:callerName withUUID:self.uuidCallkit completion:^(NSError * _Nullable error) {

}];

completion();
}

这是来电报告的方法。

- (void)reportIncomingCallFrom:(NSString *) from withUUID:(NSUUID *)uuid completion:(nullable void (^)(NSError *_Nullable error))completion
{
CXHandle *callHandle = [[CXHandle alloc] initWithType:CXHandleTypeGeneric value:from];
CXCallUpdate *callUpdate = [[CXCallUpdate alloc] init];

callUpdate.remoteHandle = callHandle;
callUpdate.supportsDTMF = YES;
callUpdate.supportsHolding = NO;
callUpdate.supportsGrouping = NO;
callUpdate.supportsUngrouping = NO;
callUpdate.hasVideo = NO;

NSLog(@"income uuid here for income call %@",uuid);

[self.callKitProvider reportNewIncomingCallWithUUID: uuid update:callUpdate completion:^(NSError *error) {
if (!error) {
NSLog(@"Incoming call successfully reported.");
} else {
NSLog(@"Failed to report incoming call successfully: %@.", [error localizedDescription]);
}

completion(error);
}];
}

有时我在后台收不到推送。

我想知道我上面的方法是否正确。

最佳答案

在这种情况下,直接调用completion()或者之前检查是否不是nil,是等价的,因为completion已经声明为非空

因此,您可以直接调用 completion() ,如果您遇到问题,那不是因为这个。

关于ios - 如何使用 PushKit 的完成处理程序来报告NewIncomingCallWithUUID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59067692/

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