Questions tagged [uiapplicationdelegate]

UIApplicationDelegate is a part of the UIKit framework used in iOS development

UIApplicationDelegate Protocol is available in /System/Library/Frameworks/UIKit.framework since iOS 2.0.

It declares methods that are implemented by the delegate of UIApplication object. It gives information on key events during application execution (finish launching, terminated, low memory, ...) (from iOS developer guide)

initial help

sample code

  • Could be found also in the official documentation
523 questions
238
votes
7 answers

applicationWillEnterForeground vs. applicationDidBecomeActive, applicationWillResignActive vs. applicationDidEnterBackground

Which is the proper delegate to implement when an application is waking up from being in the background and you want it to prep it to be active? applicationWillEnterForeground vs applicationDidBecomeActive -- What's the difference? Which is the…
Paul
  • 5,043
  • 7
  • 24
  • 24
201
votes
9 answers

Is there any way to check if iOS app is in background?

I want to check if the app is running in the background. In: locationManagerDidUpdateLocation { if(app is runing in background){ do this } }
193
votes
12 answers

Handling applicationDidBecomeActive - "How can a view controller respond to the app becoming Active?"

I have the UIApplicationDelegate protocol in my main AppDelegate.m class, with the applicationDidBecomeActive method defined. I want to call a method when the application returns from the background, but the method is in another view controller.…
Calvin
  • 8,697
  • 7
  • 43
  • 51
192
votes
29 answers

Detect if the app was launched/opened from a push notification

Is it possible to know if the app was launched/opened from a push notification? I guess the launching event can be caught here: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { if…
110
votes
4 answers

Behaviour for significant change location API when terminated/suspended?

This is the section from the CLLocationManager documentation describing the app behavior with startMonitoringSignificantLocationChanges: If you start this service and your application is subsequently terminated, the system automatically …
108
votes
10 answers

Conditionally start at different places in storyboard from AppDelegate

I have a storyboard set up with working login and main view controller, the latter is the view controller to which the user is navigated to when login is successful. My objective is to show the main view controller immediately if the authentication…
mmvie
  • 2,571
  • 7
  • 24
  • 39
78
votes
3 answers

App delegate methods aren't being called in iOS 13

I am using Xcode 11 and building an app for iOS 13. In a new project I created in Xcode some of the UIApplicationDelegate methods were missing so I added them back into the app delegate file. The new template for a "Single View App" project was…
nevan king
  • 112,709
  • 45
  • 203
  • 241
69
votes
10 answers

What is a "delegate" in Objective C's iPhone development?

What is a "delegate" in Objective C's iPhone development?
MikeN
  • 45,039
  • 49
  • 151
  • 227
59
votes
11 answers

Scheduled NSTimer when app is in background?

How do people deal with a scheduled NSTimer when an app is in the background? Let's say I update something in my app every hour. updateTimer = [NSTimer scheduledTimerWithTimeInterval:60.0*60.0 target:self selector:@selector(updateStuff)…
cannyboy
  • 24,180
  • 40
  • 146
  • 252
54
votes
3 answers

didReceiveRemoteNotification: fetchCompletionHandler: open from icon vs push notification

I'm trying to implement background push notification handling, but I'm having issues with determining whether the user opened the app from the push notification that was sent as opposed to opening it from the icon. - (void)application:(UIApplication…
47
votes
7 answers

How to detect if code is running in Main App or App Extension Target?

Does anyone know how you detect from within your code if you're running inside an App Extension? I have an app which shares classes between an app and an extension. The app code uses [UIApplication sharedApplication] but this isn't available from…
Mark Bridges
  • 8,228
  • 4
  • 50
  • 65
42
votes
8 answers

Detect if application: didReceiveRemoteNotification: fetchCompletionHandler: was called by tapping on a notification in Notification Center

application: didReceiveRemoteNotification: fetchCompletionHandler: is different from application: didReceiveRemoteNotification: How? from the docs: Unlike the application:didReceiveRemoteNotification: method, which is called only when your app…
Devfly
  • 2,495
  • 5
  • 38
  • 56
36
votes
4 answers

ApplicationWillTerminate in iOS 4.0

The applicationWillTerminate delegate method is not getting called in iOS 4.0 When I hit the Home button I am seeing the applicationWillResignActive and applicationDidEnterBackground delegate methods getting called. -…
Biranchi
  • 16,120
  • 23
  • 124
  • 161
36
votes
8 answers

Display a view or splash screen before applicationDidEnterBackground (to avoid active view screenshot)

I have confidential informations in my app, so I would like to hide them with a splash screen when the app is about to be moved to background. I do run the app on iOS6 and further. I tried to display the view in applicationWillResignActive but the…
Tancrede Chazallet
  • 7,035
  • 6
  • 41
  • 62
35
votes
4 answers

UIApplication sharedApplication - keyWindow is nil?

I want to convert a CGPoint from my UIView to UIWindow coordinates and have realized that UIApplication keyWindow is always nil; why is this? I have tried the convertPoint:toView: method from UIView. Please see this sample code I tried in the view…
nacho4d
  • 43,720
  • 45
  • 157
  • 240
1
2 3
34 35