Files
firebase-ios-sdk/Firebase/Database/Public/FIRDatabase.h
T

182 lines
6.1 KiB
Objective-C
Raw Normal View History

2017-05-15 12:27:07 -07:00
/*
* Copyright 2017 Google
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#import "FIRDatabaseReference.h"
2019-08-05 13:27:47 -07:00
#import <Foundation/Foundation.h>
2017-05-15 12:27:07 -07:00
@class FIRApp;
NS_ASSUME_NONNULL_BEGIN
/**
2019-08-05 13:27:47 -07:00
* The entry point for accessing a Firebase Database. You can get an instance
* by calling [FIRDatabase database]. To access a location in the database and
* read or write data, use [FIRDatabase reference].
2017-05-15 12:27:07 -07:00
*/
NS_SWIFT_NAME(Database)
2017-05-15 12:27:07 -07:00
@interface FIRDatabase : NSObject
2017-06-30 10:47:37 -07:00
2017-06-02 02:35:38 +09:00
/**
2019-08-05 13:27:47 -07:00
* The NSObject initializer that has been marked as unavailable. Use the
* `database` method instead
2017-06-02 02:35:38 +09:00
*
* @return An instancetype instance
2019-08-05 13:27:47 -07:00
*/
- (instancetype)init
__attribute__((unavailable("use the database method instead")));
2017-05-15 12:27:07 -07:00
/**
* Gets the instance of FIRDatabase for the default FIRApp.
*
* @return A FIRDatabase instance.
*/
2019-08-05 13:27:47 -07:00
+ (FIRDatabase *)database NS_SWIFT_NAME(database());
2017-05-15 12:27:07 -07:00
/**
* Gets a FirebaseDatabase instance for the specified URL.
*
* @param url The URL to the Firebase Database instance you want to access.
* @return A FIRDatabase instance.
*/
+ (FIRDatabase *)databaseWithURL:(NSString *)url NS_SWIFT_NAME(database(url:));
/**
* Gets a FirebaseDatabase instance for the specified URL, using the specified
* FirebaseApp.
*
* @param app The FIRApp to get a FIRDatabase for.
* @param url The URL to the Firebase Database instance you want to access.
* @return A FIRDatabase instance.
*/
// clang-format off
+ (FIRDatabase *)databaseForApp:(FIRApp *)app
URL:(NSString *)url NS_SWIFT_NAME(database(app:url:));
// clang-format on
2017-05-15 12:27:07 -07:00
/**
* Gets an instance of FIRDatabase for a specific FIRApp.
*
* @param app The FIRApp to get a FIRDatabase for.
* @return A FIRDatabase instance.
*/
2019-08-05 13:27:47 -07:00
+ (FIRDatabase *)databaseForApp:(FIRApp *)app NS_SWIFT_NAME(database(app:));
2017-05-15 12:27:07 -07:00
/** The FIRApp instance to which this FIRDatabase belongs. */
2019-08-05 13:27:47 -07:00
@property(weak, readonly, nonatomic) FIRApp *app;
2017-05-15 12:27:07 -07:00
/**
* Gets a FIRDatabaseReference for the root of your Firebase Database.
*/
2019-08-05 13:27:47 -07:00
- (FIRDatabaseReference *)reference;
2017-05-15 12:27:07 -07:00
/**
* Gets a FIRDatabaseReference for the provided path.
*
* @param path Path to a location in your Firebase Database.
* @return A FIRDatabaseReference pointing to the specified path.
*/
2019-08-05 13:27:47 -07:00
- (FIRDatabaseReference *)referenceWithPath:(NSString *)path;
2017-05-15 12:27:07 -07:00
/**
2019-08-05 13:27:47 -07:00
* Gets a FIRDatabaseReference for the provided URL. The URL must be a URL to a
* path within this Firebase Database. To create a FIRDatabaseReference to a
* different database, create a FIRApp} with a FIROptions object configured with
* the appropriate database URL.
2017-05-15 12:27:07 -07:00
*
* @param databaseUrl A URL to a path within your database.
* @return A FIRDatabaseReference for the provided URL.
2019-08-05 13:27:47 -07:00
*/
- (FIRDatabaseReference *)referenceFromURL:(NSString *)databaseUrl;
2017-05-15 12:27:07 -07:00
/**
2019-08-05 13:27:47 -07:00
* The Firebase Database client automatically queues writes and sends them to
* the server at the earliest opportunity, depending on network connectivity. In
* some cases (e.g. offline usage) there may be a large number of writes waiting
* to be sent. Calling this method will purge all outstanding writes so they are
* abandoned.
2017-05-15 12:27:07 -07:00
*
2019-08-05 13:27:47 -07:00
* All writes will be purged, including transactions and onDisconnect writes.
* The writes will be rolled back locally, perhaps triggering events for
* affected event listeners, and the client will not (re-)send them to the
* Firebase Database backend.
2017-05-15 12:27:07 -07:00
*/
- (void)purgeOutstandingWrites;
/**
2019-08-05 13:27:47 -07:00
* Shuts down our connection to the Firebase Database backend until goOnline is
* called.
2017-05-15 12:27:07 -07:00
*/
- (void)goOffline;
/**
2019-08-05 13:27:47 -07:00
* Resumes our connection to the Firebase Database backend after a previous
* goOffline call.
2017-05-15 12:27:07 -07:00
*/
- (void)goOnline;
/**
2019-08-05 13:27:47 -07:00
* The Firebase Database client will cache synchronized data and keep track of
* all writes you've initiated while your application is running. It seamlessly
* handles intermittent network connections and re-sends write operations when
* the network connection is restored.
2017-05-15 12:27:07 -07:00
*
2019-08-05 13:27:47 -07:00
* However by default your write operations and cached data are only stored
* in-memory and will be lost when your app restarts. By setting this value to
* `YES`, the data will be persisted to on-device (disk) storage and will thus
* be available again when the app is restarted (even when there is no network
* connectivity at that time). Note that this property must be set before
* creating your first Database reference and only needs to be called once per
2017-05-15 12:27:07 -07:00
* application.
*
*/
2019-08-05 13:27:47 -07:00
@property(nonatomic) BOOL persistenceEnabled NS_SWIFT_NAME(isPersistenceEnabled)
;
2017-05-15 12:27:07 -07:00
/**
2019-08-05 13:27:47 -07:00
* By default the Firebase Database client will use up to 10MB of disk space to
* cache data. If the cache grows beyond this size, the client will start
* removing data that hasn't been recently used. If you find that your
* application caches too little or too much data, call this method to change
* the cache size. This property must be set before creating your first
* FIRDatabaseReference and only needs to be called once per application.
2017-05-15 12:27:07 -07:00
*
2019-08-05 13:27:47 -07:00
* Note that the specified cache size is only an approximation and the size on
* disk may temporarily exceed it at times. Cache sizes smaller than 1 MB or
* greater than 100 MB are not supported.
2017-05-15 12:27:07 -07:00
*/
2019-08-05 13:27:47 -07:00
@property(nonatomic) NSUInteger persistenceCacheSizeBytes;
2017-05-15 12:27:07 -07:00
/**
2019-08-05 13:27:47 -07:00
* Sets the dispatch queue on which all events are raised. The default queue is
* the main queue.
2017-05-15 12:27:07 -07:00
*
* Note that this must be set before creating your first Database reference.
*/
2019-08-05 13:27:47 -07:00
@property(nonatomic, strong) dispatch_queue_t callbackQueue;
2017-05-15 12:27:07 -07:00
/**
* Enables verbose diagnostic logging.
*
* @param enabled YES to enable logging, NO to disable.
*/
2019-08-05 13:27:47 -07:00
+ (void)setLoggingEnabled:(BOOL)enabled;
2017-05-15 12:27:07 -07:00
/** Retrieve the Firebase Database SDK version. */
2019-08-05 13:27:47 -07:00
+ (NSString *)sdkVersion;
2017-05-15 12:27:07 -07:00
@end
NS_ASSUME_NONNULL_END