 
     private func applicationDidBecomeActive(notification: NSNotification) {
         log("Application Did Become Active Notification")
+        applicationInactive = false
         dispatch_async(smartcardQueue) {
             self.openSmartcard()
             self.checkSmartcard()

    private var observers: [ObserverProxy] = []
    private let smartcardQueue: dispatch_queue_t
    private var retryingConnection: Bool = false

    // Communication objects
    private let smartcard = PBSmartcard()


    private func accessoryDisconnected(notification: NSNotification) {
        log("Accessory Disconnected Notification")
        if applicationInactive {
            // Ignore accessory connection state notifications when application is not active.
            return
        }

