正规建网站公司,电影网站开发影院座位问题,阿里云服务器官网入口,asp做网站安全性背景#xff1a;
在iOS应用中#xff0c;当应用在前台运行时#xff0c;是不会默认弹出通知的。这是iOS的设计决定#xff0c;以避免用户在使用应用的过程中被打扰。然而#xff0c;如果你希望在应用在前台的时候也能收到通知#xff0c;你可以在你的应用代码中进行一些…背景
在iOS应用中当应用在前台运行时是不会默认弹出通知的。这是iOS的设计决定以避免用户在使用应用的过程中被打扰。然而如果你希望在应用在前台的时候也能收到通知你可以在你的应用代码中进行一些修改。
添加代理
在AppDelegate的didFinishLaunchingWithOptions:方法中设置通知中心的代理在你的AppDelegate中实现userNotificationCenter(_:willPresent:withCompletionHandler:)方法。
public func setNotifiAuth() {let center UNUserNotificationCenter.current()center.delegate selfcenter.requestAuthorization(options: [.alert, .badge, .sound]) { granted, error inif granted true {dePrint(允许通知)} else {dePrint(不允许通知)}}}extension LocalNotification: UNUserNotificationCenterDelegate {// 前台显示弹窗func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification) async - UNNotificationPresentationOptions {return .alert}
}