- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经在我的应用程序中启用了 UserNotifications,除了一开始(首次安装)时出现的错误之外,一切都运行良好。本地通知需要询问用户发送通知的权限,并且它在首次安装时作为警报出现,用户可以选择他/她的选项(“允许”、“不允许”)。问题是,此通知请求在 AppDelegate 中的“applicationDidFinishLaunchingWithOptions”方法中调用,并被另一个警报中断,该警报是我在 viewDidLoad 中启动的 LocalAuthorization(TouchID) 警报。有没有一种方法可以将所有这些警报放入某种队列中,以便它们被一个接一个地触发而不是相互重叠?或者,以某种方式告诉 viewDidLoad 警报等待 AppDelegate 警报完成显示?欢迎任何意见。谢谢。
最佳答案
扩展 ViewController:UNUserNotificationCenterDelegate {
//for displaying notification when app is in foreground
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
//If you don't want to show notification when app is open, do something here else and make a return here.
//Even you you don't implement this delegate method, you will not see the notification on the specified controller. So, you have to implement this delegate and make sure the below line execute. i.e. completionHandler.
completionHandler([.alert, .badge, .sound])
}
// For handling tap and user actions
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
switch response.actionIdentifier {
case "action1":
print("Action First Tapped")//here you can your alert
case "action2":
print("Action Second Tapped")//here you can your alert
default:
break
}
completionHandler()
}
}
关于swift - LocalNotification警报干扰,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48217730/
我想使用 UILocalNotifications 作为应用程序的后台计时器。用户可以像远程通知一样禁用此通知吗?如果用户禁用了应用程序的远程通知,本地通知是否也会被禁用? 最佳答案 我最终编写了一个
是否有任何原因导致我的本地通知显示在通知中心但未弹出?有什么设置可以让它弹出吗? 最佳答案 本地通知将与所有其他通知一样显示,作为开发者,您对此无能为力。 通知的默认设置是将其显示为屏幕顶部的横幅,而
我创建了一个应用程序,该应用程序每天通知用户一次。 为此我使用了下面的代码 func application(application: UIApplication, didRegisterUserN
我正在安排计时器并向用户发送有关某些数据的一些本地通知,例如 - 如果附近有商店。 func configureNotification(shop: Shop) { let notificat
这是我的 didEnterRegion 函数代码。问题是通知在进入和退出时触发。如何仅在用户输入位置时触发通知? func locationManager(manager: CLLocationMan
我有一个 iOS 应用程序,它每 4 小时左右触发一次本地通知。这似乎按预期成功运行。不过,我担心的是如果用户重新启动设备该怎么办。任何现有的本地通知是否仍然存在?以下是我如何触发本地通知:
我正在通过单击按钮安排基于位置的 UILocalNotification。但是当我尝试通过再次单击同一个按钮来取消 localNotification 时,它不会取消通知。我正在使用 UIApplic
我已使用 UILocalNotification() 创建了通知,并且我正在尝试清除收到的通知,而不删除计划的其余通知。 这是我尝试使用的代码: UIApplication.sharedApplica
我正在开发一个应用程序,该应用程序应该在 21 天内每天发送本地通知,但随后它应该停止发送一周。我知道我可以设置 fireDate 并且可以设置重复间隔,但是有什么方法可以设置像最后一个 fireDa
我有一个日期数组 NSArray *datesArray=[NSArray arrayWithObjects: @"2014-09-14 00:00:00",@"2014-08-21 07:12:36
我在我的应用程序中设置了一个警报,它会产生一个显示为横幅的本地通知。我怎样才能让它显示为必须单击以关闭它或理想情况下直接打开应用程序的警报? 这就是我目前设置通知的方式 window.plugin.n
我在我的 Ionic 应用程序中使用 ngCordova LocalNotification 插件,我试图让它以随机时间跨度重复。 例如,用户将触发通知在 1 分钟内启动,然后我需要在另外 2 分钟内
如果我从后台强行关闭我的应用程序。然后本地通知来了。如果点击本地通知,当应用程序在前台运行时我的方法不会被调用。我在 iOS 中较新。请帮忙。 -(void)application:(UIApplic
我正在开发一款应用,该应用会向用户发送本地通知,提醒他们某双鞋即将上市。 我认为应该在前一天晚上 8:00 发送通知。 这是我的日期字符串(称为 releaseDate): 2014-04-10 00
我正在使用经 Teleriks 验证的 LocalNotification 插件来将本地通知发送到运行我的应用程序的设备。我允许他们选择自己喜欢的通知间隔(1-2-3 或 4 小时),但我希望这些通知
我有一个场景,我安排了两个单独的 LocalNotifications。一个设置为在午夜十点开火,另一个每小时开火一次。我可以通过在安排通知时设置通知的 UserInfo 来区分它们。 对于每小时通知
我正在学习 PhoneGap,我尝试使用 Notification Local Plugin ,但对我不起作用。 我正在尝试构建我的应用程序,但它在 XML AndroidManifest.xml 中
我有这段代码每天早上 7 点运行通知,它获取当前日期,然后在到达设定时间时运行通知,我的问题是如果时间已经超过设定的运行时间,那么它每天都会在用户当前时间运行,而不是我早上 7 点的时间,这是我的代码
我在我的应用程序中使用 LocalNotification。它工作正常,但一旦设置了 ApplicationIconBadgeNumber,就无法将其从应用程序中删除。如何删除它? 最佳答案 您需要设
基于此教程Simple iOS Alarm Clock Tutorial,我实现了AlarmClock App。 该通知运行良好,但没有声音。 为了解决这个问题,我尝试过: Fix-1,并且未选中/选
我是一名优秀的程序员,十分优秀!