In iOS, the app delegate is responsible for managing the app throughout its lifecycle by responding to events such as launch and termination.
Questions tagged [appdelegate]
2019 questions
30
votes
12 answers
Get the current view controller from the app delegate
i am new to ios. I need to know the current view controller from app delegate.. i have no idea about this and i don't knowto implement this. i am using this code toimplemnt this but it return null values.
I followed this link-
Get current view…

user3459648
- 351
- 1
- 3
- 9
30
votes
5 answers
Open a view controller when a iOS push notification is received
I want to open a specific view controller when a user clicks on the received push notification message, but when I receive a push notification message and click the message, only the application opens, but it does not redirect to a specific view…

cdsoft
- 621
- 2
- 8
- 15
30
votes
3 answers
Present view controller from app delegate
I'm attempting to present a view controller from the app delegate with this code:
- (void)interstitialViewControllerRequestSucceeded:(UIViewController *)interstitialViewController
{
[self.window.rootViewController…

mikeholp
- 965
- 3
- 11
- 14
29
votes
3 answers
Swift – Instantiating a navigation controller without storyboards in App Delegate
I'm rebuilding an app without storyboards and the part of it that I'm having the most trouble with is navigating view-to-view programatically. Few things are written out there which don't use storyboards, so finding an answer for this has been…

Zack Shapiro
- 6,648
- 17
- 83
- 151
27
votes
7 answers
Changing titleTextAttribute in swift
Every since i updated xcode i cant seem to change the titleTextAttribute. Now when i use following code i get this error:
could not find an overload init that accepts this supplied arguments
Code in…

Peter Pik
- 11,023
- 19
- 84
- 142
26
votes
7 answers
Swift - pushViewController from appDelegate, rootViewController.navigationController is nil
Having a problem following a few guides, specifically
http://blog.originate.com/blog/2014/04/22/deeplinking-in-ios/
I'm setting the url scheme and it's working well to launch the app from another app, but passing in the host or url are not working…

tehfailsafe
- 3,283
- 3
- 21
- 27
25
votes
3 answers
AppDelegate and SceneDelegate when supporting iOS 12 and 13
I need to support iOS 12 and iOS 13.
Should I be duplicating code between AppDelegate and SceneDelegate?
For example:
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
…

Teddy K
- 820
- 1
- 6
- 17
25
votes
5 answers
presentViewController in AppDelegate with delay in iOS8
So I had a full working solution in iOS7 that displays a LoginViewController via presentViewController in the AppDelegate's didFinishLaunching.
Basically I am doing something like this:
UIViewController *backgroundViewController =…

Tiago Almeida
- 14,081
- 3
- 67
- 82
23
votes
6 answers
"Error : Use of undeclared type MessagingDelegate" in Firebase messaging
I have updated my firebase messaging pod recently and followed the Quickstart guide of Firebase to perform necessary changes of upgradation.
I added the new extension AppDelegate : MessagingDelegate extension but getting certain errors.

Heckyl Technologies
- 291
- 1
- 2
- 3
23
votes
2 answers
Apple iTunes Connect Analytics: attribution provider and campaign id value passing to the app delegate
The new iTunes connect has analytics features now. You can specify the provider (pid) id and campaign id (cid) in the url. e.g.
https://itunes.apple.com/fr/app/candy-crush-saga/id553834731?mt=8&pid=1234&cid=My_Campaign
Can you pass those values…

Zsolt
- 3,648
- 3
- 32
- 47
22
votes
4 answers
Can I use PushKit to do regular push with out using VoIP? Will it allow killed app to be launched in background if user does not act on notification?
In the PushKit it is mentioned we can use regular push or VoIP push. But I did not find any documentation for what PKPushType to use for regular push.
Did anybody try the regular push using the PushKit?
If I don't use VoIP is it possible for a…

SDTDMT
- 221
- 2
- 7
22
votes
2 answers
Replace xib file with Main.storyboard file in App delegate class
Right now project is using MainWindow.xib in App delegate class as main nib file. It has this code in main.m file
int main(int argc, char *argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc,…

user1120133
- 3,244
- 3
- 48
- 90
21
votes
2 answers
Accessing AppState in AppDelegate with SwiftUI's new iOS 14 life cycle
I'm using SwiftUI's new app lifecycle coming in iOS 14.
However, I'm stuck at how to access my AppState (single source of truth) object in the AppDelegate.
I need the AppDelegate to run code on startup and register for notifications…

Mister22
- 213
- 2
- 6
21
votes
4 answers
Swift: How to access in AppDelegate variable from the View controller?
I would like to write in the text or csv (prefer) file the variable from the view controller.
Indeed I am doing a drawing app and I would like to write in the file the current position of the finger.
class ViewController: UIViewController {var…

Yann Amouyal
- 211
- 1
- 2
- 3
21
votes
5 answers
Call app delegate method from view controller
I want to know if I can call an app delegate method from another ViewController.
When the app starts, the application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool i method is called. Can I…

Memon Irshad
- 972
- 1
- 8
- 17