【发布时间】:2018-09-04 07:31:21
【问题描述】:
在我的应用程序中,我要求这样的通知权限:
UNUserNotificationCenter.current().requestAuthorization(options:[.badge, .alert, .sound]) { (granted, error) in
if granted {
DispatchQueue.main.async {
UIApplication.shared.registerForRemoteNotifications()
}
}
}
现在在测试时,我需要处理这个权限弹出但它不起作用,我尝试了这些代码:
XCUIApplication().alerts["“AppName” Would Like to Send You Notifications"].buttons["Allow"].tap() //didn't work.
addUIInterruptionMonitorWithDescription("Notification Dialog") { (alert) -> Bool in
alert.buttons["Allow"].tap()
return true
}
addUIInterruptionMonitorWithDescription("“AppName” Would Like to Send You Notifications") { (alert) -> Bool in
alert.buttons["Allow"].tap()
return true
}
addUIInterruptionMonitorWithDescription("Notifications may include alerts, sounds, and icon badges. These can be configured in Settings.") { (alert) -> Bool in
alert.buttons["Allow"].tap()
return true
}
但是没有任何效果。
【问题讨论】: