Search code examples
iosios6uiviewcontrollernsnotificationcenter

UIApplicationDidBecomeActiveNotification notifications not firing when run app first time


I have called this line of code in the init method and viewDidLoad method. However, the method applicationDidBecomeActiveNotification NEVER fires on the first time I run the app. It only runs after I have run it once.

 [[NSNotificationCenter defaultCenter] addObserver:self
          selector:@selector(applicationDidBecomeActiveNotificationAction)
                           name:UIApplicationDidBecomeActiveNotification
                                               object:nil];

Is this right? Is there a way for my viewController to be notified of UIApplicationDidBecomeActiveNotification the first time I run the app.


Solution

  • it won't be fired when you first time run the APP

    UIApplicationDidBecomeActiveNotification
    
    Posted when the application becomes active.
    An application is active when it is receiving events. An active application can be said to have focus. It gains focus after being launched, loses focus when an overlay window pops up or when the device is locked, and gains focus when the device is unlocked.
    

    you can just fire it youself after the APP is initialised.