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

Open containing app from custom keyboard in Swift 3?

Before iOS 10 i used the method written by Valentin Sherwin here. Any workarounds to open the containing app from the custom keyboard with Swift 3?
DanielZanchi
  • 2,708
  • 1
  • 25
  • 37
0
votes
1 answer

Can we add or use handleOpenURL other app delegate

I'm building SDK for my product and there will be no app delegate class. I used Dropbox Integration in my SDK, so I'm bound to use following method. - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url { NSString…
Aleem
  • 3,173
  • 5
  • 33
  • 71
0
votes
1 answer

iOS 9 app lunch URL for 'Storage and iCloud Usage'

What is the openURL string for Settings > General > Storage and iCloud Usage e.g. prefs:root=General&path=???
Nagesh
  • 167
  • 1
  • 2
  • 11
0
votes
3 answers

How to retrieve the detailedText from a cell then use it in a function?

I'm trying to retrieve the detailedText contained in a UITableView Cell (which is a phone number "String") and then Use it in a function that will make a phone call. Problem: My app keeps crashing with the error "fatal error: unexpectedly found nil…
AziCode
  • 2,510
  • 6
  • 27
  • 53
0
votes
2 answers

iPhone: Quitting aplication using [[UIApplication sharedApplication] terminateWithSuccess];

I have built a small app that gets informations from a database on a website. the first thing the app does is to fetch an rss feed and then display it. Apple guidelines tell to let the user decide if he/she wants to connect to the Internet, so I…
Antonio
  • 535
  • 10
  • 26
0
votes
1 answer

IOS Open Url not working on some devices

@IBAction func openLinkedin() { let url = NSURL(string: self.currentUser.linkedin)! if(UIApplication.sharedApplication().canOpenURL(url) == true){ if currentUser.linkedin.rangeOfString("linkedin") != nil{ …
Cees
  • 415
  • 2
  • 16
0
votes
2 answers

openURL for some phone numbers is failing

I'm trying to make a call programmatically to a number which has double extension. When I try to run this, [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel:2133776478,213#,213#"]]] I get "No" as the…
0
votes
1 answer

repetitive calls to beginBackgroundTaskWithExpirationHandler

I am evaluating some code that is stacking calls to beginBackgroundTaskWithExpirationHandler in a effort to leave a timer in the background. Have to admit that it is a pretty clever idea, but not sure if this is best practice. So the flow: Call…
Rob Bonner
  • 9,276
  • 8
  • 35
  • 55
0
votes
1 answer

iPhoneOS, using applicationWillResignActive

I want to use this function applicationWillResignActive perform some tasks. before the application shuts down due to incoming call, message or user close it manually. Can i send an email message/in app sms using this function ? Will those tasks…
Taimur Ajmal
  • 2,778
  • 6
  • 39
  • 57
0
votes
0 answers

Sending unrecognized selector `inhibitRotationAnimation` to VC when setting rootViewController

Once I launch my application, the BaseVC inits. In BaseVC, I will verify whether user has logged in. If true, my app will jump to main tabbar controller by using: UIApplication.sharedApplication().windows.last?.rootViewController =…
Desmond
  • 767
  • 1
  • 6
  • 18
0
votes
2 answers

Will I ever need the UIApplication* application from the ApplicationDelegate functions?

When would the application parameter in any of the app delegates not be equal to the shared instance? -(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { UIApplication* sharedapp =…
Nick
  • 2,735
  • 1
  • 29
  • 36
0
votes
1 answer

Access AppDelegate functions in tableview controller?

We are using Swift and we made a "UITableViewController" inside our project folder. We are trying to access our "AppDelegate" functions. We have tried using let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate We have…
0
votes
1 answer

Navigation/TabBarController disappear

I`m using this code in AppDelegate for make a shortcut when you long press the app before its launch. func application(application: UIApplication, performActionForShortcutItem shortcutItem: UIApplicationShortcutItem, completionHandler: (Bool) ->…
Scaly
  • 1
  • 2
0
votes
1 answer

Long URLs make UIApplication openURL: fail on iOS 9

I'm scratching my head on this one: I've got two apps, and pass images between the two by calling [[UIApplication sharedApplication] openURL:appURL];. Images are base64-encoded. It worked great until now. Now, in iOS 9, it works only with…
PatrickNLT
  • 4,075
  • 1
  • 25
  • 32
0
votes
0 answers

Counting push notifications on iOS (deal with cancel from notif center)

I'm trying to understand on how to deal with a particular use case with push notifications. Let's suppose that I have 4 push notifications in the notification center waiting for an interaction, the server keeps track of the badge number. The user…
Andrea
  • 26,120
  • 10
  • 85
  • 131