Swift:要求用户同意两件事,一件通知在另一件之前闪烁?

时间:2016-12-23 21:09:17

标签: ios swift permissions notifications

因此,当我运行以下代码(并首次打开应用程序)时,位置权限请求首先闪烁,然后直接被通知1替换。如果我回答通知,则会显示位置。我问的是如何在第一个通知之前摆脱第二个通知的闪光。

final class ModelController: UIViewController {

    let locationManager = CLLocationManager()
    var window: UIWindow?
    var mapVC: MapVC?

    override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
        super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)

        locationManager.delegate = self
        locationManager.startMonitoringSignificantLocationChanges()
        locationManager.requestAlwaysAuthorization()

        UIApplication.shared.registerUserNotificationSettings(UIUserNotificationSettings(types: [.sound, .alert, .badge], categories: nil))
        UIApplication.shared.cancelAllLocalNotifications()
     }
 }

我的想法是因为这是在UI出现后调用的,不应该。 modelcontroller是在我的rootViewController的viewDidLoad中创建的。我也不知道这是否正确。

override func viewDidLoad() {
    super.viewDidLoad()
    mapView.delegate = self
    mapView.showsScale = true
    mapView.isPitchEnabled = false

    model = ModelController()
    model?.mapVC = self
}

0 个答案:

没有答案
相关问题