Controlling which view controller loads after receiving a push notification in SWIFT

Updated for Swift 4.2 Like it was said, you want to register to remote notifications in applicationDidLaunchWithOptions : func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { let pushSettings = UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil) UIApplication.shared.registerUserNotificationSettings(pushSettings) UIApplication.shared.registerForRemoteNotifications() } There is no way to know in which viewController you will be when you … Read more

Swift 4 ,must be used from main thread only warning

You’re making this call on a background queue. To fix, try something like… public var context: NSManagedObjectContext DispatchQueue.main.async { var appDelegate = UIApplication.shared.delegate as! AppDelegate context = appDelegate.persistentContainer.viewContext } Although this is a pretty bad way to do this… you’re using your App Delegate as a global variable (which we all know is bad!) You should … Read more

Present UIAlertController from AppDelegate [duplicate]

You can use this code as well if you want to launch it from didFinishLaunchingWithOptions.Hope this helps. dispatch_async(dispatch_get_main_queue(), { let importantAlert: UIAlertController = UIAlertController(title: “Action Sheet”, message: “Hello I was presented from appdelegate ;)”, preferredStyle: .ActionSheet) self.window?.rootViewController?.presentViewController(importantAlert, animated: true, completion: nil) }) And up-to-date: DispatchQueue.main.async { let alert = UIAlertController(title: “Hello!”, message: “Greetings from AppDelegate.”, … Read more

AppDelegate, rootViewController and presentViewController

I had the same issue. Based on the answer to this question, I added [self.window makeKeyAndVisible] just before presentViewController:animated:completion:, and that fixed it for me. In your case, showLoginView becomes – (void)showLoginView { UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@”MainStoryboard” bundle:nil]; LoginViewController *loginViewController = [storyboard instantiateViewControllerWithIdentifier:@”LoginViewController”]; [self.window makeKeyAndVisible]; [self.window.rootViewController presentViewController:loginViewController animated:YES completion:NULL]; }

No visible @interface for ‘RCTBundleURLProvider’ declares the selector ‘jsBundleURLForBundleRoot:fallbackResource:’

After some research i found out that jsBundleURLForBundleRoot:fallbackResource: no longer exists on RCTBundleURLProvider. Here’s the Fix: Replace return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@”index” fallbackResource:nil]; with return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@”index”]; Re-Build the app and you are good to go.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)