Local storage in iphone using firebase - ios

Is there a way where I can use firebase to store data on the iphone device so that even after the user turns off and then turns on the device, the data remains in the device?

Put this in your AppDelegate file
Swift 3
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
FIRApp.configure()
FIRDatabase.database().persistenceEnabled = true
return true
}

Related

Firebase Crashlytics is not working in iOS

Implemented all steps from firebase doc :
Create App on firebase
add google plist in project
POD installed
Add FirebaseApp.configure() in didFinishLaunchingWithOptions
Added run script ${PODS_ROOT}/Fabric/run
update Debug information format
Please make sure Firebase configuration should be first line in the didFinishLaunchingWithOptions method of AppDelegate file.
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
Fabric.sharedSDK().debug = true
return true
}

Firebase Crashlytics integration not detecting or reporting crashes

I have integrated Crashlytics , here are the changes i have done.
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
Fabric.with([Crashlytics.self()])
Crashlytics.sharedInstance().debugMode = true
Have you added a key like.
"${PODS_ROOT}/Fabric/run" ed9c83ee83d41dc717a07531450c480895e41264 b6cc34ec354a4f96ab160958b4s2a01cc321be62acaa6116983376a5113c9s36

How to add simple app launching animation when AppDelegate loading data from CSV?

I made an app. At first install to phone, app creating CoreData from CSV file in AppDelegate. It takes around 10 seconds.
So i want to show user some loading animation(circle or progress bar or something else).
This is my AppDelegate didFinishLaunchingWithOptions function, where at first launching, app parsing CSV file(around 15000 entity objects) with function preloadDataFromCSVFile().
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let isPreloaded = UserDefaults.standard.bool(forKey: isPreloadedKey)
if !isPreloaded {
preloadDataFromCSVFile()
defaults.set(true, forKey: isPreloadedKey)
}
...
}

Use of undeclared type 'UIApplicationLaunchOptionsKey'

Recently converted a project to Swift 2.2 and running into issues that didn't exist prior. I've tried searching for a workaround but haven't found any similar posts.
Use of undeclared type 'UIApplicationLaunchOptionsKey'.
I can't tell what's wrong with this code in the AppDelegate.swift:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
//UIToolbar.appearance().tintColor = UIColor.clearColor()
return true
}
Try changing the method signature to
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
return true
}
The signature is modified to func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool in swift 3
In Swift 3 the method is changed to:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}

iOS Firebase app not configured after calling FIRApp.configure()

I have an iOS (Swift) app with the following code in the AppDelegate:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FIRApp.configure()
FIRDatabase.database().persistenceEnabled = true
return true
}
The app crashes on the persistenceEnabled = true line, with exception FIRAppNotConfigured, and the message "Failed to get default FIRDatabase instance. Must call FIRApp.configure() before using FIRDatabase."
Obviously, I've called FIRApp.configure() immediately before this, so the suggested solution is incorrect. The log output even shows "Configuring the default app" when that is called.
What might the problem be, and how could I resolve it so I can use the FIRDatabase?
Try:
override init() {
// Firebase Init
FIRApp.configure()
}

Resources