Questions tagged [uiapplication]

The UIApplication class provides a centralized point of control and coordination for apps running on iOS. Every app must have exactly one instance of UIApplication (or a subclass of UIApplication). When an app is launched, the UIApplicationMain function is called; among its other tasks, this function creates a singleton UIApplication object. Thereafter you access this object by invoking the sharedApplication class method.

The UIApplication class provides a centralized point of control and coordination for apps running on iOS. Every app must have exactly one instance of UIApplication (or a subclass of UIApplication). When an app is launched, the UIApplicationMain function is called; among its other tasks, this function creates a singleton UIApplication object. Thereafter you access this object by invoking the sharedApplication class method.

A major role of a UIApplication object is to handle the initial routing of incoming user events. It also dispatches action messages forwarded to it by control objects (UIControl) to the appropriate target objects. In addition, the UIApplication object maintains a list of all the windows (UIWindow objects) currently open in the app, so through those it can retrieve any of the app’s UIView objects. The app object is typically assigned a delegate, an object that the app informs of significant runtime events—for example, app launch, low-memory warnings, and app termination—giving it an opportunity to respond appropriately.

Apps can cooperatively handle a resource such as an email or an image file through the openURL: method. For example, an app opening an email URL with this method may cause the mail client to launch and display the message.

The programmatic interfaces of UIApplication allow you to manage behavior that is specific to the device. Use this object to do the following:

  • Control the app’s response to changes in interface orientation.

  • Temporarily suspend incoming touch events.

  • Turn proximity sensing (of the user’s face) off and on again.

  • Register for remote notifications.

  • Trigger the undo-redo UI (applicationSupportsShakeToEdit).

  • Determine whether an installed app can open a URL (canOpenURL:).

  • Extend the execution of the app so that it can finish a task in the background.

  • Schedule and cancel local notifications.

  • Coordinate the reception of remote-control events.

  • Perform app-level state restoration tasks.

UIApplication defines a delegate that must adopt the UIApplicationDelegate protocol and implement some of the protocol methods.

Subclassing Notes

Most apps should never need to subclass the UIApplication class. Most apps use an app delegate to manage interactions between the system and the app.

The only situation where you might need to subclass UIApplication is when you are implementing a custom event or action dispatching mechanism. In that situation, you might override the sendEvent: or sendAction:to:from:forEvent: methods to implement that mechanism. However, the cases where this is required are very rare and should be avoided whenever possible.

484 questions
1
vote
2 answers

Presenting a ViewController from UIApplication subclass

I have a timer running in my UIApplication subclass, that is should send the user to a certain ViewController when it runs out. I am able to instantiate the ViewController I want to go to... let storyboard = UIStoryboard(name: "Main", bundle:…
Marmelador
  • 947
  • 7
  • 27
1
vote
1 answer

Regarding Notification Center Observers for UIApplicationWillEnterForeground Swift

Hello everyone and thanks for taking the time to read this. I have a table view controller with a header that needs to be refreshed to display the latest content after the user brings the application to the foreground, so I added an observer in…
Jason Rybka
  • 157
  • 2
  • 15
1
vote
1 answer

Can I get iPhone or iPad Usage Stats from UIApplication?

Is it possible to access iPhone or iPad stats on App Usage through UIApplication or something. Trying to figure out on some iPad's we have which apps are most viewed and overall how long they are used.
Jeffrey Hunter
  • 1,103
  • 2
  • 12
  • 19
1
vote
0 answers

Check if an app is installed on an iPhone in iOS9 and up?

I need to know if a specific app is installed. I can't add the Schemes to the plist LSApplicationQueriesSchemes so the function UIApplication.sharedApplication().canOpenURL() is not helpful from iOS9.
1
vote
1 answer

Expected identifier '(' in Xcode

I'm having a problem with this the first line of code, it says that there is an "expected identifier '('" Not sure if it has something to do with UIApplication. I've already declared UIApplication as a class. Someone please help me with this …
1
vote
2 answers

undefined reference to `_imp___ZN7QWidget14setWindowTitleE7QString'

I am developing an application with Qt Creator and I'm getting this message undefined reference to `_imp___ZN7QWidget14setWindowTitleE7QString' Are there any modules or headers that I should include to remove this error message? Edit: The version…
G.Hajj
  • 31
  • 1
  • 7
1
vote
2 answers

Firebase background and inactive notifications not showing iOS

Using FCM for push notifications in iOS 10: This is the snipper that's getting called after pushing a notification via our own API: - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary…
1
vote
1 answer

What's UserNotification framework's equivalent of didReceive notification: UILocalNotification?

I already knew about this code which can be used before iOS 10: func application(_ application: UIApplication, didReceive notification: UILocalNotification) { } However, it's depreciated so I just want to ask is there any method that is …
1
vote
2 answers

iOS How to exit current app after using UIApplication openURL to launch a browser

I am very new to iOS development. The app I need is very simple: just open a web browser and go to a specific URL when my app is launched. So in the delegate file, in didFinishLaunchingWithOptions, I add a line of code: [[UIApplication…
Ray
  • 11
  • 1
  • 2
1
vote
1 answer

Screen turn into dark when set UIApplication.shared.isIdleTimerDisabled to false

I want screen always light when playing audio, and turn dark when complete the audio and I do not tap the screen after two minutes(i have set auto-lock in setting), implement code as the following. override func viewDidAppear(_ animated: Bool) { …
Leo
  • 835
  • 1
  • 12
  • 31
1
vote
0 answers

How to make a call from background thread in iOS

I call a method from background thread as follows. - (void)applicationDidEnterBackground:(UIApplication *)application { UIApplication *app = [UIApplication sharedApplication]; //create new uiBackgroundTask __block…
Deepak Thakur
  • 3,453
  • 2
  • 37
  • 65
1
vote
0 answers

How to prevent app switcher trying to display snapshot with same orientation

I'm having trouble figuring out how to tell the app switcher to use the last snapshot taken, regardless of the orientation. Do you know how to do that? For example, if I leave my app in landscape mode and open an app that's running in portrait, the…
awfulcode
  • 597
  • 5
  • 12
1
vote
1 answer

Local Notification while in an inactive application state

I am not sure if this is not possible or if I am implementing it wrong. I am trying to complete a task in the background using beginBackgroundTask(expirationHandler) and then post a LocalNotification once it is complete on iOS10. The issue is that…
arvinkx
  • 164
  • 1
  • 11
1
vote
2 answers

Can I use beginBackgroundTaskWithName for normal app processing

I have some NSOperations that are started regularly in my application. They should complete even when the the application is put to background. For this, I'm using the beginBackgroundTaskWithExpirationHandler method. Am I supposed to use the…
Jan
  • 7,444
  • 9
  • 50
  • 74
1
vote
7 answers

Slow app launch

My iphone app is launching very slowly, and I have no idea why. My application:didFinishLaunchingWithOptions: isn't really heavy, I'm just setting the managedObjectContext for each of my five view controllers of my tab bar controller. Does anybody…
burki
  • 2,946
  • 6
  • 37
  • 51