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
2
votes
1 answer

How does UIApplication cancelAllLocalNotifications work between app updates?

Does anyone know how the cancelAllLocalNotifications method works on UIApplication? I'm wondering specifically how iOS knows what to cancel. Does it know by App ID? Or does it use the version number of the app somehow? What I'm experiencing right…
thephatp
  • 1,479
  • 1
  • 20
  • 37
2
votes
1 answer

How Can I use blackberry browser in my view hiearchy?

I need to show some links in my application's views. But I can't find anything about it. is it possible?? I want to place browsercontent(field) where gray area for os <5.00 ?
atasoyh
  • 3,045
  • 6
  • 31
  • 57
2
votes
1 answer

IOS Shared Application hide StatusBar

I am hiding the Status bar with the below code and it gives me a memory warning level1 . It does nothing to the app itself during the memory warning but I do not like to have such things happening. Is there somthing I am doing wrong? or and con…
FreeAppl3
  • 858
  • 1
  • 15
  • 32
2
votes
1 answer

Monotouch - CancelLocalNotification

Anyone used this to cancel a previously scheduled Local Notification? I see it in the documentation but can't get it wired up in code. UIApplication.SharedApplication.ScheduledLocalNotifications schedNoteList = new …
Rick
  • 483
  • 1
  • 6
  • 19
2
votes
0 answers

iOS 15 Beta keyWindow not available in viewDidLoad

We have a lot of logs to Crashlytics where the keyWindow ist nil after app startup in viewDidLoad of the first viewController show on screen. Anyone else having problems to access UIApplication.shared.keyWindow?.rootViewController on app startup…
Renato Stauffer
  • 738
  • 2
  • 14
  • 30
2
votes
1 answer

how to pass in subject and body text in swiftui mail app?

I am trying to pass in subject and body text when I open the mail app but for some reason the mail wont happen hen I pass in parameters . can anyone see in my code of what I am doing wrong? or if guys have another method for me to work in swiftui…
2
votes
1 answer

setNetworkActivityIndicatorVisible spinner not displaying

As the title says, here's some code: - (void)refreshMap { NSLog(@"refreshing"); [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES]; lat = [[NSNumber numberWithDouble:myUserLocation.coordinate.latitude]…
koichirose
  • 1,815
  • 4
  • 22
  • 30
2
votes
1 answer

How do I launch an Apple Pages document from my iOS application?

I have a pages document in my iOS applications bundle. I'd like to open this document directly with Apple's Pages iOS app. I know I have to add schemes in info.plist under LSApplicationQueriesSchemes. But i'm really just guessing what I should add.…
NSCaleb
  • 135
  • 4
2
votes
1 answer

Calling open(_:options:completionHandler:) on a "podcast://"-prefixed URL results in the iOS Podcasts app prepending "http://" to the original URL

Context I'm working on a Swift iOS app in Xcode (iOS 13 and Xcode 11.3). Goal Basically, from within my app, I want to be able to open a private podcast feed's URL in the iOS Podcasts app (to add it as a new subscription). What I'm doing My…
focorner
  • 1,927
  • 1
  • 20
  • 24
2
votes
2 answers

How to know if current device can have background mode

I am doing some tasks after having entered in background mode. I want to do these tasks only if I am in background mode so I did : if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateBackground) But applicationState is…
kheraud
  • 5,048
  • 7
  • 46
  • 75
2
votes
2 answers

iOS - in device settings if i change time it should get notified even in app background, killed state

To get the device settings time change notification, i found that we have to use UIApplication.significantTimeChangeNotification notification and func applicationSignificantTimeChange(_ application: UIApplication) delegate method. But in my case…
Anjaneyulu Battula
  • 1,910
  • 16
  • 33
2
votes
0 answers

Detect the iOS device entering sleep mode

Let's assume I have an app that has the idle timer disabled and will continue to run when the application state is not active (in background while using other apps or in lock screen, think audio playback) but it should stop when the device enters…
nontomatic
  • 2,003
  • 2
  • 24
  • 38
2
votes
0 answers

How can I know the new Height of my status before rotating

StatusBar, NavigationBar and TabBar height are diffirent between platforms and orientations. I would like to know the new height of all three before rotating to change my constraint in the viewWillTransition…
stix
  • 110
  • 10
2
votes
2 answers

Have already added LSApplicationQueriesScheme and I still get error: "This app is not allowed to query for scheme whatsapp"

I have already checked several of the other questions on this matter, and installed the LSApplicationQueriesScheme for whatsapp, but my application still is not being allowed to share with whatsapp. Here's a screenshot of my Info.plist file: This…
2
votes
2 answers

UIApplication.shared.open(_ url: URL,etc.) doesn't open anything

I have added "instagram" to my LSApplicationQueriesSchemes in the Info.plist file but it still doesn't open up neither safari nor instagram when the following function is called: func openinstagram () { let instaurl = URL(fileURLWithPath:…