markdown 火力地堡
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 火力地堡相关的知识,希望对你有一定的参考价值。
### What is Firebase?
* Backend provider from Google
* Basically allows us to save our data to the servers hosted by Google
* DATABASE
* AUTHENTICATION
* Cloud based database
---
## Set up Account
* [Create account here](https://firebase.google.com/)
* [Go to console](https://console.firebase.google.com)
* Create a new project
---
### Set up Database
* Navigate to add Firebase to your iOS App
* **Ensure you have a unique bundle identifier for your app!**
* Copy and paste the bundle identifier into the field on the firebase console -> `Register App`
* Leave app nickname and ios store id blank!
* Download `GoogleService-Info.plist` and insert it below the info.plist file in your project directory
* Make sure the `Destination` and `Add to targets` are checked!
* Back in the firebase console, click `next`
* Podfile Setup: `cd` into your project directory and `pod init`
* `open Podfile -a Xcode`
* **uncomment** platform
* Add the following pods:
```ruby
pod 'Firebase'
pod 'Firebase/Auth'
pod 'Firebase/Database'
pod 'SVProgressHUD'
pod 'ChameleonFramework'
```
* `pod install`
* Exit app
* In the same terminal `open .`, and use the `.xcworkspace` file
* Run `cmd + B`
* To ignore the warnings, head into the `Podfile` and append the following LOC:
```ruby
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['CLANG_WARN_DOCUMENTATION_COMMENTS'] = 'NO'
end
end
end
```
* **Save, close app, in terminal `pod update`**
* **Once completed, open project.xcworkspace and run `cmd+B`**
* Back to firebase console, `Finish`, skip connection
---
### Saving to Database
* Import the module: `AppDelegate.swift` file, `import Firebase`
```swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
//TODO: Initialise and Configure your Firebase here:
FirebaseApp.configure()
// reference to a brand new database
let myDatabase = Database.database().reference()
// Set some data to the database upon first loading the app
myDatabase.setValue("We've got data")
return true
}
```
* Head back into firebase terminal and create a realtime database
* Head into the `rules` tab and make sure the following rules are specified:
```
{
"rules": {
".read": true,
".write": true
}
// MORE SECURE FOR AUTH USERS
"rules": {
".read": "auth != null",
".write": "auth != null"
}
}
```
* May need to restart your app 2 times for the set data to be in the database!
### Authenticating Users
* Head in to the firebase console, in the `Authentication` tab
* `Sign in Method` and enable `Email/Password`
*
以上是关于markdown 火力地堡的主要内容,如果未能解决你的问题,请参考以下文章