我现在花了几个小时试图弄清楚为什么didRegisterForRemoteNotificationsWithDeviceToken没有被调用。它以前有效。我已经好几个星期没碰它了。现在停止工作。
这是我的设置:
didRegisterForRemoteNotificationsWithDeviceToken坐在SceneDelegateSceneDelegate为UNUserNotificationCenterDelegateUNUserNotificationCenter.current().delegate = self在func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions)UNUserNotificationCenter.current().requestAuthorization { granted, error in... 在我的应用程序的UIViewControllers之一,特别是在viewDidLoad该控制器的-我得到授权弹出,接受我得到一个当true了回grantedUNUserNotificationCenter.current().getNotificationSettings { settings in ...支票内settings.authorizationStatus == .authorizedtruedidFailToRegisterForRemoteNotificationsWithError至少检查过是否被调用 - 但它没有。didReceive委托被调用但如果我通过终端命令发送测试通知,模拟器xcrun simctl push...和我得到的通知。我已经设置了一个 UICollectionView ,如下所示。我正在尝试设置自定义单元格高度,以便集合在必须滚动之前适合屏幕上的 3 个单元格。但是,这种定制工作不起作用或似乎被忽略了。有谁知道我做错了什么?
class CoopOverviewViewController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource {
@IBOutlet weak var CampaignBrandSliderBackground: UIView!
@IBOutlet weak var CampaignBrandSlider: UISegmentedControl!
@IBOutlet weak var CampaignCollectionView: UICollectionView!
// TODO: load real data and replace with campaign model
let campaignImages: [UIImage] = [UIImage(named: "icon-black")!,UIImage(named: "icon-white")!,UIImage(named: "icon-black")!,UIImage(named: "icon-white")!]
let apiService = APIService()
override func viewDidLoad() {
super.viewDidLoad()
CampaignBrandSliderBackground.layer.cornerRadius = 10
// do other stuff...
// Conform to UICollectionViewDelegate Protocol:
CampaignCollectionView.dataSource = self
CampaignCollectionView.delegate = self
// Adjust Layout of CollectionViewCell: set cell height …Run Code Online (Sandbox Code Playgroud)