Application (_: didFinishLaunchingWithOptions :) doesn't print anything inside

I am testing push notifications in a bare-bone application. Currently, all he does is receive push notifications and do nothing.

When I try to print()output information inside a function application(_:didFinishLaunchingWithOptions:), it refuses to print anything.

My code is:

class AppDelegate: UIResponder, UIApplicationDelegate {
    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        print("TEST TEST TEST")
        registerForPushNotifications(application)
        print("TEST TEST TEST")
        if let notification = launchOptions?[UIApplicationLaunchOptionsRemoteNotificationKey] as? [String: AnyObject] {
            print(notification)
            let aps = notification["aps"] as! [String: AnyObject]
            print(aps)
        }
        return true
    }

    func registerForPushNotifications(application: UIApplication) {
        let notificationSettings = UIUserNotificationSettings(forTypes: [.Badge, .Sound, .Alert], categories: nil)
        application.registerUserNotificationSettings(notificationSettings)
    }
}

None of the print lines in the function print anything on the console. I confirmed that they were hit with milestones. Why is nothing printed?

I managed to find a workaround with the help of warnings, and they work fine and give me all the information I need, but this does not help to answer why nothing is printed in the console.

Workaround:

class AppDelegate: UIResponder, UIApplicationDelegate {
    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        UIAlertView(title: "Remote Notif", message: "\(launchOptions)", delegate: nil, cancelButtonTitle: "OK").show()
        registerForPushNotifications(application)
        if let notification = launchOptions?[UIApplicationLaunchOptionsRemoteNotificationKey] as? [String: AnyObject] {
            UIAlertView(title: "Remote Notif", message: "\(notification)", delegate: nil, cancelButtonTitle: "OK").show()
            let aps = notification["aps"] as! [String: AnyObject]
            UIAlertView(title: "Remote Notif", message: "\(aps)", delegate: nil, cancelButtonTitle: "OK").show()
        }
        return true
    }

    func registerForPushNotifications(application: UIApplication) {
        let notificationSettings = UIUserNotificationSettings(forTypes: [.Badge, .Sound, .Alert], categories: nil)
        application.registerUserNotificationSettings(notificationSettings)
    }
}

I know that UIAlertView is deprecated, but it still works fine.

:
.
, (, push-).
.plist - ""


, , ​​ Wait for executable to be launched, ​​ Automatically, . , , , , push-. Xcode.

+4
1

, Wait for application to be launched , Xcode . , Xcode. Launch automatically , . xCode .

+5

All Articles