开发者社区> 问答> 正文

Main Thread Checker: UI API called on a background

已解决

Main Thread Checker: UI API called on a background thread image.png

展开
收起
EMAS支持组 2022-09-16 14:00:25 363 0
1 条回答
写回答
取消 提交回答
  • 采纳回答

    请 pod update 一下,确定 AlicloudUT 版本为 5.2.0.12 ,已经修复该 UI 卡顿问题 。

    如还有该问题出现,请参考下面的排查步骤 :

    请检查工程中,是否在后台线程(非主线程)调用 AppKit、UIKit 相关的 API,比如 iOS 10+ 请求通知权限时,[application registerForRemoteNotifications]; 在回调非主线程中执行,则 Xcode 9 会报上述提示。

    [_notificationCenter requestAuthorizationWithOptions:UNAuthorizationOptionAlert | UNAuthorizationOptionBadge | UNAuthorizationOptionSound completionHandler:^(BOOL granted, NSError * _Nullable error) {
        if (granted) {
            // granted
            NSLog(@"User authored notification.");
            // 向APNs注册,获取deviceToken
            [application registerForRemoteNotifications];
        } else {
            // not granted
            NSLog(@"User denied notification.");
        }
    }];
    

    应修改为:

    [_notificationCenter requestAuthorizationWithOptions:UNAuthorizationOptionAlert | UNAuthorizationOptionBadge | UNAuthorizationOptionSound completionHandler:^(BOOL granted, NSError * _Nullable error) {
        if (granted) {
            // granted
            NSLog(@"User authored notification.");
            // 向APNs注册,获取deviceToken
            dispatch_async(dispatch_get_main_queue(), ^{
                [application registerForRemoteNotifications];
            };
        } else {
            // not granted
            NSLog(@"User denied notification.");
        }
    }];
    

    更多官方信息

    EMAS官网介绍:https://www.aliyun.com/product/emas

    Devops:https://www.aliyun.com/product/emascrash/mobile_devops

    移动热修复:https://www.aliyun.com/product/hotfix

    移动测试:https://www.aliyun.com/activity/emas/mqcexpert

    移动推送:https://www.aliyun.com/product/cps

    HTTPDNS:https://www.aliyun.com/product/httpdns

    EMAS 控制台: https://emas.console.aliyun.com/products

    2022-09-16 14:30:24
    赞同 展开评论 打赏
来源圈子
更多
收录在圈子:
基于阿里巴巴以及合作伙伴的最佳实践,围绕大前端、云原生领域的相关技术热点(小程序、Serverless、应用中间件、低代码、DevOps)展开行业探讨,与开发者一起探寻云原生时代应用研发的新范式。
问答排行榜
最热
最新

相关电子书

更多
Spring Boot2.0实战Redis分布式缓存 立即下载
CUDA MATH API 立即下载
API PLAYBOOK 立即下载