swift - 有没有办法去除 FaSTLane 截图中的 Push Notification Pop Up 确认消息?

标签 swift push-notification screenshot fastlane

我正在使用 FaSTLane 创建快照。由于我的应用程序使用“推送通知”,当应用程序启动时,它总是向用户显示请求授权发送此类消息的弹出窗口。在 AppDelegate UIApplication.shared.registerForRemoteNotifications() 中调用了一个方法,该方法是向用户“显示”弹出窗口的方法。

我试过类似的东西:

#if !DEBUG
  UIApplication.shared.registerForRemoteNotifications()
#endif
#if TARGET_IPHONE_SIMULATOR
  UIApplication.shared.registerForRemoteNotifications()
#endif

我也尝试过设置一个全局变量,但是一直找不到设置这个变量的地方,因为它永远不起作用

我总是得到同样的行为。

我预计第一次在模拟器中运行测试时,它不会显示消息。

谢谢。

最佳答案

我找到了一种避免此屏幕截图的简单方法。

在截取屏幕截图之前,我只需按下“允许”按钮

let systemAlerts = XCUIApplication(bundleIdentifier: "com.apple.springboard").alerts
if systemAlerts.buttons["Allow"].exists {
   systemAlerts.buttons["Allow"].tap()
}

简单又容易:)

关于swift - 有没有办法去除 FaSTLane 截图中的 Push Notification Pop Up 确认消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56024759/

相关文章:

android - PushSharp 是否需要打开运行它的机器的入站端口?

iOS拦截推送通知

python - 如何使用 CleverTap API 通过 python 发送推送?

c# - 使用 C# 截取任何外部应用程序的屏幕截图

swift - CBCentralManager State 最初注册为 .unknown

swift - UIAlertView 没有出现

ios - 如何在程序运行时禁用(停用)按钮?

swift - 如何将 alamofire 返回 json 解析为 Swift 中的字符串数组?

exception - Watir-Webdriver : take screenshot upon error/exception/fail. How to?

python - 截图中没有交互元素