What I came up with is to use Swift custom flags
In my AppDelegate in didFinishLaunchingWithOptions
I used conditional flag SKIP_NOTIFICATIONS_PROMPT
:
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
let brazeApiKey = ""
Appboy.start(withApiKey: brazeApiKey as! String, in:application, withLaunchOptions:launchOptions)
if #available(iOS 10, *) {
let center = UNUserNotificationCenter.current()
center.delegate = self as UNUserNotificationCenterDelegate
let options: UNAuthorizationOptions = [.alert, .sound, .badge]
#if SKIP_NOTIFICATIONS_PROMPT
// skipping permission request for uat test builds
#else
center.requestAuthorization(options: options) { (granted, error) in
Appboy.sharedInstance()?.pushAuthorization(fromUserNotificationCenter: granted)
}
#endif
UIApplication.shared.registerForRemoteNotifications()
} else {
let types : UIUserNotificationType = [.alert, .badge, .sound]
let setting : UIUserNotificationSettings = UIUserNotificationSettings(types:types, categories:nil)
UIApplication.shared.registerUserNotificationSettings(setting)
UIApplication.shared.registerForRemoteNotifications()
}
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
And I set this flag in Other Swift Flags section of Build Settings of the project for the Debug-development
flavor which is used by default when running Flutter Driver tests:
