How do I rewrite the code snippet according to this;
Setter for 'statusBarStyle' was deprecated in iOS 9.0: Use -[UIViewController preferredStatusBarStyle]
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions:
[UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
UIApplication.shared.statusBarStyle = .lightContent
return true
}
This is the new method for status bar styles
override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}
Related
I have a video calling application now issue is that if the user declines the permission and once the user grants the camera access permission then the iOS application restarts then how I can know the application restart due to permission change?
Is there any method called from appdelegate before restart or after restart?
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
}
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
return orientationLock
}
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
}
func applicationDidEnterBackground(_ application: UIApplication) {
}
func applicationDidBecomeActive(_ application: UIApplication) {
}
func applicationWillTerminate(_ application: UIApplication) {
}
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: #escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
}
import UIKit
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
Model.shared.loadXMLFile(date: nil)
Model.shared.parseXML()
return true
}
// MARK: UISceneSession Lifecycle
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
}
}
When you create a UITableViewController in your storyboard, its main view must be a UITableView. This error often happens when some other controller type is changed to a UITableViewController but with its old main view still in place.
In this code, when I type GIDSignIn.sharedInstance, for some reason sharedInstance is not a function, which means I can't acces clientID. I cannot find a solution for this anywhere.
import UIKit
import GoogleSignIn
#main
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
GIDSignIn.sharedInstance().clientID = "clientID"
return true
}
In latest version of GoogleSignIn SDK. Removed this method.
Now in new follow this link or below code.
https://developers.google.com/identity/sign-in/ios/sign-in
#IBAction func clkLoginWithGmail(_ sender: UIButton) {
let signInConfig = GIDConfiguration.init(clientID: "clientID-XYZ")
GIDSignIn.sharedInstance.signIn(with: signInConfig, presenting: self) { user, error in
}
}
Xcode keeps complaining about an ambigous reference I've made in the AppDelegate. I'm trying to integrate Facebook Login with Firebase in my Xcode project using this tutorial.
Error:
Ambiguous reference to member
'application(_:didFinishLaunchingWithOptions:)'
Code:
import UIKit
import CoreData
import Firebase
import FBSDKLoginKit
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
FIRApp.configure()
FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
return true
}
private func application(_ app: UIApplication, open url: URL, options: UIApplicationOpenURLOptionsKey) -> Bool {
var handled = FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: options[UIApplicationOpenURLOptionsSourceApplicationKey], annotation: options[UIApplicationOpenURLOptionsAnnotationKey]) // Error happens here
// Add any custom logic here.
return handled
}
I'm not sure what what this error means (still new to iOS programming). I've highlighted where it happens in the code with a comment.
import UIKit
import Firebase
import CoreData
import FBSDKCoreKit
import FBSDKLoginKit
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FIRApp.configure()
FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
return true
}
func application(_ application: UIApplication, open url: URL, _: NSURL, sourceApplication: String, annotation: AnyObject) -> Bool {
let handled: Bool = FBSDKApplicationDelegate.sharedInstance().application(application, open: url, sourceApplication: sourceApplication, annotation: annotation)
return handled
}
func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask
{
return UIInterfaceOrientationMask.Portrait.rawValue.hashValue | UIInterfaceOrientationMask.PortraitUpsideDown.rawValue.hashValue
}
That used to work in Swift 1.2 however the return line is now throwing this error:
Binary operator '|' cannot be applied to two
'UIInterfaceOrientationMask' operands
I am able to get to work with just 1 return value with the new type but I cannot get it to pipe the second orientation I need.
This 'works'
func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask
{
return UIInterfaceOrientationMask.Portrait
}
But what I 'think' I need is this:
func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask
{
return UIInterfaceOrientationMask.Portrait | UIInterfaceOrientationMask.PortraitUpsideDown
}
And it says the same error as I posted above.
Do you know how to properly set the orientation to 2 or more values in the in the AppDelegate in Swift 2.0?
Try new syntax:
func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask {
return [.Portrait, .PortraitUpsideDown]
}