├── .DS_Store ├── .gitignore ├── Firebase.framework ├── Firebase ├── Headers │ ├── FAuthData.h │ ├── FAuthType.h │ ├── FConfig.h │ ├── FDataSnapshot.h │ ├── FEventType.h │ ├── FMutableData.h │ ├── FQuery.h │ ├── FTransactionResult.h │ ├── Firebase.h │ ├── FirebaseApp.h │ └── FirebaseServerValue.h ├── Info.plist ├── Modules │ └── module.modulemap └── NOTICE ├── README.md ├── RNFirebase.js ├── RNFirebase.xcodeproj ├── project.pbxproj └── xcuserdata │ └── alonso.xcuserdatad │ └── xcschemes │ ├── RNFirebase.xcscheme │ └── xcschememanagement.plist ├── RNFirebase ├── .DS_Store ├── Firebase.framework │ ├── Firebase │ ├── Headers │ │ ├── FAuthData.h │ │ ├── FAuthType.h │ │ ├── FConfig.h │ │ ├── FDataSnapshot.h │ │ ├── FEventType.h │ │ ├── FMutableData.h │ │ ├── FQuery.h │ │ ├── FTransactionResult.h │ │ ├── Firebase.h │ │ ├── FirebaseApp.h │ │ └── FirebaseServerValue.h │ ├── Info.plist │ ├── Modules │ │ └── module.modulemap │ └── NOTICE ├── RNFirebase.swift └── RNFirebaseBridge.m ├── RNFirebaseDataSnapshot.js ├── RNFirebaseQuery.js ├── RNFirebaseTests ├── Info.plist └── RNFirebaseTests.swift ├── example.js └── package.json /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/holmesal/react-native-firebase/37ed6cb77efd65276fc92ebf6890ddd02cb4fb3b/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ -------------------------------------------------------------------------------- /Firebase.framework/Firebase: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/holmesal/react-native-firebase/37ed6cb77efd65276fc92ebf6890ddd02cb4fb3b/Firebase.framework/Firebase -------------------------------------------------------------------------------- /Firebase.framework/Headers/FAuthData.h: -------------------------------------------------------------------------------- 1 | // 2 | // FAuthData.h 3 | // Firebase 4 | // 5 | // Created by Katherine Fang on 7/30/14. 6 | // 7 | 8 | #import 9 | #import "FAuthType.h" 10 | 11 | 12 | /** 13 | * The FAuthData class is a wrapper around the user metadata returned from the Firebase auth server. 14 | * It includes the provider authenticated against, a uid (with the possible exception of authenticating against a custom 15 | * backend), and a token used to authenticate with Firebase. 16 | * 17 | * It may include other metadata about the user, depending on the provider used to do the authentication. 18 | */ 19 | @interface FAuthData : NSObject 20 | 21 | /** 22 | * @return Raw authentication token payload returned by the server 23 | */ 24 | @property (nonatomic, strong, readonly) NSDictionary *auth; 25 | 26 | /** 27 | * @return Authentication token expiration timestamp (seconds since epoch) returned by the server 28 | */ 29 | @property (nonatomic, strong, readonly) NSNumber *expires; 30 | 31 | /** 32 | * @return A uid for this user. It is unique across all auth providers. 33 | */ 34 | @property (nonatomic, strong, readonly) NSString *uid; 35 | 36 | 37 | /** 38 | * @return The provider that authenticated this user 39 | */ 40 | @property (nonatomic, readonly) NSString *provider; 41 | 42 | 43 | /** 44 | * @return The token that was used to authenticate this user with Firebase 45 | */ 46 | @property (nonatomic, strong, readonly) NSString *token; 47 | 48 | 49 | /** 50 | * @return Provider data keyed by provider. Includes cached data from third-party providers 51 | */ 52 | @property (nonatomic, strong, readonly) NSDictionary *providerData; 53 | 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /Firebase.framework/Headers/FAuthType.h: -------------------------------------------------------------------------------- 1 | // 2 | // FAuthType.h 3 | // Firebase 4 | // 5 | // Created by Katherine Fang on 7/30/14. 6 | // 7 | // All public-facing auth enums. 8 | // 9 | 10 | #ifndef Firebase_FAuthenticationTypes_h 11 | #define Firebase_FAuthenticationTypes_h 12 | 13 | typedef NS_ENUM(NSInteger, FAuthenticationError) { 14 | // Developer / Config Errors 15 | FAuthenticationErrorProviderDisabled = -1, 16 | FAuthenticationErrorInvalidConfiguration = -2, 17 | FAuthenticationErrorInvalidOrigin = -3, 18 | FAuthenticationErrorInvalidProvider = -4, 19 | 20 | // User Errors (Email / Password) 21 | FAuthenticationErrorInvalidEmail = -5, 22 | FAuthenticationErrorInvalidPassword = -6, 23 | FAuthenticationErrorInvalidToken = -7, 24 | FAuthenticationErrorUserDoesNotExist = -8, 25 | FAuthenticationErrorEmailTaken = -9, 26 | 27 | // User Errors (Facebook / Twitter / Github / Google) 28 | FAuthenticationErrorDeniedByUser = -10, 29 | FAuthenticationErrorInvalidCredentials = -11, 30 | FAuthenticationErrorInvalidArguments = -12, 31 | FAuthenticationErrorProviderError = -13, 32 | FAuthenticationErrorLimitsExceeded = -14, 33 | 34 | // Client side errors 35 | FAuthenticationErrorNetworkError = -15, 36 | FAuthenticationErrorPreempted = -16, 37 | 38 | FAuthenticationErrorUnknown = -9999 39 | }; 40 | 41 | #endif -------------------------------------------------------------------------------- /Firebase.framework/Headers/FConfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Firebase iOS Client Library 3 | * 4 | * Copyright © 2015 Firebase - All Rights Reserved 5 | * https://www.firebase.com 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binaryform must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY FIREBASE AS IS AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 20 | * EVENT SHALL FIREBASE BE LIABLE FOR ANY DIRECT, 21 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #import 30 | 31 | /** 32 | * Configuration object for Firebase. You can get the default FConfig object via 33 | * `[Firebase defaultConfig]` and modify it. You must make all changes to it before 34 | * you create your first Firebase instance. 35 | */ 36 | @interface FConfig : NSObject 37 | 38 | /** 39 | * By default the Firebase client will keep data in memory while your application is running, but not 40 | * when it is restarted. By setting this value to YES, the data will be persisted to on-device (disk) 41 | * storage and will thus be available again when the app is restarted (even when there is no network 42 | * connectivity at that time). Note that this property must be set before creating your first Firebase 43 | * reference and only needs to be called once per application. 44 | * 45 | * If your app uses Firebase Authentication, the client will automatically persist the user's authentication 46 | * token across restarts, even without persistence enabled. But if the auth token expired while offline and 47 | * you've enabled persistence, the client will pause write operations until you successfully re-authenticate 48 | * (or explicitly unauthenticate) to prevent your writes from being sent unauthenticated and failing due to 49 | * security rules. 50 | */ 51 | @property (nonatomic) BOOL persistenceEnabled; 52 | 53 | /** 54 | * By default Firebase will use up to 10MB of disk space to cache data. If the cache grows beyond this size, 55 | * Firebase will start removing data that hasn't been recently used. If you find that your application caches too 56 | * little or too much data, call this method to change the cache size. This property must be set before creating 57 | * your first Firebase reference and only needs to be called once per application. 58 | * 59 | * Note that the specified cache size is only an approximation and the size on disk may temporarily exceed it 60 | * at times. 61 | */ 62 | @property (nonatomic) NSUInteger persistenceCacheSizeBytes; 63 | 64 | /** 65 | * Sets the dispatch queue on which all events are raised. The default queue is the main queue. 66 | */ 67 | @property (nonatomic, strong) dispatch_queue_t callbackQueue; 68 | 69 | @end 70 | -------------------------------------------------------------------------------- /Firebase.framework/Headers/FDataSnapshot.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Firebase iOS Client Library 3 | * 4 | * Copyright © 2013 Firebase - All Rights Reserved 5 | * https://www.firebase.com 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binaryform must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY FIREBASE AS IS AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 20 | * EVENT SHALL FIREBASE BE LIABLE FOR ANY DIRECT, 21 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #import 30 | 31 | @class Firebase; 32 | 33 | /** 34 | * An FDataSnapshot contains data from a Firebase location. Any time you read 35 | * Firebase data, you receive the data as an FDataSnapshot. 36 | * 37 | * FDataSnapshots are passed to the blocks you attach with observeEventType:withBlock: or observeSingleEvent:withBlock:. 38 | * They are efficiently-generated immutable copies of the data at a Firebase location. 39 | * They can't be modified and will never change. To modify data at a location, 40 | * use a Firebase reference (e.g. with setValue:). 41 | */ 42 | @interface FDataSnapshot : NSObject 43 | 44 | 45 | /** @name Navigating and inspecting a snapshot */ 46 | 47 | /** 48 | * Get an FDataSnapshot for the location at the specified relative path. 49 | * The relative path can either be a simple child key (e.g. 'fred') 50 | * or a deeper slash-separated path (e.g. 'fred/name/first'). If the child 51 | * location has no data, an empty FDataSnapshot is returned. 52 | * 53 | * @param childPathString A relative path to the location of child data. 54 | * @return The FDataSnapshot for the child location. 55 | */ 56 | - (FDataSnapshot *) childSnapshotForPath:(NSString *)childPathString; 57 | 58 | 59 | /** 60 | * Return YES if the specified child exists. 61 | * 62 | * @param childPathString A relative path to the location of a potential child. 63 | * @return YES if data exists at the specified childPathString, else false. 64 | */ 65 | - (BOOL) hasChild:(NSString *)childPathString; 66 | 67 | 68 | /** 69 | * Return YES if the DataSnapshot has any children. 70 | * 71 | * @return YES if this snapshot has any children, else NO. 72 | */ 73 | - (BOOL) hasChildren; 74 | 75 | 76 | /** 77 | * Return YES if the DataSnapshot contains a non-null value. 78 | * 79 | * @return YES if this snapshot contains a non-null value, otherwise NO. 80 | */ 81 | - (BOOL) exists; 82 | 83 | 84 | /** @name Data export */ 85 | 86 | /** 87 | * Returns the raw value at this location, coupled with any metadata, such as priority. 88 | * 89 | * Priorities, where they exist, are accessible under the ".priority" key in instances of NSDictionary. 90 | * For leaf locations with priorities, the value will be under the ".value" key. 91 | */ 92 | - (id) valueInExportFormat; 93 | 94 | 95 | /** @name Properties */ 96 | 97 | /** 98 | * Returns the contents of this data snapshot as native types. 99 | * 100 | * Data types returned: 101 | * * NSDictionary 102 | * * NSArray 103 | * * NSNumber (also includes booleans) 104 | * * NSString 105 | * 106 | * @return The data as a native object. 107 | */ 108 | @property (strong, readonly, nonatomic) id value; 109 | 110 | 111 | /** 112 | * Get the number of children for this DataSnapshot. 113 | * 114 | * @return An integer indicating the number of children. 115 | */ 116 | @property (readonly, nonatomic) NSUInteger childrenCount; 117 | 118 | 119 | /** 120 | * Get a Firebase reference for the location that this data came from 121 | * 122 | * @return A Firebase instance for the location of this data 123 | */ 124 | @property (nonatomic, readonly, strong) Firebase* ref; 125 | 126 | 127 | /** 128 | * The key of the location that generated this FDataSnapshot. 129 | * 130 | * @return An NSString containing the key for the location of this FDataSnapshot. 131 | */ 132 | @property (strong, readonly, nonatomic) NSString* key; 133 | 134 | 135 | /** 136 | * An iterator for snapshots of the child nodes in this snapshot. 137 | * You can use the native for..in syntax: 138 | * 139 | * for (FDataSnapshot* child in snapshot.children) { 140 | * ... 141 | * } 142 | * 143 | * @return An NSEnumerator of the children 144 | */ 145 | @property (strong, readonly, nonatomic) NSEnumerator* children; 146 | 147 | /** 148 | * The priority of the data in this FDataSnapshot. 149 | * 150 | * @return The priority as a string, or nil if no priority was set. 151 | */ 152 | @property (strong, readonly, nonatomic) id priority; 153 | 154 | @end 155 | -------------------------------------------------------------------------------- /Firebase.framework/Headers/FEventType.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Firebase iOS Client Library 3 | * 4 | * Copyright © 2013 Firebase - All Rights Reserved 5 | * https://www.firebase.com 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binaryform must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY FIREBASE AS IS AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 20 | * EVENT SHALL FIREBASE BE LIABLE FOR ANY DIRECT, 21 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef Firebase_FEventType_h 30 | #define Firebase_FEventType_h 31 | 32 | /** 33 | * This enum is the set of events that you can observe at a Firebase location. 34 | */ 35 | typedef NS_ENUM(NSInteger, FEventType) { 36 | FEventTypeChildAdded, // 0, fired when a new child node is added to a location 37 | FEventTypeChildRemoved, // 1, fired when a child node is removed from a location 38 | FEventTypeChildChanged, // 2, fired when a child node at a location changes 39 | FEventTypeChildMoved, // 3, fired when a child node moves relative to the other child nodes at a location 40 | FEventTypeValue // 4, fired when any data changes at a location and, recursively, any children 41 | }; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /Firebase.framework/Headers/FMutableData.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Firebase iOS Client Library 3 | * 4 | * Copyright © 2013 Firebase - All Rights Reserved 5 | * https://www.firebase.com 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binaryform must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY FIREBASE AS IS AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 20 | * EVENT SHALL FIREBASE BE LIABLE FOR ANY DIRECT, 21 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #import 30 | 31 | /** 32 | * An FMutableData instance is populated with data from a Firebase location. 33 | * When you are using runTransactionBlock:, you will be given an instance containing the current 34 | * data at that location. Your block will be responsible for updating that instance to the data 35 | * you wish to save at that location, and then returning using [FTransactionResult successWithValue:]. 36 | * 37 | * To modify the data, set its value property to any of the native types support by Firebase: 38 | * * NSNumber (includes BOOL) 39 | * * NSDictionary 40 | * * NSArray 41 | * * NSString 42 | * * nil / NSNull to remove the data 43 | * 44 | * Note that changes made to a child FMutableData instance will be visible to the parent. 45 | */ 46 | @interface FMutableData : NSObject 47 | 48 | 49 | /** @name Inspecting and navigating the data */ 50 | 51 | 52 | /** 53 | * Returns boolean indicating whether this mutable data has children. 54 | * 55 | * @return YES if this data contains child nodes. 56 | */ 57 | - (BOOL) hasChildren; 58 | 59 | 60 | /** 61 | * Indicates whether this mutable data has a child at the given path. 62 | * 63 | * @param path A path string, consisting either of a single segment, like 'child', or multiple segments, 'a/deeper/child' 64 | * @return YES if this data contains a child at the specified relative path 65 | */ 66 | - (BOOL) hasChildAtPath:(NSString *)path; 67 | 68 | 69 | /** 70 | * Used to obtain an FMutableData instance that encapsulates the data at the given relative path. 71 | * Note that changes made to the child will be visible to the parent. 72 | * 73 | * @param path A path string, consisting either of a single segment, like 'child', or multiple segments, 'a/deeper/child' 74 | * @return An FMutableData instance containing the data at the given path 75 | */ 76 | - (FMutableData *) childDataByAppendingPath:(NSString *)path; 77 | 78 | 79 | /** @name Properties */ 80 | 81 | 82 | /** 83 | * This method is deprecated. 84 | * 85 | * @return An FMutableData instance containing the data at the parent location, or nil if this is the top-most location 86 | */ 87 | @property (strong, readonly, nonatomic) FMutableData* parent __attribute__((deprecated("Deprecated. Do not use.")));; 88 | 89 | 90 | /** 91 | * To modify the data contained by this instance of FMutableData, set this to any of the native types support by Firebase: 92 | * 93 | * * NSNumber (includes BOOL) 94 | * * NSDictionary 95 | * * NSArray 96 | * * NSString 97 | * * nil / NSNull to remove the data 98 | * 99 | * Note that setting the value will override the priority at this location. 100 | * 101 | * @return The current data at this location as a native object 102 | */ 103 | @property (strong, nonatomic) id value; 104 | 105 | 106 | /** 107 | * Set this property to update the priority of the data at this location. Can be set to the following types: 108 | * 109 | * * NSNumber 110 | * * NSString 111 | * * nil / NSNull to remove the priority 112 | * 113 | * @return The priority of the data at this location 114 | */ 115 | @property (strong, nonatomic) id priority; 116 | 117 | 118 | /** 119 | * @return The number of child nodes at this location 120 | */ 121 | @property (readonly, nonatomic) NSUInteger childrenCount; 122 | 123 | 124 | /** 125 | * Used to iterate over the children at this location. You can use the native for .. in syntax: 126 | * 127 | * for (FMutableData* child in data.children) { 128 | * ... 129 | * } 130 | * 131 | * Note that this enumerator operates on an immutable copy of the child list. So, you can modify the instance 132 | * during iteration, but the new additions will not be visible until you get a new enumerator. 133 | */ 134 | @property (readonly, nonatomic, strong) NSEnumerator* children; 135 | 136 | 137 | /** 138 | * @return The key name of this node, or nil if it is the top-most location 139 | */ 140 | @property (readonly, nonatomic, strong) NSString* key; 141 | 142 | 143 | @end 144 | -------------------------------------------------------------------------------- /Firebase.framework/Headers/FQuery.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Firebase iOS Client Library 3 | * 4 | * Copyright © 2013 Firebase - All Rights Reserved 5 | * https://www.firebase.com 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binaryform must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY FIREBASE AS IS AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 20 | * EVENT SHALL FIREBASE BE LIABLE FOR ANY DIRECT, 21 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #import 30 | #import "FEventType.h" 31 | #import "FDataSnapshot.h" 32 | 33 | typedef NSUInteger FirebaseHandle; 34 | 35 | /** 36 | * An FQuery instance represents a query over the data at a particular location. 37 | * 38 | * You create one by calling one of the query methods (queryStartingAtPriority:, queryEndingAtPriority:, etc.) 39 | * on a Firebase reference. The query methods can be chained to further specify the data you are interested in 40 | * observing 41 | */ 42 | @interface FQuery : NSObject 43 | 44 | 45 | /** @name Attaching observers to read data */ 46 | 47 | /** 48 | * observeEventType:withBlock: is used to listen for data changes at a particular location. 49 | * This is the primary way to read data from Firebase. Your block will be triggered 50 | * for the initial data and again whenever the data changes. 51 | * 52 | * Use removeObserverWithHandle: to stop receiving updates. 53 | * @param eventType The type of event to listen for. 54 | * @param block The block that should be called with initial data and updates. It is passed the data as an FDataSnapshot. 55 | * @return A handle used to unregister this block later using removeObserverWithHandle: 56 | */ 57 | - (FirebaseHandle) observeEventType:(FEventType)eventType withBlock:(void (^)(FDataSnapshot* snapshot))block; 58 | 59 | 60 | /** 61 | * observeEventType:andPreviousSiblingKeyWithBlock: is used to listen for data changes at a particular location. 62 | * This is the primary way to read data from Firebase. Your block will be triggered 63 | * for the initial data and again whenever the data changes. In addition, for FEventTypeChildAdded, FEventTypeChildMoved, and 64 | * FEventTypeChildChanged events, your block will be passed the key of the previous node by priority order. 65 | * 66 | * Use removeObserverWithHandle: to stop receiving updates. 67 | * 68 | * @param eventType The type of event to listen for. 69 | * @param block The block that should be called with initial data and updates. It is passed the data as an FDataSnapshot 70 | * and the previous child's key. 71 | * @return A handle used to unregister this block later using removeObserverWithHandle: 72 | */ 73 | - (FirebaseHandle) observeEventType:(FEventType)eventType andPreviousSiblingKeyWithBlock:(void (^)(FDataSnapshot* snapshot, NSString* prevKey))block; 74 | 75 | 76 | /** 77 | * observeEventType:withBlock: is used to listen for data changes at a particular location. 78 | * This is the primary way to read data from Firebase. Your block will be triggered 79 | * for the initial data and again whenever the data changes. 80 | * 81 | * The cancelBlock will be called if you will no longer receive new events due to no longer having permission. 82 | * 83 | * Use removeObserverWithHandle: to stop receiving updates. 84 | * 85 | * @param eventType The type of event to listen for. 86 | * @param block The block that should be called with initial data and updates. It is passed the data as an FDataSnapshot. 87 | * @param cancelBlock The block that should be called if this client no longer has permission to receive these events 88 | * @return A handle used to unregister this block later using removeObserverWithHandle: 89 | */ 90 | - (FirebaseHandle) observeEventType:(FEventType)eventType withBlock:(void (^)(FDataSnapshot* snapshot))block withCancelBlock:(void (^)(NSError* error))cancelBlock; 91 | 92 | 93 | /** 94 | * observeEventType:andPreviousSiblingKeyWithBlock: is used to listen for data changes at a particular location. 95 | * This is the primary way to read data from Firebase. Your block will be triggered 96 | * for the initial data and again whenever the data changes. In addition, for FEventTypeChildAdded, FEventTypeChildMoved, and 97 | * FEventTypeChildChanged events, your block will be passed the key of the previous node by priority order. 98 | * 99 | * The cancelBlock will be called if you will no longer receive new events due to no longer having permission. 100 | * 101 | * Use removeObserverWithHandle: to stop receiving updates. 102 | * 103 | * @param eventType The type of event to listen for. 104 | * @param block The block that should be called with initial data and updates. It is passed the data as an FDataSnapshot 105 | * and the previous child's key. 106 | * @param cancelBlock The block that should be called if this client no longer has permission to receive these events 107 | * @return A handle used to unregister this block later using removeObserverWithHandle: 108 | */ 109 | - (FirebaseHandle) observeEventType:(FEventType)eventType andPreviousSiblingKeyWithBlock:(void (^)(FDataSnapshot* snapshot, NSString* prevKey))block withCancelBlock:(void (^)(NSError* error))cancelBlock; 110 | 111 | 112 | /** 113 | * This is equivalent to observeEventType:withBlock:, except the block is immediately canceled after the initial data is returned. 114 | * 115 | * @param eventType The type of event to listen for. 116 | * @param block The block that should be called. It is passed the data as an FDataSnapshot. 117 | */ 118 | - (void) observeSingleEventOfType:(FEventType)eventType withBlock:(void (^)(FDataSnapshot* snapshot))block; 119 | 120 | 121 | /** 122 | * This is equivalent to observeEventType:withBlock:, except the block is immediately canceled after the initial data is returned. In addition, for FEventTypeChildAdded, FEventTypeChildMoved, and 123 | * FEventTypeChildChanged events, your block will be passed the key of the previous node by priority order. 124 | * 125 | * @param eventType The type of event to listen for. 126 | * @param block The block that should be called. It is passed the data as an FDataSnapshot and the previous child's key. 127 | */ 128 | - (void) observeSingleEventOfType:(FEventType)eventType andPreviousSiblingKeyWithBlock:(void (^)(FDataSnapshot* snapshot, NSString* prevKey))block; 129 | 130 | 131 | /** 132 | * This is equivalent to observeEventType:withBlock:, except the block is immediately canceled after the initial data is returned. 133 | * 134 | * The cancelBlock will be called if you do not have permission to read data at this location. 135 | * 136 | * @param eventType The type of event to listen for. 137 | * @param block The block that should be called. It is passed the data as an FDataSnapshot. 138 | * @param cancelBlock The block that will be called if you don't have permission to access this data 139 | */ 140 | - (void) observeSingleEventOfType:(FEventType)eventType withBlock:(void (^)(FDataSnapshot* snapshot))block withCancelBlock:(void (^)(NSError* error))cancelBlock; 141 | 142 | 143 | /** 144 | * This is equivalent to observeEventType:withBlock:, except the block is immediately canceled after the initial data is returned. In addition, for FEventTypeChildAdded, FEventTypeChildMoved, and 145 | * FEventTypeChildChanged events, your block will be passed the key of the previous node by priority order. 146 | * 147 | * The cancelBlock will be called if you do not have permission to read data at this location. 148 | * 149 | * @param eventType The type of event to listen for. 150 | * @param block The block that should be called. It is passed the data as an FDataSnapshot and the previous child's key. 151 | * @param cancelBlock The block that will be called if you don't have permission to access this data 152 | */ 153 | - (void) observeSingleEventOfType:(FEventType)eventType andPreviousSiblingKeyWithBlock:(void (^)(FDataSnapshot* snapshot, NSString* prevKey))block withCancelBlock:(void (^)(NSError* error))cancelBlock; 154 | 155 | /** @name Detaching observers */ 156 | 157 | /** 158 | * Detach a block previously attached with observeEventType:withBlock:. 159 | * 160 | * @param handle The handle returned by the call to observeEventType:withBlock: which we are trying to remove. 161 | */ 162 | - (void) removeObserverWithHandle:(FirebaseHandle)handle; 163 | 164 | 165 | /** 166 | * Detach all blocks previously attached to this Firebase location with observeEventType:withBlock: 167 | */ 168 | - (void) removeAllObservers; 169 | 170 | /** 171 | * By calling `keepSynced:YES` on a location, the data for that location will automatically be downloaded and 172 | * kept in sync, even when no listeners are attached for that location. Additionally, while a location is kept 173 | * synced, it will not be evicted from the persistent disk cache. 174 | * 175 | * @param keepSynced Pass YES to keep this location synchronized, pass NO to stop synchronization. 176 | */ 177 | - (void) keepSynced:(BOOL)keepSynced; 178 | 179 | 180 | /** @name Querying and limiting */ 181 | 182 | 183 | /** 184 | * This method is deprecated in favor of using queryStartingAtValue:. This can be used with queryOrderedByPriority 185 | * to query by priority. 186 | * 187 | * queryStartingAtPriority: is used to generate a reference to a limited view of the data at this location. 188 | * The FQuery instance returned by queryStartingAtPriority: will respond to events at nodes with a priority 189 | * greater than or equal to startPriority 190 | * 191 | * @param startPriority The lower bound, inclusive, for the priority of data visible to the returned FQuery 192 | * @return An FQuery instance, limited to data with priority greater than or equal to startPriority 193 | */ 194 | - (FQuery *) queryStartingAtPriority:(id)startPriority __attribute__((deprecated("Use [[FQuery queryOrderedByPriority] queryStartingAtValue:] instead"))); 195 | 196 | 197 | /** 198 | * This method is deprecated in favor of using queryStartingAtValue:childKey:. This can be used with queryOrderedByPriority 199 | * to query by priority. 200 | * 201 | * queryStartingAtPriority:andChildName: is used to generate a reference to a limited view of the data at this location. 202 | * The FQuery instance returned by queryStartingAtPriority:andChildName will respond to events at nodes with a priority 203 | * greater than startPriority, or equal to startPriority and with a name greater than or equal to childName 204 | * 205 | * @param startPriority The lower bound, inclusive, for the priority of data visible to the returned FQuery 206 | * @param childName The lower bound, inclusive, for the name of nodes with priority equal to startPriority 207 | * @return An FQuery instance, limited to data with priority greater than or equal to startPriority 208 | */ 209 | - (FQuery *) queryStartingAtPriority:(id)startPriority andChildName:(NSString *)childName __attribute__((deprecated("Use [[FQuery queryOrderedByPriority] queryStartingAtValue:childKey:] instead"))); 210 | 211 | /** 212 | * This method is deprecated in favor of using queryEndingAtValue:. This can be used with queryOrderedByPriority 213 | * to query by priority. 214 | * 215 | * queryEndingAtPriority: is used to generate a reference to a limited view of the data at this location. 216 | * The FQuery instance returned by queryEndingAtPriority: will respond to events at nodes with a priority 217 | * less than or equal to startPriority and with a name greater than or equal to childName 218 | * 219 | * @param endPriority The upper bound, inclusive, for the priority of data visible to the returned FQuery 220 | * @return An FQuery instance, limited to data with priority less than or equal to endPriority 221 | */ 222 | - (FQuery *) queryEndingAtPriority:(id)endPriority __attribute__((deprecated("Use [[FQuery queryOrderedByPriority] queryEndingAtValue:] instead"))); 223 | 224 | 225 | /** 226 | * This method is deprecated in favor of using queryEndingAtValue:childKey:. This can be used with queryOrderedByPriority 227 | * to query by priority. 228 | * 229 | * queryEndingAtPriority:andChildName: is used to generate a reference to a limited view of the data at this location. 230 | * The FQuery instance returned by queryEndingAtPriority:andChildName will respond to events at nodes with a priority 231 | * less than endPriority, or equal to endPriority and with a name less than or equal to childName 232 | * 233 | * @param endPriority The upper bound, inclusive, for the priority of data visible to the returned FQuery 234 | * @param childName The upper bound, inclusive, for the name of nodes with priority equal to endPriority 235 | * @return An FQuery instance, limited to data with priority less than endPriority or equal to endPriority and with a name less than or equal to childName 236 | */ 237 | - (FQuery *) queryEndingAtPriority:(id)endPriority andChildName:(NSString *)childName __attribute__((deprecated("Use [[FQuery queryOrderedByPriority] queryEndingAtValue:childKey:] instead"))); 238 | 239 | 240 | /** 241 | * This method is deprecated in favor of using queryEqualToValue:. This can be used with queryOrderedByPriority 242 | * to query by priority. 243 | * 244 | * queryEqualToPriority: is used to generate a reference to a limited view of the data at this location. 245 | * The FQuery instance returned by queryEqualToPriority: will respond to events at nodes with a priority equal to 246 | * supplied argument. 247 | * 248 | * @param priority The priority that the data returned by this FQuery will have 249 | * @return An Fquery instance, limited to data with the supplied priority. 250 | */ 251 | - (FQuery *) queryEqualToPriority:(id)priority __attribute__((deprecated("Use [[FQuery queryOrderedByPriority] queryEqualToValue:] instead"))); 252 | 253 | 254 | /** 255 | * This method is deprecated in favor of using queryEqualAtValue:childKey:. This can be used with queryOrderedByPriority 256 | * to query by priority. 257 | * 258 | * queryEqualToPriority:andChildName: is used to generate a reference to a limited view of the data at this location. 259 | * The FQuery instance returned by queryEqualToPriority:andChildName will respond to events at nodes with a priority 260 | * equal to the supplied argument with a name equal to childName. There will be at most one node that matches because 261 | * child names are unique. 262 | * 263 | * @param priority The priority that the data returned by this FQuery will have 264 | * @param childName The name of nodes with the right priority 265 | * @return An FQuery instance, limited to data with the supplied priority and the name. 266 | */ 267 | - (FQuery *) queryEqualToPriority:(id)priority andChildName:(NSString *)childName __attribute__((deprecated("Use [[FQuery queryOrderedByPriority] queryEqualToValue:childKey:] instead"))); 268 | 269 | /** 270 | * This method is deprecated in favor of using queryLimitedToFirst:limit or queryLimitedToLast:limit instead. 271 | * 272 | * queryLimitedToNumberOfChildren: is used to generate a reference to a limited view of the data at this location. 273 | * The FQuery instance returned by queryLimitedToNumberOfChildren: will respond to events from at most limit child nodes. 274 | * 275 | * @param limit The upper bound, inclusive, for the number of child nodes to receive events for 276 | * @return An FQuery instance, limited to at most limit child nodes. 277 | */ 278 | - (FQuery *) queryLimitedToNumberOfChildren:(NSUInteger)limit __attribute__((deprecated("Use [FQuery queryLimitedToFirst:limit] or [FQuery queryLimitedToLast:limit] instead"))); 279 | 280 | 281 | /** 282 | * queryLimitedToFirst: is used to generate a reference to a limited view of the data at this location. 283 | * The FQuery instance returned by queryLimitedToFirst: will respond to at most the first limit child nodes. 284 | * 285 | * @param limit The upper bound, inclusive, for the number of child nodes to receive events for 286 | * @return An FQuery instance, limited to at most limit child nodes. 287 | */ 288 | - (FQuery *) queryLimitedToFirst:(NSUInteger)limit; 289 | 290 | 291 | /** 292 | * queryLimitedToLast: is used to generate a reference to a limited view of the data at this location. 293 | * The FQuery instance returned by queryLimitedToLast: will respond to at most the last limit child nodes. 294 | * 295 | * @param limit The upper bound, inclusive, for the number of child nodes to receive events for 296 | * @return An FQuery instance, limited to at most limit child nodes. 297 | */ 298 | - (FQuery *) queryLimitedToLast:(NSUInteger)limit; 299 | 300 | /** 301 | * queryOrderBy: is used to generate a reference to a view of the data that's been sorted by the values of 302 | * a particular child key. This method is intended to be used in combination with queryStartingAtValue:, 303 | * queryEndingAtValue:, or queryEqualToValue:. 304 | * 305 | * @param key The child key to use in ordering data visible to the returned FQuery 306 | * @return An FQuery instance, ordered by the values of the specified child key. 307 | */ 308 | - (FQuery *) queryOrderedByChild:(NSString *)key; 309 | 310 | /** 311 | * queryOrderedByKey: is used to generate a reference to a view of the data that's been sorted by child key. 312 | * This method is intended to be used in combination with queryStartingAtValue:, queryEndingAtValue:, 313 | * or queryEqualToValue:. 314 | * 315 | * @return An FQuery instance, ordered by child keys. 316 | */ 317 | - (FQuery *) queryOrderedByKey; 318 | 319 | /** 320 | * queryOrderedByValue: is used to generate a reference to a view of the data that's been sorted by child value. 321 | * This method is intended to be used in combination with queryStartingAtValue:, queryEndingAtValue:, 322 | * or queryEqualToValue:. 323 | * 324 | * @return An FQuery instance, ordered by child value. 325 | */ 326 | - (FQuery *) queryOrderedByValue; 327 | 328 | /** 329 | * queryOrderedByPriority: is used to generate a reference to a view of the data that's been sorted by child 330 | * priority. This method is intended to be used in combination with queryStartingAtValue:, queryEndingAtValue:, 331 | * or queryEqualToValue:. 332 | * 333 | * @return An FQuery instance, ordered by child priorities. 334 | */ 335 | - (FQuery *) queryOrderedByPriority; 336 | 337 | /** 338 | * queryStartingAtValue: is used to generate a reference to a limited view of the data at this location. 339 | * The FQuery instance returned by queryStartingAtValue: will respond to events at nodes with a value 340 | * greater than or equal to startValue. 341 | * 342 | * @param startValue The lower bound, inclusive, for the value of data visible to the returned FQuery 343 | * @return An FQuery instance, limited to data with value greater than or equal to startValue 344 | */ 345 | - (FQuery *) queryStartingAtValue:(id)startValue; 346 | 347 | /** 348 | * queryStartingAtValue:childKey: is used to generate a reference to a limited view of the data at this location. 349 | * The FQuery instance returned by queryStartingAtValue:childKey will respond to events at nodes with a value 350 | * greater than startValue, or equal to startValue and with a key greater than or equal to childKey. 351 | * 352 | * @param startValue The lower bound, inclusive, for the value of data visible to the returned FQuery 353 | * @param childKey The lower bound, inclusive, for the key of nodes with value equal to startValue 354 | * @return An FQuery instance, limited to data with value greater than or equal to startValue 355 | */ 356 | - (FQuery *) queryStartingAtValue:(id)startValue childKey:(NSString *)childKey; 357 | 358 | /** 359 | * queryEndingAtValue: is used to generate a reference to a limited view of the data at this location. 360 | * The FQuery instance returned by queryEndingAtValue: will respond to events at nodes with a value 361 | * less than or equal to endValue. 362 | * 363 | * @param endValue The upper bound, inclusive, for the value of data visible to the returned FQuery 364 | * @return An FQuery instance, limited to data with value less than or equal to endValue 365 | */ 366 | - (FQuery *) queryEndingAtValue:(id)endValue; 367 | 368 | /** 369 | * queryEndingAtValue:childKey: is used to generate a reference to a limited view of the data at this location. 370 | * The FQuery instance returned by queryEndingAtValue:childKey will respond to events at nodes with a value 371 | * less than endValue, or equal to endValue and with a key less than or equal to childKey. 372 | * 373 | * @param endValue The upper bound, inclusive, for the value of data visible to the returned FQuery 374 | * @param childKey The upper bound, inclusive, for the key of nodes with value equal to endValue 375 | * @return An FQuery instance, limited to data with value less than or equal to endValue 376 | */ 377 | - (FQuery *) queryEndingAtValue:(id)endValue childKey:(NSString *)childKey; 378 | 379 | /** 380 | * queryEqualToValue: is used to generate a reference to a limited view of the data at this location. 381 | * The FQuery instance returned by queryEqualToValue: will respond to events at nodes with a value equal 382 | * to the supplied argument. 383 | * 384 | * @param value The value that the data returned by this FQuery will have 385 | * @return An Fquery instance, limited to data with the supplied value. 386 | */ 387 | - (FQuery *) queryEqualToValue:(id)value; 388 | 389 | /** 390 | * queryEqualToValue:childKey: is used to generate a reference to a limited view of the data at this location. 391 | * The FQuery instance returned by queryEqualToValue:childKey will respond to events at nodes with a value 392 | * equal to the supplied argument with a name equal to childKey. There will be at most one node that matches because 393 | * child keys are unique. 394 | * 395 | * @param value The value that the data returned by this FQuery will have 396 | * @param childKey The name of nodes with the right value 397 | * @return An FQuery instance, limited to data with the supplied value and the key. 398 | */ 399 | - (FQuery *) queryEqualToValue:(id)value childKey:(NSString *)childKey; 400 | 401 | 402 | /** @name Properties */ 403 | 404 | 405 | /** 406 | * Get a Firebase reference for the location of this query. 407 | * 408 | * @return A Firebase instance for the location of this query. 409 | */ 410 | @property (nonatomic, readonly, strong) Firebase* ref; 411 | 412 | @end 413 | -------------------------------------------------------------------------------- /Firebase.framework/Headers/FTransactionResult.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Firebase iOS Client Library 3 | * 4 | * Copyright © 2013 Firebase - All Rights Reserved 5 | * https://www.firebase.com 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binaryform must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY FIREBASE AS IS AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 20 | * EVENT SHALL FIREBASE BE LIABLE FOR ANY DIRECT, 21 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #import 30 | #import "FMutableData.h" 31 | 32 | /** 33 | * Used for runTransactionBlock:. An FTransactionResult instance is a container for the results of the transaction. 34 | */ 35 | @interface FTransactionResult : NSObject 36 | 37 | /** 38 | * Used for runTransactionBlock:. Indicates that the new value should be saved at this location 39 | * 40 | * @param value An FMutableData instance containing the new value to be set 41 | * @return An FTransactionResult instance that can be used as a return value from the block given to runTransactionBlock: 42 | */ 43 | + (FTransactionResult *) successWithValue:(FMutableData *)value; 44 | 45 | 46 | /** 47 | * Used for runTransactionBlock:. Indicates that the current transaction should no longer proceed. 48 | * 49 | * @return An FTransactionResult instance that can be used as a return value from the block given to runTransactionBlock: 50 | */ 51 | + (FTransactionResult *) abort; 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /Firebase.framework/Headers/Firebase.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Firebase iOS Client Library 3 | * 4 | * Copyright © 2013 Firebase - All Rights Reserved 5 | * https://www.firebase.com 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binaryform must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY FIREBASE AS IS AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 20 | * EVENT SHALL FIREBASE BE LIABLE FOR ANY DIRECT, 21 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | 30 | #import 31 | #import "FQuery.h" 32 | #import "FirebaseApp.h" 33 | #import "FDataSnapshot.h" 34 | #import "FMutableData.h" 35 | #import "FTransactionResult.h" 36 | #import "FAuthData.h" 37 | #import "FAuthType.h" 38 | #import "FirebaseServerValue.h" 39 | #import "FConfig.h" 40 | 41 | /** 42 | * A Firebase reference represents a particular location in your Firebase 43 | * and can be used for reading or writing data to that Firebase location. 44 | * 45 | * This class is the starting point for all Firebase operations. After you've 46 | * initialized it with initWithUrl: you can use it 47 | * to read data (ie. observeEventType:withBlock:), write data (ie. setValue:), and to create new 48 | * Firebase references (ie. child:). 49 | */ 50 | @interface Firebase : FQuery 51 | 52 | 53 | /** @name Initializing a Firebase object */ 54 | 55 | /** 56 | * Initialize this Firebase reference with an absolute URL. 57 | * 58 | * @param url The Firebase URL (ie: https://SampleChat.firebaseIO-demo.com) 59 | */ 60 | - (id)initWithUrl:(NSString *)url; 61 | 62 | /** @name Getting references to children locations */ 63 | 64 | /** 65 | * Get a Firebase reference for the location at the specified relative path. 66 | * The relative path can either be a simple child key (e.g. 'fred') or a 67 | * deeper slash-separated path (e.g. 'fred/name/first'). 68 | * 69 | * @param pathString A relative path from this location to the desired child location. 70 | * @return A Firebase reference for the specified relative path. 71 | */ 72 | - (Firebase *) childByAppendingPath:(NSString *)pathString; 73 | 74 | 75 | /** 76 | * childByAutoId generates a new child location using a unique key and returns a 77 | * Firebase reference to it. This is useful when the children of a Firebase 78 | * location represent a list of items. 79 | * 80 | * The unique key generated by childByAutoId: is prefixed with a client-generated 81 | * timestamp so that the resulting list will be chronologically-sorted. 82 | * 83 | * @return A Firebase reference for the generated location. 84 | */ 85 | - (Firebase *) childByAutoId; 86 | 87 | 88 | /** @name Writing data */ 89 | 90 | /*! Write data to this Firebase location. 91 | 92 | This will overwrite any data at this location and all child locations. 93 | 94 | Data types that can be set are: 95 | 96 | - NSString -- @"Hello World" 97 | - NSNumber (also includes boolean) -- @YES, @43, @4.333 98 | - NSDictionary -- @{@"key": @"value", @"nested": @{@"another": @"value"} } 99 | - NSArray 100 | 101 | The effect of the write will be visible immediately and the corresponding 102 | events will be triggered. Synchronization of the data to the Firebase 103 | servers will also be started. 104 | 105 | Passing null for the new value is equivalent to calling remove:; 106 | all data at this location or any child location will be deleted. 107 | 108 | Note that setValue: will remove any priority stored at this location, so if priority 109 | is meant to be preserved, you should use setValue:andPriority: instead. 110 | 111 | 112 | **Server Values** - Placeholder values you may write into Firebase as a value or priority 113 | that will automatically be populated by the Firebase Server. 114 | 115 | - kFirebaseServerValueTimestamp - The number of milliseconds since the Unix epoch 116 | 117 | 118 | @param value The value to be written. 119 | */ 120 | - (void) setValue:(id)value; 121 | 122 | 123 | #define kFirebaseServerValueTimestamp @{ @".sv": @"timestamp" } 124 | 125 | /** 126 | * The same as setValue: with a block that gets triggered after the write operation has 127 | * been committed to the Firebase servers. 128 | * 129 | * @param value The value to be written. 130 | * @param block The block to be called after the write has been committed to the Firebase servers. 131 | */ 132 | - (void) setValue:(id)value withCompletionBlock:(void (^)(NSError* error, Firebase* ref))block; 133 | 134 | 135 | /** 136 | * The same as setValue: with an additional priority to be attached to the data being written. 137 | * Priorities are used to order items. 138 | * 139 | * @param value The value to be written. 140 | * @param priority The priority to be attached to that data. 141 | */ 142 | - (void) setValue:(id)value andPriority:(id)priority; 143 | 144 | 145 | /** 146 | * The same as setValue:andPriority: with a block that gets triggered after the write operation has 147 | * been committed to the Firebase servers. 148 | * 149 | * @param value The value to be written. 150 | * @param priority The priority to be attached to that data. 151 | * @param block The block to be called after the write has been committed to the Firebase servers. 152 | */ 153 | - (void) setValue:(id)value andPriority:(id)priority withCompletionBlock:(void (^)(NSError* error, Firebase* ref))block; 154 | 155 | 156 | /** 157 | * Remove the data at this Firebase location. Any data at child locations will also be deleted. 158 | * 159 | * The effect of the delete will be visible immediately and the corresponding events 160 | * will be triggered. Synchronization of the delete to the Firebase servers will 161 | * also be started. 162 | * 163 | * remove: is equivalent to calling setValue:nil 164 | */ 165 | - (void) removeValue; 166 | 167 | 168 | /** 169 | * The same as remove: with a block that gets triggered after the remove operation has 170 | * been committed to the Firebase servers. 171 | * 172 | * @param block The block to be called after the remove has been committed to the Firebase servers. 173 | */ 174 | - (void) removeValueWithCompletionBlock:(void (^)(NSError* error, Firebase* ref))block; 175 | 176 | /** 177 | * Set a priority for the data at this Firebase location. 178 | * Priorities can be used to provide a custom ordering for the children at a location 179 | * (if no priorities are specified, the children are ordered by key). 180 | * 181 | * You cannot set a priority on an empty location. For this reason 182 | * setValue:andPriority: should be used when setting initial data with a specific priority 183 | * and setPriority: should be used when updating the priority of existing data. 184 | * 185 | * Children are sorted based on this priority using the following rules: 186 | * 187 | * Children with no priority come first. 188 | * Children with a number as their priority come next. They are sorted numerically by priority (small to large). 189 | * Children with a string as their priority come last. They are sorted lexicographically by priority. 190 | * Whenever two children have the same priority (including no priority), they are sorted by key. Numeric 191 | * keys come first (sorted numerically), followed by the remaining keys (sorted lexicographically). 192 | * 193 | * Note that priorities are parsed and ordered as IEEE 754 double-precision floating-point numbers. 194 | * Keys are always stored as strings and are treated as numbers only when they can be parsed as a 195 | * 32-bit integer 196 | * 197 | * @param priority The priority to set at the specified location. 198 | */ 199 | - (void) setPriority:(id)priority; 200 | 201 | 202 | /** 203 | * The same as setPriority: with a block block that is called once the priority has 204 | * been committed to the Firebase servers. 205 | * 206 | * @param priority The priority to set at the specified location. 207 | * @param block The block that is triggered after the priority has been written on the servers. 208 | */ 209 | - (void) setPriority:(id)priority withCompletionBlock:(void (^)(NSError* error, Firebase* ref))block; 210 | 211 | /** 212 | * Update changes the values at the specified paths in the dictionary without overwriting other 213 | * keys at this location. 214 | * 215 | * @param values A dictionary of the keys to change and their new values 216 | */ 217 | - (void) updateChildValues:(NSDictionary *)values; 218 | 219 | /** 220 | * The same as update: with a block block that is called once the update has been committed to the 221 | * Firebase servers 222 | * 223 | * @param values A dictionary of the keys to change and their new values 224 | * @param block The block that is triggered after the update has been written on the Firebase servers 225 | */ 226 | - (void) updateChildValues:(NSDictionary *)values withCompletionBlock:(void (^)(NSError* error, Firebase* ref))block; 227 | 228 | 229 | /** @name Attaching observers to read data */ 230 | 231 | /** 232 | * observeEventType:withBlock: is used to listen for data changes at a particular location. 233 | * This is the primary way to read data from Firebase. Your block will be triggered 234 | * for the initial data and again whenever the data changes. 235 | * 236 | * Use removeObserverWithHandle: to stop receiving updates. 237 | * @param eventType The type of event to listen for. 238 | * @param block The block that should be called with initial data and updates. It is passed the data as an FDataSnapshot. 239 | * @return A handle used to unregister this block later using removeObserverWithHandle: 240 | */ 241 | - (FirebaseHandle) observeEventType:(FEventType)eventType withBlock:(void (^)(FDataSnapshot* snapshot))block; 242 | 243 | 244 | /** 245 | * observeEventType:andPreviousSiblingKeyWithBlock: is used to listen for data changes at a particular location. 246 | * This is the primary way to read data from Firebase. Your block will be triggered 247 | * for the initial data and again whenever the data changes. In addition, for FEventTypeChildAdded, FEventTypeChildMoved, and 248 | * FEventTypeChildChanged events, your block will be passed the key of the previous node by priority order. 249 | * 250 | * Use removeObserverWithHandle: to stop receiving updates. 251 | * 252 | * @param eventType The type of event to listen for. 253 | * @param block The block that should be called with initial data and updates. It is passed the data as an FDataSnapshot 254 | * and the previous child's key. 255 | * @return A handle used to unregister this block later using removeObserverWithHandle: 256 | */ 257 | - (FirebaseHandle) observeEventType:(FEventType)eventType andPreviousSiblingKeyWithBlock:(void (^)(FDataSnapshot* snapshot, NSString* prevKey))block; 258 | 259 | 260 | /** 261 | * observeEventType:withBlock: is used to listen for data changes at a particular location. 262 | * This is the primary way to read data from Firebase. Your block will be triggered 263 | * for the initial data and again whenever the data changes. 264 | * 265 | * The cancelBlock will be called if you will no longer receive new events due to no longer having permission. 266 | * 267 | * Use removeObserverWithHandle: to stop receiving updates. 268 | * 269 | * @param eventType The type of event to listen for. 270 | * @param block The block that should be called with initial data and updates. It is passed the data as an FDataSnapshot. 271 | * @param cancelBlock The block that should be called if this client no longer has permission to receive these events 272 | * @return A handle used to unregister this block later using removeObserverWithHandle: 273 | */ 274 | - (FirebaseHandle) observeEventType:(FEventType)eventType withBlock:(void (^)(FDataSnapshot* snapshot))block withCancelBlock:(void (^)(NSError* error))cancelBlock; 275 | 276 | 277 | /** 278 | * observeEventType:andPreviousSiblingKeyWithBlock: is used to listen for data changes at a particular location. 279 | * This is the primary way to read data from Firebase. Your block will be triggered 280 | * for the initial data and again whenever the data changes. In addition, for FEventTypeChildAdded, FEventTypeChildMoved, and 281 | * FEventTypeChildChanged events, your block will be passed the key of the previous node by priority order. 282 | * 283 | * The cancelBlock will be called if you will no longer receive new events due to no longer having permission. 284 | * 285 | * Use removeObserverWithHandle: to stop receiving updates. 286 | * 287 | * @param eventType The type of event to listen for. 288 | * @param block The block that should be called with initial data and updates. It is passed the data as an FDataSnapshot 289 | * and the previous child's key. 290 | * @param cancelBlock The block that should be called if this client no longer has permission to receive these events 291 | * @return A handle used to unregister this block later using removeObserverWithHandle: 292 | */ 293 | - (FirebaseHandle) observeEventType:(FEventType)eventType andPreviousSiblingKeyWithBlock:(void (^)(FDataSnapshot* snapshot, NSString* prevKey))block withCancelBlock:(void (^)(NSError* error))cancelBlock; 294 | 295 | 296 | /** 297 | * This is equivalent to observeEventType:withBlock:, except the block is immediately canceled after the initial data is returned. 298 | * 299 | * @param eventType The type of event to listen for. 300 | * @param block The block that should be called. It is passed the data as an FDataSnapshot. 301 | */ 302 | - (void) observeSingleEventOfType:(FEventType)eventType withBlock:(void (^)(FDataSnapshot* snapshot))block; 303 | 304 | 305 | /** 306 | * This is equivalent to observeEventType:withBlock:, except the block is immediately canceled after the initial data is returned. In addition, for FEventTypeChildAdded, FEventTypeChildMoved, and 307 | * FEventTypeChildChanged events, your block will be passed the key of the previous node by priority order. 308 | * 309 | * @param eventType The type of event to listen for. 310 | * @param block The block that should be called. It is passed the data as an FDataSnapshot and the previous child's key. 311 | */ 312 | - (void) observeSingleEventOfType:(FEventType)eventType andPreviousSiblingKeyWithBlock:(void (^)(FDataSnapshot* snapshot, NSString* prevKey))block; 313 | 314 | 315 | /** 316 | * This is equivalent to observeEventType:withBlock:, except the block is immediately canceled after the initial data is returned. 317 | * 318 | * The cancelBlock will be called if you do not have permission to read data at this location. 319 | * 320 | * @param eventType The type of event to listen for. 321 | * @param block The block that should be called. It is passed the data as an FDataSnapshot. 322 | * @param cancelBlock The block that will be called if you don't have permission to access this data 323 | */ 324 | - (void) observeSingleEventOfType:(FEventType)eventType withBlock:(void (^)(FDataSnapshot* snapshot))block withCancelBlock:(void (^)(NSError* error))cancelBlock; 325 | 326 | 327 | /** 328 | * This is equivalent to observeEventType:withBlock:, except the block is immediately canceled after the initial data is returned. In addition, for FEventTypeChildAdded, FEventTypeChildMoved, and 329 | * FEventTypeChildChanged events, your block will be passed the key of the previous node by priority order. 330 | * 331 | * The cancelBlock will be called if you do not have permission to read data at this location. 332 | * 333 | * @param eventType The type of event to listen for. 334 | * @param block The block that should be called. It is passed the data as an FDataSnapshot and the previous child's key. 335 | * @param cancelBlock The block that will be called if you don't have permission to access this data 336 | */ 337 | - (void) observeSingleEventOfType:(FEventType)eventType andPreviousSiblingKeyWithBlock:(void (^)(FDataSnapshot* snapshot, NSString* prevKey))block withCancelBlock:(void (^)(NSError* error))cancelBlock; 338 | 339 | /** @name Detaching observers */ 340 | 341 | /** 342 | * Detach a block previously attached with observeEventType:withBlock:. 343 | * 344 | * @param handle The handle returned by the call to observeEventType:withBlock: which we are trying to remove. 345 | */ 346 | - (void) removeObserverWithHandle:(FirebaseHandle)handle; 347 | 348 | /** 349 | * By calling `keepSynced:YES` on a location, the data for that location will automatically be downloaded and 350 | * kept in sync, even when no listeners are attached for that location. Additionally, while a location is kept 351 | * synced, it will not be evicted from the persistent disk cache. 352 | * 353 | * @param keepSynced Pass YES to keep this location synchronized, pass NO to stop synchronization. 354 | */ 355 | - (void) keepSynced:(BOOL)keepSynced; 356 | 357 | 358 | /** 359 | * Calling removeAllObservers does not remove any observers at child references. 360 | * removeAllObservers must be called again for each child reference where a listener was established to remove the observers. 361 | */ 362 | - (void) removeAllObservers; 363 | 364 | /** @name Querying and limiting */ 365 | 366 | 367 | /** 368 | * This method is deprecated in favor of using queryStartingAtValue:. This can be used with queryOrderedByPriority 369 | * to query by priority. 370 | * 371 | * queryStartingAtPriority: is used to generate a reference to a limited view of the data at this location. 372 | * The FQuery instance returned by queryStartingAtPriority: will respond to events at nodes with a priority 373 | * greater than or equal to startPriority 374 | * 375 | * @param startPriority The lower bound, inclusive, for the priority of data visible to the returned FQuery 376 | * @return An FQuery instance, limited to data with priority greater than or equal to startPriority 377 | */ 378 | - (FQuery *) queryStartingAtPriority:(id)startPriority __attribute__((deprecated("Use [[FQuery queryOrderedByPriority] queryStartingAtValue:] instead"))); 379 | 380 | 381 | /** 382 | * This method is deprecated in favor of using queryStartingAtValue:childKey:. This can be used with queryOrderedByPriority 383 | * to query by priority. 384 | * 385 | * queryStartingAtPriority:andChildName: is used to generate a reference to a limited view of the data at this location. 386 | * The FQuery instance returned by queryStartingAtPriority:andChildName will respond to events at nodes with a priority 387 | * greater than startPriority, or equal to startPriority and with a name greater than or equal to childName 388 | * 389 | * @param startPriority The lower bound, inclusive, for the priority of data visible to the returned FQuery 390 | * @param childName The lower bound, inclusive, for the name of nodes with priority equal to startPriority 391 | * @return An FQuery instance, limited to data with priority greater than or equal to startPriority 392 | */ 393 | - (FQuery *) queryStartingAtPriority:(id)startPriority andChildName:(NSString *)childName __attribute__((deprecated("Use [[FQuery queryOrderedByPriority] queryStartingAtValue:childKey:] instead"))); 394 | 395 | /** 396 | * This method is deprecated in favor of using queryEndingAtValue:. This can be used with queryOrderedByPriority 397 | * to query by priority. 398 | * 399 | * queryEndingAtPriority: is used to generate a reference to a limited view of the data at this location. 400 | * The FQuery instance returned by queryEndingAtPriority: will respond to events at nodes with a priority 401 | * less than or equal to startPriority and with a name greater than or equal to childName 402 | * 403 | * @param endPriority The upper bound, inclusive, for the priority of data visible to the returned FQuery 404 | * @return An FQuery instance, limited to data with priority less than or equal to endPriority 405 | */ 406 | - (FQuery *) queryEndingAtPriority:(id)endPriority __attribute__((deprecated("Use [[FQuery queryOrderedByPriority] queryEndingAtValue:] instead"))); 407 | 408 | 409 | /** 410 | * This method is deprecated in favor of using queryEndingAtValue:childKey:. This can be used with queryOrderedByPriority 411 | * to query by priority. 412 | * 413 | * queryEndingAtPriority:andChildName: is used to generate a reference to a limited view of the data at this location. 414 | * The FQuery instance returned by queryEndingAtPriority:andChildName will respond to events at nodes with a priority 415 | * less than endPriority, or equal to endPriority and with a name less than or equal to childName 416 | * 417 | * @param endPriority The upper bound, inclusive, for the priority of data visible to the returned FQuery 418 | * @param childName The upper bound, inclusive, for the name of nodes with priority equal to endPriority 419 | * @return An FQuery instance, limited to data with priority less than endPriority or equal to endPriority and with a name less than or equal to childName 420 | */ 421 | - (FQuery *) queryEndingAtPriority:(id)endPriority andChildName:(NSString *)childName __attribute__((deprecated("Use [[FQuery queryOrderedByPriority] queryEndingAtValue:childKey:] instead"))); 422 | 423 | 424 | /** 425 | * This method is deprecated in favor of using queryEqualToValue:. This can be used with queryOrderedByPriority 426 | * to query by priority. 427 | * 428 | * queryEqualToPriority: is used to generate a reference to a limited view of the data at this location. 429 | * The FQuery instance returned by queryEqualToPriority: will respond to events at nodes with a priority equal to 430 | * supplied argument. 431 | * 432 | * @param priority The priority that the data returned by this FQuery will have 433 | * @return An Fquery instance, limited to data with the supplied priority. 434 | */ 435 | - (FQuery *) queryEqualToPriority:(id)priority __attribute__((deprecated("Use [[FQuery queryOrderedByPriority] queryEqualToValue:] instead"))); 436 | 437 | 438 | /** 439 | * This method is deprecated in favor of using queryEqualAtValue:childKey:. This can be used with queryOrderedByPriority 440 | * to query by priority. 441 | * 442 | * queryEqualToPriority:andChildName: is used to generate a reference to a limited view of the data at this location. 443 | * The FQuery instance returned by queryEqualToPriority:andChildName will respond to events at nodes with a priority 444 | * equal to the supplied argument with a name equal to childName. There will be at most one node that matches because 445 | * child names are unique. 446 | * 447 | * @param priority The priority that the data returned by this FQuery will have 448 | * @param childName The name of nodes with the right priority 449 | * @return An FQuery instance, limited to data with the supplied priority and the name. 450 | */ 451 | - (FQuery *) queryEqualToPriority:(id)priority andChildName:(NSString *)childName __attribute__((deprecated("Use [[FQuery queryOrderedByPriority] queryEqualToValue:childKey:] instead"))); 452 | 453 | /** 454 | * This method is deprecated in favor of using queryLimitedToFirst:limit or queryLimitedToLast:limit instead. 455 | * 456 | * queryLimitedToNumberOfChildren: is used to generate a reference to a limited view of the data at this location. 457 | * The FQuery instance returned by queryLimitedToNumberOfChildren: will respond to events from at most limit child nodes. 458 | * 459 | * @param limit The upper bound, inclusive, for the number of child nodes to receive events for 460 | * @return An FQuery instance, limited to at most limit child nodes. 461 | */ 462 | - (FQuery *) queryLimitedToNumberOfChildren:(NSUInteger)limit __attribute__((deprecated("Use [FQuery queryLimitedToFirst:limit] or [FQuery queryLimitedToLast:limit] instead"))); 463 | 464 | 465 | /** 466 | * queryLimitedToFirst: is used to generate a reference to a limited view of the data at this location. 467 | * The FQuery instance returned by queryLimitedToFirst: will respond to at most the first limit child nodes. 468 | * 469 | * @param limit The upper bound, inclusive, for the number of child nodes to receive events for 470 | * @return An FQuery instance, limited to at most limit child nodes. 471 | */ 472 | - (FQuery *) queryLimitedToFirst:(NSUInteger)limit; 473 | 474 | 475 | /** 476 | * queryLimitedToLast: is used to generate a reference to a limited view of the data at this location. 477 | * The FQuery instance returned by queryLimitedToLast: will respond to at most the last limit child nodes. 478 | * 479 | * @param limit The upper bound, inclusive, for the number of child nodes to receive events for 480 | * @return An FQuery instance, limited to at most limit child nodes. 481 | */ 482 | - (FQuery *) queryLimitedToLast:(NSUInteger)limit; 483 | 484 | /** 485 | * queryOrderBy: is used to generate a reference to a view of the data that's been sorted by the values of 486 | * a particular child key. This method is intended to be used in combination with queryStartingAtValue:, 487 | * queryEndingAtValue:, or queryEqualToValue:. 488 | * 489 | * @param key The child key to use in ordering data visible to the returned FQuery 490 | * @return An FQuery instance, ordered by the values of the specified child key. 491 | */ 492 | - (FQuery *) queryOrderedByChild:(NSString *)key; 493 | 494 | /** 495 | * queryOrderedByKey: is used to generate a reference to a view of the data that's been sorted by child key. 496 | * This method is intended to be used in combination with queryStartingAtValue:, queryEndingAtValue:, 497 | * or queryEqualToValue:. 498 | * 499 | * @return An FQuery instance, ordered by child keys. 500 | */ 501 | - (FQuery *) queryOrderedByKey; 502 | 503 | /** 504 | * queryOrderedByPriority: is used to generate a reference to a view of the data that's been sorted by child 505 | * priority. This method is intended to be used in combination with queryStartingAtValue:, queryEndingAtValue:, 506 | * or queryEqualToValue:. 507 | * 508 | * @return An FQuery instance, ordered by child priorities. 509 | */ 510 | - (FQuery *) queryOrderedByPriority; 511 | 512 | /** 513 | * queryStartingAtValue: is used to generate a reference to a limited view of the data at this location. 514 | * The FQuery instance returned by queryStartingAtValue: will respond to events at nodes with a value 515 | * greater than or equal to startValue. 516 | * 517 | * @param startValue The lower bound, inclusive, for the value of data visible to the returned FQuery 518 | * @return An FQuery instance, limited to data with value greater than or equal to startValue 519 | */ 520 | - (FQuery *) queryStartingAtValue:(id)startValue; 521 | 522 | /** 523 | * queryStartingAtValue:childKey: is used to generate a reference to a limited view of the data at this location. 524 | * The FQuery instance returned by queryStartingAtValue:childKey will respond to events at nodes with a value 525 | * greater than startValue, or equal to startValue and with a key greater than or equal to childKey. 526 | * 527 | * @param startValue The lower bound, inclusive, for the value of data visible to the returned FQuery 528 | * @param childKey The lower bound, inclusive, for the key of nodes with value equal to startValue 529 | * @return An FQuery instance, limited to data with value greater than or equal to startValue 530 | */ 531 | - (FQuery *) queryStartingAtValue:(id)startValue childKey:(NSString *)childKey; 532 | 533 | /** 534 | * queryEndingAtValue: is used to generate a reference to a limited view of the data at this location. 535 | * The FQuery instance returned by queryEndingAtValue: will respond to events at nodes with a value 536 | * less than or equal to endValue. 537 | * 538 | * @param endValue The upper bound, inclusive, for the value of data visible to the returned FQuery 539 | * @return An FQuery instance, limited to data with value less than or equal to endValue 540 | */ 541 | - (FQuery *) queryEndingAtValue:(id)endValue; 542 | 543 | /** 544 | * queryEndingAtValue:childKey: is used to generate a reference to a limited view of the data at this location. 545 | * The FQuery instance returned by queryEndingAtValue:childKey will respond to events at nodes with a value 546 | * less than endValue, or equal to endValue and with a key less than or equal to childKey. 547 | * 548 | * @param endValue The upper bound, inclusive, for the value of data visible to the returned FQuery 549 | * @param childKey The upper bound, inclusive, for the key of nodes with value equal to endValue 550 | * @return An FQuery instance, limited to data with value less than or equal to endValue 551 | */ 552 | - (FQuery *) queryEndingAtValue:(id)endValue childKey:(NSString *)childKey; 553 | 554 | /** 555 | * queryEqualToValue: is used to generate a reference to a limited view of the data at this location. 556 | * The FQuery instance returned by queryEqualToValue: will respond to events at nodes with a value equal 557 | * to the supplied argument. 558 | * 559 | * @param value The value that the data returned by this FQuery will have 560 | * @return An Fquery instance, limited to data with the supplied value. 561 | */ 562 | - (FQuery *) queryEqualToValue:(id)value; 563 | 564 | /** 565 | * queryEqualToValue:childKey: is used to generate a reference to a limited view of the data at this location. 566 | * The FQuery instance returned by queryEqualToValue:childKey will respond to events at nodes with a value 567 | * equal to the supplied argument with a key equal to childKey. There will be at most one node that matches because 568 | * child keys are unique. 569 | * 570 | * @param value The value that the data returned by this FQuery will have 571 | * @param childKey The key of nodes with the right value 572 | * @return An FQuery instance, limited to data with the supplied value and the key. 573 | */ 574 | - (FQuery *) queryEqualToValue:(id)value childKey:(NSString *)childKey; 575 | 576 | /** @name Managing presence */ 577 | 578 | /** 579 | * Ensure the data at this location is set to the specified value when 580 | * the client is disconnected (due to closing the browser, navigating 581 | * to a new page, or network issues). 582 | * 583 | * onDisconnectSetValue: is especially useful for implementing "presence" systems, 584 | * where a value should be changed or cleared when a user disconnects 585 | * so that he appears "offline" to other users. 586 | * 587 | * @param value The value to be set after the connection is lost. 588 | */ 589 | - (void) onDisconnectSetValue:(id)value; 590 | 591 | 592 | /** 593 | * Ensure the data at this location is set to the specified value when 594 | * the client is disconnected (due to closing the browser, navigating 595 | * to a new page, or network issues). 596 | * 597 | * The completion block will be triggered when the operation has been successfully queued up on the Firebase servers 598 | * 599 | * @param value The value to be set after the connection is lost. 600 | * @param block Block to be triggered when the operation has been queued up on the Firebase servers 601 | */ 602 | - (void) onDisconnectSetValue:(id)value withCompletionBlock:(void (^)(NSError* error, Firebase* ref))block; 603 | 604 | 605 | /** 606 | * Ensure the data at this location is set to the specified value and priority when 607 | * the client is disconnected (due to closing the browser, navigating 608 | * to a new page, or network issues). 609 | * 610 | * @param value The value to be set after the connection is lost. 611 | * @param priority The priority to be set after the connection is lost. 612 | */ 613 | - (void) onDisconnectSetValue:(id)value andPriority:(id)priority; 614 | 615 | 616 | /** 617 | * Ensure the data at this location is set to the specified value and priority when 618 | * the client is disconnected (due to closing the browser, navigating 619 | * to a new page, or network issues). 620 | * 621 | * The completion block will be triggered when the operation has been successfully queued up on the Firebase servers 622 | * 623 | * @param value The value to be set after the connection is lost. 624 | * @param priority The priority to be set after the connection is lost. 625 | * @param block Block to be triggered when the operation has been queued up on the Firebase servers 626 | */ 627 | - (void) onDisconnectSetValue:(id)value andPriority:(id)priority withCompletionBlock:(void (^)(NSError* error, Firebase* ref))block; 628 | 629 | 630 | /** 631 | * Ensure the data at this location is removed when 632 | * the client is disconnected (due to closing the app, navigating 633 | * to a new page, or network issues). 634 | * 635 | * onDisconnectRemoveValue is especially useful for implementing "presence" systems. 636 | */ 637 | - (void) onDisconnectRemoveValue; 638 | 639 | 640 | /** 641 | * Ensure the data at this location is removed when 642 | * the client is disconnected (due to closing the app, navigating 643 | * to a new page, or network issues). 644 | * 645 | * onDisconnectRemoveValueWithCompletionBlock: is especially useful for implementing "presence" systems. 646 | * 647 | * @param block Block to be triggered when the operation has been queued up on the Firebase servers 648 | */ 649 | - (void) onDisconnectRemoveValueWithCompletionBlock:(void (^)(NSError* error, Firebase* ref))block; 650 | 651 | 652 | 653 | /** 654 | * Ensure the data has the specified child values updated when 655 | * the client is disconnected (due to closing the browser, navigating 656 | * to a new page, or network issues). 657 | * 658 | * 659 | * @param values A dictionary of child node keys and the values to set them to after the connection is lost. 660 | */ 661 | - (void) onDisconnectUpdateChildValues:(NSDictionary *)values; 662 | 663 | 664 | /** 665 | * Ensure the data has the specified child values updated when 666 | * the client is disconnected (due to closing the browser, navigating 667 | * to a new page, or network issues). 668 | * 669 | * 670 | * @param values A dictionary of child node keys and the values to set them to after the connection is lost. 671 | * @param block A block that will be called once the operation has been queued up on the Firebase servers 672 | */ 673 | - (void) onDisconnectUpdateChildValues:(NSDictionary *)values withCompletionBlock:(void (^)(NSError* error, Firebase* ref))block; 674 | 675 | 676 | /** 677 | * Cancel any operations that are set to run on disconnect. If you previously called onDisconnectSetValue:, 678 | * onDisconnectRemoveValue:, or onDisconnectUpdateChildValues:, and no longer want the values updated when the 679 | * connection is lost, call cancelDisconnectOperations: 680 | */ 681 | - (void) cancelDisconnectOperations; 682 | 683 | 684 | /** 685 | * Cancel any operations that are set to run on disconnect. If you previously called onDisconnectSetValue:, 686 | * onDisconnectRemoveValue:, or onDisconnectUpdateChildValues:, and no longer want the values updated when the 687 | * connection is lost, call cancelDisconnectOperations: 688 | * 689 | * @param block A block that will be triggered once the Firebase servers have acknowledged the cancel request. 690 | */ 691 | - (void) cancelDisconnectOperationsWithCompletionBlock:(void (^)(NSError* error, Firebase* ref))block; 692 | 693 | 694 | /** @name Reading and observing authentication data */ 695 | 696 | /** 697 | * Get the authentication data of the current user. 698 | * 699 | * @return Authentication data of the current user. 700 | */ 701 | @property (nonatomic, strong, readonly) FAuthData *authData; 702 | 703 | 704 | /** 705 | * Observer block will be triggered whenever a user gets authenticated or logged out. 706 | * 707 | * Authentication data is persisted across app restarts. If your have an old authentication, Firebase will attempt to 708 | * resume your old session. This approach does not wait for a server roundtrip. Rather, it inspects the 709 | * contents of the persisted JWT and assumes that the Firebase secret used to generate the token has not been revoked. 710 | * 711 | * In the event that the Firebase secret used to generate the token has been revoked, observers will likely see one 712 | * flicker / rapid flip-flop of authentication state once the server rejects the token. 713 | * 714 | * Use removeAuthEventObserverWithHandle: to stop receiving updates. 715 | * 716 | * @param block The block that should be called with initial authentication data and future updates 717 | * @return A handle used to unregister this block later with removeAuthEventObserverWithHandle: 718 | */ 719 | - (FirebaseHandle) observeAuthEventWithBlock:(void (^)(FAuthData *authData))block; 720 | 721 | 722 | /** 723 | * Detach a block previously attached with observeAuthEventWithBlock:. 724 | * 725 | * @param handle The handle returned by the call to observeAuthEventWithBlock: which we are trying to remove. 726 | */ 727 | - (void) removeAuthEventObserverWithHandle:(FirebaseHandle)handle; 728 | 729 | /** @name User creation and modification */ 730 | 731 | /** 732 | * Used to create a new user account with the given email and password combo. The results will be passed to the given block. 733 | * Note that this method will not log the new user in. 734 | * 735 | * @param email The email for the account to be created 736 | * @param password The password for the account to be created 737 | * @param block The block to be called with the results of the operation 738 | */ 739 | - (void) createUser:(NSString *)email password:(NSString *)password withCompletionBlock:(void (^)(NSError *error))block; 740 | 741 | /** 742 | * Used to create a new user account with the given email and password combo. The results will be passed 743 | * to the given block. Note that this method will not log the new user in. On success, invokes the result 744 | * block with an dictionary of user data, including the user id. 745 | * 746 | * @param email The email for the account to be created 747 | * @param password The password for the account to be created 748 | * @param block The block to be called with the results of the operation 749 | */ 750 | - (void) createUser:(NSString *)email password:(NSString *)password withValueCompletionBlock:(void (^)(NSError *error, NSDictionary *result))block; 751 | 752 | /** 753 | * Remove a user account with the given email and password. 754 | * 755 | * @param email The email of the account to be removed 756 | * @param password The password for the account to be removed 757 | * @param block A block to receive the results of the operation 758 | */ 759 | - (void) removeUser:(NSString *)email password:(NSString *)password withCompletionBlock:(void (^)(NSError *error))block; 760 | 761 | 762 | /** 763 | * Attempts to change the password for the account with the given credentials to the new password given. Results are reported to the supplied block. 764 | * 765 | * @param email The email for the account to be changed 766 | * @param oldPassword The old password for the account to be changed 767 | * @param newPassword The desired newPassword for the account 768 | * @param block A block to receive the results of the operation 769 | */ 770 | - (void) changePasswordForUser:(NSString *)email fromOld:(NSString *)oldPassword toNew:(NSString *)newPassword withCompletionBlock:(void (^)(NSError *error))block; 771 | 772 | 773 | /** 774 | * Attempts to change the email for the account with the given credentials to the new email given. Results are reported to the supplied block. 775 | * 776 | * @param email The email for the account to be changed 777 | * @param password The password for the account to be changed 778 | * @param newEmail The desired newEmail for the account 779 | * @param block A block to receive the results of the operation 780 | */ 781 | - (void) changeEmailForUser:(NSString *)email password:(NSString *)password toNewEmail:(NSString *)newEmail withCompletionBlock:(void (^)(NSError *error))block; 782 | 783 | 784 | /** 785 | * Send a password reset email to the owner of the account with the given email. Results are reported to the supplied block. 786 | * 787 | * @param email The email of the account to be removed 788 | * @param block A block to receive the results of the operation 789 | */ 790 | - (void) resetPasswordForUser:(NSString *)email withCompletionBlock:(void (^)(NSError* error))block; 791 | 792 | /** @name Authenticating */ 793 | 794 | /** 795 | * Attempts to log the user in anonymously. The block will receive the results of the attempt. 796 | * 797 | * @param block A block to receive the results of the authentication attempt. 798 | */ 799 | - (void) authAnonymouslyWithCompletionBlock:(void (^)(NSError *error, FAuthData *authData))block; 800 | 801 | /** 802 | * Attempts to authenticate to Firebase with the given credentials. The block will receive the results of the attempt. 803 | * 804 | * @param email The email of the account 805 | * @param password The password for the account 806 | * @param block A block to receive the results of the authentication attempt 807 | */ 808 | - (void) authUser:(NSString *)email password:(NSString *)password withCompletionBlock:(void (^)(NSError *error, FAuthData *authData))block; 809 | 810 | /** 811 | * Authenticate access to this Firebase using the provided credentials. 812 | * 813 | * The completion block will be called with the results of the authenticated attempt. Unlike 814 | * authWithCredential:withCompletionBlock:withCancelBlock:, no block will be called when the credentials become invalid. 815 | * 816 | * Instead, please use observeAuthEventWithBlock: to observe if a user gets logged out. 817 | * 818 | * @param token The Firebase authentication JWT generated by a secure code on a remote server. 819 | * @param block This block will be called with the results of the authentication attempt 820 | */ 821 | - (void) authWithCustomToken:(NSString *)token withCompletionBlock:(void (^)(NSError *error, FAuthData *authData))block; 822 | 823 | /** 824 | * Authenticate to Firebase with an OAuth token from a provider. 825 | * 826 | * This method works with current OAuth 2.0 providers such as Facebook, Google+, and Github. 827 | * 828 | * For other providers that Firebase supports which require additional parameters for login, such as Twitter, please use authWithOAuthProvider:parameters:withCompletionBlock:. 829 | * 830 | * @param provider The provider, all lower case with no spaces. 831 | * @param oauthToken The OAuth Token to authenticate with the provider 832 | * @param block A block to receive the results of the authentication attempt 833 | */ 834 | - (void) authWithOAuthProvider:(NSString *)provider token:(NSString *)oauthToken withCompletionBlock:(void (^) (NSError *error, FAuthData *authData))block; 835 | 836 | /** 837 | * Authenticate to Firebase with an OAuth token from a provider. 838 | * 839 | * This method is for OAuth providers that require extra parameters when authentication with the server, such as Twitter. 840 | * The OAuth token should be included as a parameter. 841 | * 842 | * @param provider The provider, all lowercase with no spaces. 843 | * @param parameters The parameters necessary to authenticate with the provider 844 | * @param block A block to receive the results of the authentication attempt 845 | */ 846 | - (void) authWithOAuthProvider:(NSString *)provider parameters:(NSDictionary *)parameters withCompletionBlock:(void (^) (NSError *error, FAuthData *authData))block; 847 | 848 | /** 849 | * Make a reverse OAuth Request to a provider. 850 | * 851 | * This method is for OAuth providers that require a reverse request be made first. The json output of this block 852 | * 853 | * @param provider The provider, all lowercase with no spaces. 854 | * @param block The block to receive the results of the reverse OAuth request. 855 | */ 856 | - (void) makeReverseOAuthRequestTo:(NSString *)provider withCompletionBlock:(void (^)(NSError *error, NSDictionary *json))block; 857 | 858 | /** 859 | * Removes any credentials associated with this Firebase. 860 | */ 861 | - (void) unauth; 862 | 863 | /** 864 | * This method is deprecated. Use authWithCustomToken:withCompletionBlock: instead. 865 | * 866 | * Authenticate access to this Firebase using the provided credentials. The completion block will be called with 867 | * the results of the authenticated attempt, and the cancelBlock will be called if the credentials become invalid 868 | * at some point after authentication has succeeded. 869 | * 870 | * @param credential The Firebase authentication JWT generated by a secure code on a remote server. 871 | * @param block This block will be called with the results of the authentication attempt 872 | * @param cancelBlock This block will be called if at any time in the future the credentials become invalid 873 | */ 874 | - (void) authWithCredential:(NSString *)credential withCompletionBlock:(void (^) (NSError* error, id data))block withCancelBlock:(void (^)(NSError* error))cancelBlock __attribute__((deprecated("Use authWithCustomToken:withCompletionblock: instead"))); 875 | 876 | /** 877 | * This method is deprecated. Use unauth: instead. 878 | * 879 | * Removes any credentials associated with this Firebase. The callback block will be triggered after this operation 880 | * has been acknowledged by the Firebase servers. 881 | * 882 | * @param block This block will be called once the unauth has completed. 883 | */ 884 | - (void) unauthWithCompletionBlock:(void (^)(NSError* error))block __attribute__((deprecated("Use unauth: instead"))); 885 | 886 | 887 | /** @name Manual Connection Management */ 888 | 889 | /** 890 | * Manually disconnect the Firebase client from the server and disable automatic reconnection. 891 | * 892 | * The Firebase client automatically maintains a persistent connection to the Firebase server, 893 | * which will remain active indefinitely and reconnect when disconnected. However, the goOffline( ) 894 | * and goOnline( ) methods may be used to manually control the client connection in cases where 895 | * a persistent connection is undesirable. 896 | * 897 | * While offline, the Firebase client will no longer receive data updates from the server. However, 898 | * all Firebase operations performed locally will continue to immediately fire events, allowing 899 | * your application to continue behaving normally. Additionally, each operation performed locally 900 | * will automatically be queued and retried upon reconnection to the Firebase server. 901 | * 902 | * To reconnect to the Firebase server and begin receiving remote events, see goOnline( ). 903 | * Once the connection is reestablished, the Firebase client will transmit the appropriate data 904 | * and fire the appropriate events so that your client "catches up" automatically. 905 | * 906 | * Note: Invoking this method will impact all Firebase connections. 907 | */ 908 | + (void) goOffline; 909 | 910 | /** 911 | * Manually reestablish a connection to the Firebase server and enable automatic reconnection. 912 | * 913 | * The Firebase client automatically maintains a persistent connection to the Firebase server, 914 | * which will remain active indefinitely and reconnect when disconnected. However, the goOffline( ) 915 | * and goOnline( ) methods may be used to manually control the client connection in cases where 916 | * a persistent connection is undesirable. 917 | * 918 | * This method should be used after invoking goOffline( ) to disable the active connection. 919 | * Once reconnected, the Firebase client will automatically transmit the proper data and fire 920 | * the appropriate events so that your client "catches up" automatically. 921 | * 922 | * To disconnect from the Firebase server, see goOffline( ). 923 | * 924 | * Note: Invoking this method will impact all Firebase connections. 925 | */ 926 | + (void) goOnline; 927 | 928 | 929 | /** @name Transactions */ 930 | 931 | /** 932 | * Performs an optimistic-concurrency transactional update to the data at this location. Your block will be called with an FMutableData 933 | * instance that contains the current data at this location. Your block should update this data to the value you 934 | * wish to write to this location, and then return an instance of FTransactionResult with the new data. 935 | * 936 | * If, when the operation reaches the server, it turns out that this client had stale data, your block will be run 937 | * again with the latest data from the server. 938 | * 939 | * When your block is run, you may decide to abort the transaction by return [FTransactionResult abort]. 940 | * 941 | * @param block This block receives the current data at this location and must return an instance of FTransactionResult 942 | */ 943 | - (void) runTransactionBlock:(FTransactionResult* (^) (FMutableData* currentData))block; 944 | 945 | 946 | /** 947 | * Performs an optimistic-concurrency transactional update to the data at this location. Your block will be called with an FMutableData 948 | * instance that contains the current data at this location. Your block should update this data to the value you 949 | * wish to write to this location, and then return an instance of FTransactionResult with the new data. 950 | * 951 | * If, when the operation reaches the server, it turns out that this client had stale data, your block will be run 952 | * again with the latest data from the server. 953 | * 954 | * When your block is run, you may decide to abort the transaction by return [FTransactionResult abort]. 955 | * 956 | * @param block This block receives the current data at this location and must return an instance of FTransactionResult 957 | * @param completionBlock This block will be triggered once the transaction is complete, whether it was successful or not. It will indicate if there was an error, whether or not the data was committed, and what the current value of the data at this location is. 958 | */ 959 | - (void) runTransactionBlock:(FTransactionResult* (^) (FMutableData* currentData))block andCompletionBlock:(void (^) (NSError* error, BOOL committed, FDataSnapshot* snapshot))completionBlock; 960 | 961 | 962 | 963 | /** 964 | * Performs an optimistic-concurrency transactional update to the data at this location. Your block will be called with an FMutableData 965 | * instance that contains the current data at this location. Your block should update this data to the value you 966 | * wish to write to this location, and then return an instance of FTransactionResult with the new data. 967 | * 968 | * If, when the operation reaches the server, it turns out that this client had stale data, your block will be run 969 | * again with the latest data from the server. 970 | * 971 | * When your block is run, you may decide to abort the transaction by return [FTransactionResult abort]. 972 | * 973 | * Since your block may be run multiple times, this client could see several immediate states that don't exist on the server. You can suppress those immediate states until the server confirms the final state of the transaction. 974 | * 975 | * @param block This block receives the current data at this location and must return an instance of FTransactionResult 976 | * @param completionBlock This block will be triggered once the transaction is complete, whether it was successful or not. It will indicate if there was an error, whether or not the data was committed, and what the current value of the data at this location is. 977 | * @param localEvents Set this to NO to suppress events raised for intermediate states, and only get events based on the final state of the transaction. 978 | */ 979 | - (void) runTransactionBlock:(FTransactionResult* (^) (FMutableData* currentData))block andCompletionBlock:(void (^) (NSError* error, BOOL committed, FDataSnapshot* snapshot))completionBlock withLocalEvents:(BOOL)localEvents; 980 | 981 | 982 | /** @name Retrieving String Representation */ 983 | 984 | /** 985 | * Gets the absolute URL of this Firebase location. 986 | * 987 | * @return The absolute URL of the referenced Firebase location. 988 | */ 989 | - (NSString *) description; 990 | 991 | /** @name Properties */ 992 | 993 | /** 994 | * Get a Firebase reference for the parent location. 995 | * If this instance refers to the root of your Firebase, it has no parent, 996 | * and therefore parent( ) will return null. 997 | * 998 | * @return A Firebase reference for the parent location. 999 | */ 1000 | @property (strong, readonly, nonatomic) Firebase* parent; 1001 | 1002 | 1003 | /** 1004 | * Get a Firebase reference for the root location 1005 | * 1006 | * @return A new Firebase reference to root location. 1007 | */ 1008 | @property (strong, readonly, nonatomic) Firebase* root; 1009 | 1010 | 1011 | /** 1012 | * Gets last token in a Firebase location (e.g. 'fred' in https://SampleChat.firebaseIO-demo.com/users/fred) 1013 | * 1014 | * @return The key of the location this reference points to. 1015 | */ 1016 | @property (strong, readonly, nonatomic) NSString* key; 1017 | 1018 | /** 1019 | * Gets the FirebaseApp instance associated with this reference. 1020 | * 1021 | * @return The FirebaseApp object for this reference. 1022 | */ 1023 | @property (strong, readonly, nonatomic) FirebaseApp *app; 1024 | 1025 | 1026 | /** @name Global configuration and settings */ 1027 | 1028 | /** Set the default dispatch queue for event blocks. 1029 | * 1030 | * @param queue The queue to set as the default for running blocks for all Firebase event types. 1031 | * @deprecated This method is deprecated 1032 | * @note Please use [Firebase defaultConfig].callbackQueue instead 1033 | */ 1034 | + (void) setDispatchQueue:(dispatch_queue_t)queue __attribute__((deprecated)); 1035 | 1036 | /** Retrieve the Firebase SDK version. */ 1037 | + (NSString *) sdkVersion; 1038 | 1039 | + (void) setLoggingEnabled:(BOOL)enabled; 1040 | 1041 | /** 1042 | * Returns the default config object, used for configuring Firebase client behavior. 1043 | * 1044 | * This can be modified until you create your first `Firebase` instance. 1045 | */ 1046 | + (FConfig *)defaultConfig; 1047 | 1048 | /** 1049 | * @deprecated This method is deprecated 1050 | * @note Please enable persistence by setting [Firebase defaultConfig].persistenceEnabled = YES instead. 1051 | * @param option Option to set. 1052 | * @param value Value to set. 1053 | */ 1054 | + (void) setOption:(NSString*)option to:(id)value __attribute__((deprecated)); 1055 | @end 1056 | -------------------------------------------------------------------------------- /Firebase.framework/Headers/FirebaseApp.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | /** 4 | * All Firebase references to the same database share a connection, persistent cache, etc. FirebaseApp 5 | * represents this shared state and can be accessed from any reference via its `app` property. 6 | * It has methods for managing your Firebase connection, etc. 7 | * 8 | * There is a one-to-one relationship between a FirebaseApp instance and a connection to Firebase. 9 | */ 10 | @interface FirebaseApp : NSObject 11 | 12 | /** 13 | * The Firebase client automatically queues writes and sends them to the server at the earliest opportunity, 14 | * depending on network connectivity. In some cases (e.g. offline usage) there may be a large number of writes 15 | * waiting to be sent. Calling this method will purge all outstanding writes so they are abandoned. 16 | * 17 | * All writes will be purged, including transactions and {@link Firebase#onDisconnect} writes. The writes will 18 | * be rolled back locally, perhaps triggering events for affected event listeners, and the client will not 19 | * (re-)send them to the Firebase backend. 20 | */ 21 | - (void)purgeOutstandingWrites; 22 | 23 | 24 | /** 25 | * Shuts down our connection to the Firebase backend until goOnline is called. 26 | */ 27 | - (void)goOffline; 28 | 29 | /** 30 | * Resumes our connection to the Firebase backend after a previous goOffline call. 31 | */ 32 | - (void)goOnline; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /Firebase.framework/Headers/FirebaseServerValue.h: -------------------------------------------------------------------------------- 1 | @interface FirebaseServerValue : NSObject 2 | 3 | + (NSDictionary *) timestamp; 4 | 5 | @end -------------------------------------------------------------------------------- /Firebase.framework/Info.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/holmesal/react-native-firebase/37ed6cb77efd65276fc92ebf6890ddd02cb4fb3b/Firebase.framework/Info.plist -------------------------------------------------------------------------------- /Firebase.framework/Modules/module.modulemap: -------------------------------------------------------------------------------- 1 | framework module Firebase { 2 | umbrella header "Firebase.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Firebase.framework/NOTICE: -------------------------------------------------------------------------------- 1 | Google LevelDB 2 | Copyright (c) 2011 The LevelDB Authors. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | 8 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 9 | 10 | * Neither the name of Google Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 11 | 12 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 13 | 14 | -- 15 | 16 | Square Socket Rocket 17 | Copyright 2012 Square Inc. 18 | 19 | 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 20 | 21 | http://www.apache.org/licenses/LICENSE-2.0 22 | 23 | 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. 24 | 25 | -- 26 | 27 | APLevelDB 28 | Created by Adam Preble on 1/23/12. 29 | Copyright (c) 2012 Adam Preble. All rights reserved. 30 | 31 | Permission is hereby granted, free of charge, to any person obtaining a copy 32 | of this software and associated documentation files (the "Software"), to deal 33 | in the Software without restriction, including without limitation the rights 34 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 35 | copies of the Software, and to permit persons to whom the Software is 36 | furnished to do so, subject to the following conditions: 37 | 38 | The above copyright notice and this permission notice shall be included in 39 | all copies or substantial portions of the Software. 40 | 41 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 42 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 43 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 44 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 45 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 46 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 47 | THE SOFTWARE. 48 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RNFirebase 2 | 3 | # wip - use cautiously 4 | 5 | ## Why? 6 | 7 | Because the native iOS Firebase SDK rocks - it's got great [offline capabilities & caching](https://www.firebase.com/docs/ios/guide/offline-capabilities.html), and [SimpleLogin](https://www.firebase.com/docs/ios/guide/user-auth.html) works much better on native devices than in the JS SDK. 8 | 9 | ## Goal 10 | 11 | Provide an API that mirrors Firebase's [JS SDK](https://www.firebase.com/docs/web/api/), but map the important bits to the native SDK. 12 | 13 | I'd like to continue to use Firebase references on the JS side (to avoid re-implementing methods like `.root(), .key(), etc`, and override only methods like `.on()` and `.off()`. 14 | 15 | ## How it works 16 | 17 | Subclass `Firebase` in JS, and in the constructor have the native SDK create a "mirror" reference. Anytime you call a method on the JS reference, RNFirebase will call the appropriate method on the "mirror" reference. 18 | 19 | Similarly, when data is available on the native side, an event is emitted over the bridge with the (always serializable) data. This event is caught by the JS SDK, which then fires the callback you registered with "on". This callback is provided with an object that conforms to the `DataSnapshot` API, though I'm planning only to implement the basic `DataSnapshot` methods at first. `.val()` is the important one, of course. 20 | 21 | When you call `.off()`, the corresponding reference is destroyed using the native SDK. 22 | 23 | ## JS -> iOS mappings 24 | 25 | | JS method | iOS method | 26 | | ------------- | ------------- | 27 | | .on() | observeEventType:withBlock: | 28 | 29 | When you call `new Firebase()` in javascript-land, a normal `Firebase` reference is created. Nothing happens, though, until you call a method to set or fetch data from firebase: `.on(), .update(), .set(), .remove(), (add the rest)`. 30 | 31 | ## Good first tasks 32 | (link to issues here) 33 | * Add unit tests to ensure parity with the official react JS lib 34 | -------------------------------------------------------------------------------- /RNFirebase.js: -------------------------------------------------------------------------------- 1 | require('console-shim'); 2 | var Firebase = require('firebase'); 3 | var React = require('react-native'); 4 | var FirebaseDataSnapshot = require('./RNFirebaseDataSnapshot') 5 | var FirebaseQuery = require('./RNFirebaseQuery') 6 | var {RNFirebase} = React.NativeModules; 7 | var {NativeAppEventEmitter} = React; 8 | 9 | class FirebaseRef extends Firebase { 10 | 11 | constructor(path) { 12 | // console.debug('new instance created: ', path) 13 | // Create a firebase reference, to be returned 14 | super(path); 15 | this._ref = new Firebase(path); 16 | 17 | // Calling query methods should create a new FirebaseQuery 18 | // and invoke the query method on it 19 | let queryMethods = ['orderByChild', 'orderByKey', 'orderByValue', 'orderByPriority', 'startAt', 'endAt', 'equalTo', 'limitToFirst', 'limitToLast', 'limit']; 20 | queryMethods.map((method) => { 21 | this[method] = function() { 22 | let q = new FirebaseQuery(this); 23 | q[method].apply(q, arguments); 24 | return q; 25 | } 26 | }); 27 | 28 | return this; 29 | } 30 | 31 | child(path) { 32 | // console.info('child path: ', path); 33 | let newRef = this._ref.child(path); 34 | // console.info('new ref: ', newRef.toString()); 35 | return new FirebaseRef(newRef.toString()); 36 | } 37 | 38 | /** 39 | * Methods specific to this implementation, not direct ports of firebase methods 40 | */ 41 | 42 | // Given an event string type, get the event key for use over the bridge 43 | getEventKey(event) { 44 | return `RNFirebase-${this.toString()}-${event}`; 45 | } 46 | 47 | // Given some data passed over the bridge, create a data snapshot and call the registered callback 48 | handleEvent(ev, ref, callback) { 49 | // console.debug('got event', ev); 50 | let snap = new FirebaseDataSnapshot(ev.data, ref); 51 | callback(snap); 52 | } 53 | 54 | // Mention that the method called is not implemented 55 | notImplemented() { 56 | console.error(`[RNFirebase] ${arguments.callee.caller.name} is not implemented :-(`); 57 | } 58 | 59 | /** 60 | * Firebase API methods 61 | */ 62 | on(eventType, callback) { 63 | // console.info(this.toString(), eventType); 64 | // Listen to this location 65 | RNFirebase.on(this.toString(), eventType); 66 | // Listen for events emitted on this ref 67 | NativeAppEventEmitter.addListener(this.getEventKey(eventType), (ev) => { 68 | // If this data has a different key, then we're dealing with a child 69 | if (ev.key === "") { 70 | ev.key = null; 71 | } 72 | if (ev.key !== this.key()) { 73 | var ref = this.child(ev.key); 74 | } else { 75 | var ref = this; 76 | } 77 | this.handleEvent(ev, ref, callback); 78 | }); 79 | } 80 | 81 | off(eventType, callback, context) { 82 | if (eventType || callback || context) { 83 | console.warn('[RNFirebase] You seem to be calling .off() with an eventType or a callback, which is currently unsupported. For this call, all listeners will be removed from this ref.') 84 | } 85 | RNFirebase.off(this.toString()); 86 | NativeAppEventEmitter.removeAllListeners(this.getEventKey(eventType)); 87 | } 88 | 89 | set(value, onComplete) { 90 | RNFirebase.set(this.toString(), value, onComplete); 91 | } 92 | 93 | update(value, onComplete) { 94 | RNFirebase.update(this.toString(), value, onComplete); 95 | } 96 | 97 | push(value) { 98 | // Create the child path using the js sdk 99 | let childPath = this._ref.push().toString() 100 | // Create a new instance of yourself with this path 101 | let childRef = new FirebaseRef(childPath) 102 | // If data was passed, immediately set it 103 | if (value) { 104 | childRef.set(value); 105 | } 106 | return childRef 107 | // this.notImplemented() 108 | // RNFirebase.push(this.toString(), value, onComplete) 109 | } 110 | 111 | ref() { 112 | return this; 113 | } 114 | 115 | keepSynced(shouldSync) { 116 | RNFirebase.keepSynced(this.toString(), shouldSync); 117 | } 118 | 119 | 120 | 121 | // Authentication 122 | 123 | getAuth(callback) { 124 | RNFirebase.getAuth(this.toString(), callback); 125 | } 126 | 127 | onAuth(callback) { 128 | NativeAppEventEmitter.addListener(this.getEventKey('auth'), (ev) => { 129 | callback(ev.err, ev.authData); 130 | }); 131 | // Force an auth check right away 132 | RNFirebase.getAuth(this.toString(), ()=>{}); 133 | } 134 | 135 | offAuth(callback, context) { 136 | if (callback || context) { 137 | console.warn('[RNFirebase] You seem to be calling .offAuth() with an eventType or a callback, which is currently unsupported. For this call, all listeners will be removed from the auth event.') 138 | } 139 | NativeAppEventEmitter.removeAllListeners(this.getEventKey('auth')); 140 | } 141 | 142 | unauth() { 143 | RNFirebase.unauth(this.toString()); 144 | } 145 | 146 | authWithFacebook(callback) { 147 | RNFirebase.authWithFacebook(this.toString(), callback); 148 | } 149 | 150 | 151 | // These methods need some love 152 | auth() { 153 | this.notImplemented() 154 | } 155 | 156 | parent() { 157 | this.notImplemented() 158 | } 159 | 160 | root() { 161 | this.notImplemented() 162 | } 163 | 164 | name() { 165 | this.notImplemented() 166 | } 167 | 168 | remove() { 169 | this.notImplemented() 170 | } 171 | 172 | setWithPriority() { 173 | this.notImplemented() 174 | } 175 | 176 | setPriority() { 177 | this.notImplemented() 178 | } 179 | 180 | transaction() { 181 | this.notImplemented() 182 | } 183 | } 184 | 185 | module.exports = FirebaseRef; -------------------------------------------------------------------------------- /RNFirebase.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | E26E29FA1BBE54B800BF9CD9 /* RNFirebase.h in Headers */ = {isa = PBXBuildFile; fileRef = E26E29F91BBE54B800BF9CD9 /* RNFirebase.h */; settings = {ATTRIBUTES = (Public, ); }; }; 11 | E26E2A131BBE54F600BF9CD9 /* RNFirebase.swift in Sources */ = {isa = PBXBuildFile; fileRef = E26E2A101BBE54F600BF9CD9 /* RNFirebase.swift */; }; 12 | E26E2A141BBE54F600BF9CD9 /* RNFirebase.m in Sources */ = {isa = PBXBuildFile; fileRef = E26E2A111BBE54F600BF9CD9 /* RNFirebase.m */; }; 13 | E26E2A151BBE54F600BF9CD9 /* RNFirebase-Bridging-Header.h in Headers */ = {isa = PBXBuildFile; fileRef = E26E2A121BBE54F600BF9CD9 /* RNFirebase-Bridging-Header.h */; }; 14 | E26E2A601BBE592700BF9CD9 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E26E2A5F1BBE592700BF9CD9 /* libReact.a */; }; 15 | /* End PBXBuildFile section */ 16 | 17 | /* Begin PBXFileReference section */ 18 | E26E29F41BBE54B800BF9CD9 /* RNFirebase.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = RNFirebase.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 19 | E26E29F81BBE54B800BF9CD9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 20 | E26E29F91BBE54B800BF9CD9 /* RNFirebase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNFirebase.h; sourceTree = ""; }; 21 | E26E2A051BBE54B800BF9CD9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 22 | E26E2A061BBE54B800BF9CD9 /* RNFirebaseTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RNFirebaseTests.swift; sourceTree = ""; }; 23 | E26E2A101BBE54F600BF9CD9 /* RNFirebase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RNFirebase.swift; sourceTree = ""; }; 24 | E26E2A111BBE54F600BF9CD9 /* RNFirebase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNFirebase.m; sourceTree = ""; }; 25 | E26E2A121BBE54F600BF9CD9 /* RNFirebase-Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "RNFirebase-Bridging-Header.h"; sourceTree = ""; }; 26 | E26E2A5F1BBE592700BF9CD9 /* libReact.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libReact.a; path = "../../../../Library/Developer/Xcode/DerivedData/podcastfooMobile-boqeypfpxrvhkkewzjtydjhihgdb/Build/Products/Debug-iphoneos/libReact.a"; sourceTree = ""; }; 27 | /* End PBXFileReference section */ 28 | 29 | /* Begin PBXFrameworksBuildPhase section */ 30 | E26E29F01BBE54B800BF9CD9 /* Frameworks */ = { 31 | isa = PBXFrameworksBuildPhase; 32 | buildActionMask = 2147483647; 33 | files = ( 34 | E26E2A601BBE592700BF9CD9 /* libReact.a in Frameworks */, 35 | ); 36 | runOnlyForDeploymentPostprocessing = 0; 37 | }; 38 | /* End PBXFrameworksBuildPhase section */ 39 | 40 | /* Begin PBXGroup section */ 41 | E26E29EA1BBE54B800BF9CD9 = { 42 | isa = PBXGroup; 43 | children = ( 44 | E26E2A5F1BBE592700BF9CD9 /* libReact.a */, 45 | E26E29F61BBE54B800BF9CD9 /* RNFirebase */, 46 | E26E2A031BBE54B800BF9CD9 /* RNFirebaseTests */, 47 | E26E29F51BBE54B800BF9CD9 /* Products */, 48 | ); 49 | sourceTree = ""; 50 | }; 51 | E26E29F51BBE54B800BF9CD9 /* Products */ = { 52 | isa = PBXGroup; 53 | children = ( 54 | E26E29F41BBE54B800BF9CD9 /* RNFirebase.framework */, 55 | ); 56 | name = Products; 57 | sourceTree = ""; 58 | }; 59 | E26E29F61BBE54B800BF9CD9 /* RNFirebase */ = { 60 | isa = PBXGroup; 61 | children = ( 62 | E26E2A101BBE54F600BF9CD9 /* RNFirebase.swift */, 63 | E26E2A111BBE54F600BF9CD9 /* RNFirebase.m */, 64 | E26E2A121BBE54F600BF9CD9 /* RNFirebase-Bridging-Header.h */, 65 | E26E29F91BBE54B800BF9CD9 /* RNFirebase.h */, 66 | E26E29F71BBE54B800BF9CD9 /* Supporting Files */, 67 | ); 68 | path = RNFirebase; 69 | sourceTree = ""; 70 | }; 71 | E26E29F71BBE54B800BF9CD9 /* Supporting Files */ = { 72 | isa = PBXGroup; 73 | children = ( 74 | E26E29F81BBE54B800BF9CD9 /* Info.plist */, 75 | ); 76 | name = "Supporting Files"; 77 | sourceTree = ""; 78 | }; 79 | E26E2A031BBE54B800BF9CD9 /* RNFirebaseTests */ = { 80 | isa = PBXGroup; 81 | children = ( 82 | E26E2A061BBE54B800BF9CD9 /* RNFirebaseTests.swift */, 83 | E26E2A041BBE54B800BF9CD9 /* Supporting Files */, 84 | ); 85 | path = RNFirebaseTests; 86 | sourceTree = ""; 87 | }; 88 | E26E2A041BBE54B800BF9CD9 /* Supporting Files */ = { 89 | isa = PBXGroup; 90 | children = ( 91 | E26E2A051BBE54B800BF9CD9 /* Info.plist */, 92 | ); 93 | name = "Supporting Files"; 94 | sourceTree = ""; 95 | }; 96 | /* End PBXGroup section */ 97 | 98 | /* Begin PBXHeadersBuildPhase section */ 99 | E26E29F11BBE54B800BF9CD9 /* Headers */ = { 100 | isa = PBXHeadersBuildPhase; 101 | buildActionMask = 2147483647; 102 | files = ( 103 | E26E2A151BBE54F600BF9CD9 /* RNFirebase-Bridging-Header.h in Headers */, 104 | E26E29FA1BBE54B800BF9CD9 /* RNFirebase.h in Headers */, 105 | ); 106 | runOnlyForDeploymentPostprocessing = 0; 107 | }; 108 | /* End PBXHeadersBuildPhase section */ 109 | 110 | /* Begin PBXNativeTarget section */ 111 | E26E29F31BBE54B800BF9CD9 /* RNFirebase */ = { 112 | isa = PBXNativeTarget; 113 | buildConfigurationList = E26E2A0A1BBE54B800BF9CD9 /* Build configuration list for PBXNativeTarget "RNFirebase" */; 114 | buildPhases = ( 115 | E26E29EF1BBE54B800BF9CD9 /* Sources */, 116 | E26E29F01BBE54B800BF9CD9 /* Frameworks */, 117 | E26E29F11BBE54B800BF9CD9 /* Headers */, 118 | E26E29F21BBE54B800BF9CD9 /* Resources */, 119 | ); 120 | buildRules = ( 121 | ); 122 | dependencies = ( 123 | ); 124 | name = RNFirebase; 125 | productName = RNFirebase; 126 | productReference = E26E29F41BBE54B800BF9CD9 /* RNFirebase.framework */; 127 | productType = "com.apple.product-type.framework"; 128 | }; 129 | /* End PBXNativeTarget section */ 130 | 131 | /* Begin PBXProject section */ 132 | E26E29EB1BBE54B800BF9CD9 /* Project object */ = { 133 | isa = PBXProject; 134 | attributes = { 135 | LastUpgradeCheck = 0640; 136 | ORGANIZATIONNAME = "Alonso Holmes"; 137 | TargetAttributes = { 138 | E26E29F31BBE54B800BF9CD9 = { 139 | CreatedOnToolsVersion = 6.4; 140 | }; 141 | }; 142 | }; 143 | buildConfigurationList = E26E29EE1BBE54B800BF9CD9 /* Build configuration list for PBXProject "RNFirebase" */; 144 | compatibilityVersion = "Xcode 3.2"; 145 | developmentRegion = English; 146 | hasScannedForEncodings = 0; 147 | knownRegions = ( 148 | en, 149 | ); 150 | mainGroup = E26E29EA1BBE54B800BF9CD9; 151 | productRefGroup = E26E29F51BBE54B800BF9CD9 /* Products */; 152 | projectDirPath = ""; 153 | projectRoot = ""; 154 | targets = ( 155 | E26E29F31BBE54B800BF9CD9 /* RNFirebase */, 156 | ); 157 | }; 158 | /* End PBXProject section */ 159 | 160 | /* Begin PBXResourcesBuildPhase section */ 161 | E26E29F21BBE54B800BF9CD9 /* Resources */ = { 162 | isa = PBXResourcesBuildPhase; 163 | buildActionMask = 2147483647; 164 | files = ( 165 | ); 166 | runOnlyForDeploymentPostprocessing = 0; 167 | }; 168 | /* End PBXResourcesBuildPhase section */ 169 | 170 | /* Begin PBXSourcesBuildPhase section */ 171 | E26E29EF1BBE54B800BF9CD9 /* Sources */ = { 172 | isa = PBXSourcesBuildPhase; 173 | buildActionMask = 2147483647; 174 | files = ( 175 | E26E2A141BBE54F600BF9CD9 /* RNFirebase.m in Sources */, 176 | E26E2A131BBE54F600BF9CD9 /* RNFirebase.swift in Sources */, 177 | ); 178 | runOnlyForDeploymentPostprocessing = 0; 179 | }; 180 | /* End PBXSourcesBuildPhase section */ 181 | 182 | /* Begin XCBuildConfiguration section */ 183 | E26E2A081BBE54B800BF9CD9 /* Debug */ = { 184 | isa = XCBuildConfiguration; 185 | buildSettings = { 186 | ALWAYS_SEARCH_USER_PATHS = NO; 187 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 188 | CLANG_CXX_LIBRARY = "libc++"; 189 | CLANG_ENABLE_MODULES = YES; 190 | CLANG_ENABLE_OBJC_ARC = YES; 191 | CLANG_WARN_BOOL_CONVERSION = YES; 192 | CLANG_WARN_CONSTANT_CONVERSION = YES; 193 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 194 | CLANG_WARN_EMPTY_BODY = YES; 195 | CLANG_WARN_ENUM_CONVERSION = YES; 196 | CLANG_WARN_INT_CONVERSION = YES; 197 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 198 | CLANG_WARN_UNREACHABLE_CODE = YES; 199 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 200 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 201 | COPY_PHASE_STRIP = NO; 202 | CURRENT_PROJECT_VERSION = 1; 203 | DEAD_CODE_STRIPPING = NO; 204 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 205 | ENABLE_STRICT_OBJC_MSGSEND = YES; 206 | GCC_C_LANGUAGE_STANDARD = gnu99; 207 | GCC_DYNAMIC_NO_PIC = NO; 208 | GCC_NO_COMMON_BLOCKS = YES; 209 | GCC_OPTIMIZATION_LEVEL = 0; 210 | GCC_PREPROCESSOR_DEFINITIONS = ( 211 | "DEBUG=1", 212 | "$(inherited)", 213 | ); 214 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 215 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 216 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 217 | GCC_WARN_UNDECLARED_SELECTOR = YES; 218 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 219 | GCC_WARN_UNUSED_FUNCTION = YES; 220 | GCC_WARN_UNUSED_VARIABLE = YES; 221 | HEADER_SEARCH_PATHS = ( 222 | "$(inherited)", 223 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 224 | "$(SRCROOT)/../react-native/React/**", 225 | "$(SRCROOT)/../../React/**", 226 | "$(SRCROOT)/node_modules/react-native/React/**", 227 | ); 228 | IPHONEOS_DEPLOYMENT_TARGET = 8.4; 229 | MTL_ENABLE_DEBUG_INFO = YES; 230 | ONLY_ACTIVE_ARCH = YES; 231 | SDKROOT = iphoneos; 232 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 233 | TARGETED_DEVICE_FAMILY = "1,2"; 234 | VERSIONING_SYSTEM = "apple-generic"; 235 | VERSION_INFO_PREFIX = ""; 236 | }; 237 | name = Debug; 238 | }; 239 | E26E2A091BBE54B800BF9CD9 /* Release */ = { 240 | isa = XCBuildConfiguration; 241 | buildSettings = { 242 | ALWAYS_SEARCH_USER_PATHS = NO; 243 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 244 | CLANG_CXX_LIBRARY = "libc++"; 245 | CLANG_ENABLE_MODULES = YES; 246 | CLANG_ENABLE_OBJC_ARC = YES; 247 | CLANG_WARN_BOOL_CONVERSION = YES; 248 | CLANG_WARN_CONSTANT_CONVERSION = YES; 249 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 250 | CLANG_WARN_EMPTY_BODY = YES; 251 | CLANG_WARN_ENUM_CONVERSION = YES; 252 | CLANG_WARN_INT_CONVERSION = YES; 253 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 254 | CLANG_WARN_UNREACHABLE_CODE = YES; 255 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 256 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 257 | COPY_PHASE_STRIP = NO; 258 | CURRENT_PROJECT_VERSION = 1; 259 | DEAD_CODE_STRIPPING = NO; 260 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 261 | ENABLE_NS_ASSERTIONS = NO; 262 | ENABLE_STRICT_OBJC_MSGSEND = YES; 263 | GCC_C_LANGUAGE_STANDARD = gnu99; 264 | GCC_NO_COMMON_BLOCKS = YES; 265 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 266 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 267 | GCC_WARN_UNDECLARED_SELECTOR = YES; 268 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 269 | GCC_WARN_UNUSED_FUNCTION = YES; 270 | GCC_WARN_UNUSED_VARIABLE = YES; 271 | HEADER_SEARCH_PATHS = ( 272 | "$(inherited)", 273 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 274 | "$(SRCROOT)/../react-native/React/**", 275 | "$(SRCROOT)/../../React/**", 276 | "$(SRCROOT)/node_modules/react-native/React/**", 277 | ); 278 | IPHONEOS_DEPLOYMENT_TARGET = 8.4; 279 | MTL_ENABLE_DEBUG_INFO = NO; 280 | SDKROOT = iphoneos; 281 | TARGETED_DEVICE_FAMILY = "1,2"; 282 | VALIDATE_PRODUCT = YES; 283 | VERSIONING_SYSTEM = "apple-generic"; 284 | VERSION_INFO_PREFIX = ""; 285 | }; 286 | name = Release; 287 | }; 288 | E26E2A0B1BBE54B800BF9CD9 /* Debug */ = { 289 | isa = XCBuildConfiguration; 290 | buildSettings = { 291 | ALWAYS_SEARCH_USER_PATHS = NO; 292 | DEAD_CODE_STRIPPING = NO; 293 | DEFINES_MODULE = YES; 294 | DYLIB_COMPATIBILITY_VERSION = 1; 295 | DYLIB_CURRENT_VERSION = 1; 296 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 297 | FRAMEWORK_SEARCH_PATHS = ( 298 | "$(inherited)", 299 | "/Users/alonso/dev/podcastfooMobile/node_modules/react-native-firebase", 300 | "$(PROJECT_DIR)", 301 | ); 302 | HEADER_SEARCH_PATHS = ( 303 | "$(inherited)", 304 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 305 | "$(SRCROOT)/../react-native/React/**", 306 | "$(SRCROOT)/../../React/**", 307 | "$(SRCROOT)/node_modules/react-native/React/**", 308 | ); 309 | INFOPLIST_FILE = RNFirebase/Info.plist; 310 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 311 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 312 | LIBRARY_SEARCH_PATHS = ( 313 | "$(inherited)", 314 | "$(USER_LIBRARY_DIR)/Developer/Xcode/DerivedData/podcastfooMobile-boqeypfpxrvhkkewzjtydjhihgdb/Build/Products/Debug-iphoneos", 315 | "/Users/alonso/dev/podcastfooMobile/Pods/../build/Debug-iphoneos", 316 | ); 317 | PRODUCT_NAME = "$(TARGET_NAME)"; 318 | SKIP_INSTALL = YES; 319 | TARGETED_DEVICE_FAMILY = 1; 320 | }; 321 | name = Debug; 322 | }; 323 | E26E2A0C1BBE54B800BF9CD9 /* Release */ = { 324 | isa = XCBuildConfiguration; 325 | buildSettings = { 326 | ALWAYS_SEARCH_USER_PATHS = NO; 327 | DEAD_CODE_STRIPPING = NO; 328 | DEFINES_MODULE = YES; 329 | DYLIB_COMPATIBILITY_VERSION = 1; 330 | DYLIB_CURRENT_VERSION = 1; 331 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 332 | FRAMEWORK_SEARCH_PATHS = ( 333 | "$(inherited)", 334 | "/Users/alonso/dev/podcastfooMobile/node_modules/react-native-firebase", 335 | "$(PROJECT_DIR)", 336 | ); 337 | HEADER_SEARCH_PATHS = ( 338 | "$(inherited)", 339 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 340 | "$(SRCROOT)/../react-native/React/**", 341 | "$(SRCROOT)/../../React/**", 342 | "$(SRCROOT)/node_modules/react-native/React/**", 343 | ); 344 | INFOPLIST_FILE = RNFirebase/Info.plist; 345 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 346 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 347 | LIBRARY_SEARCH_PATHS = ( 348 | "$(inherited)", 349 | "$(USER_LIBRARY_DIR)/Developer/Xcode/DerivedData/podcastfooMobile-boqeypfpxrvhkkewzjtydjhihgdb/Build/Products/Debug-iphoneos", 350 | "/Users/alonso/dev/podcastfooMobile/Pods/../build/Debug-iphoneos", 351 | ); 352 | PRODUCT_NAME = "$(TARGET_NAME)"; 353 | SKIP_INSTALL = YES; 354 | TARGETED_DEVICE_FAMILY = 1; 355 | }; 356 | name = Release; 357 | }; 358 | /* End XCBuildConfiguration section */ 359 | 360 | /* Begin XCConfigurationList section */ 361 | E26E29EE1BBE54B800BF9CD9 /* Build configuration list for PBXProject "RNFirebase" */ = { 362 | isa = XCConfigurationList; 363 | buildConfigurations = ( 364 | E26E2A081BBE54B800BF9CD9 /* Debug */, 365 | E26E2A091BBE54B800BF9CD9 /* Release */, 366 | ); 367 | defaultConfigurationIsVisible = 0; 368 | defaultConfigurationName = Release; 369 | }; 370 | E26E2A0A1BBE54B800BF9CD9 /* Build configuration list for PBXNativeTarget "RNFirebase" */ = { 371 | isa = XCConfigurationList; 372 | buildConfigurations = ( 373 | E26E2A0B1BBE54B800BF9CD9 /* Debug */, 374 | E26E2A0C1BBE54B800BF9CD9 /* Release */, 375 | ); 376 | defaultConfigurationIsVisible = 0; 377 | defaultConfigurationName = Release; 378 | }; 379 | /* End XCConfigurationList section */ 380 | }; 381 | rootObject = E26E29EB1BBE54B800BF9CD9 /* Project object */; 382 | } 383 | -------------------------------------------------------------------------------- /RNFirebase.xcodeproj/xcuserdata/alonso.xcuserdatad/xcschemes/RNFirebase.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 75 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 94 | 100 | 101 | 102 | 103 | 105 | 106 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /RNFirebase.xcodeproj/xcuserdata/alonso.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | RNFirebase.xcscheme 8 | 9 | orderHint 10 | 14 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | E26E29F31BBE54B800BF9CD9 16 | 17 | primary 18 | 19 | 20 | E26E29FE1BBE54B800BF9CD9 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /RNFirebase/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/holmesal/react-native-firebase/37ed6cb77efd65276fc92ebf6890ddd02cb4fb3b/RNFirebase/.DS_Store -------------------------------------------------------------------------------- /RNFirebase/Firebase.framework/Firebase: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/holmesal/react-native-firebase/37ed6cb77efd65276fc92ebf6890ddd02cb4fb3b/RNFirebase/Firebase.framework/Firebase -------------------------------------------------------------------------------- /RNFirebase/Firebase.framework/Headers/FAuthData.h: -------------------------------------------------------------------------------- 1 | // 2 | // FAuthData.h 3 | // Firebase 4 | // 5 | // Created by Katherine Fang on 7/30/14. 6 | // 7 | 8 | #import 9 | #import "FAuthType.h" 10 | 11 | 12 | /** 13 | * The FAuthData class is a wrapper around the user metadata returned from the Firebase auth server. 14 | * It includes the provider authenticated against, a uid (with the possible exception of authenticating against a custom 15 | * backend), and a token used to authenticate with Firebase. 16 | * 17 | * It may include other metadata about the user, depending on the provider used to do the authentication. 18 | */ 19 | @interface FAuthData : NSObject 20 | 21 | /** 22 | * @return Raw authentication token payload returned by the server 23 | */ 24 | @property (nonatomic, strong, readonly) NSDictionary *auth; 25 | 26 | /** 27 | * @return Authentication token expiration timestamp (seconds since epoch) returned by the server 28 | */ 29 | @property (nonatomic, strong, readonly) NSNumber *expires; 30 | 31 | /** 32 | * @return A uid for this user. It is unique across all auth providers. 33 | */ 34 | @property (nonatomic, strong, readonly) NSString *uid; 35 | 36 | 37 | /** 38 | * @return The provider that authenticated this user 39 | */ 40 | @property (nonatomic, readonly) NSString *provider; 41 | 42 | 43 | /** 44 | * @return The token that was used to authenticate this user with Firebase 45 | */ 46 | @property (nonatomic, strong, readonly) NSString *token; 47 | 48 | 49 | /** 50 | * @return Provider data keyed by provider. Includes cached data from third-party providers 51 | */ 52 | @property (nonatomic, strong, readonly) NSDictionary *providerData; 53 | 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /RNFirebase/Firebase.framework/Headers/FAuthType.h: -------------------------------------------------------------------------------- 1 | // 2 | // FAuthType.h 3 | // Firebase 4 | // 5 | // Created by Katherine Fang on 7/30/14. 6 | // 7 | // All public-facing auth enums. 8 | // 9 | 10 | #ifndef Firebase_FAuthenticationTypes_h 11 | #define Firebase_FAuthenticationTypes_h 12 | 13 | typedef NS_ENUM(NSInteger, FAuthenticationError) { 14 | // Developer / Config Errors 15 | FAuthenticationErrorProviderDisabled = -1, 16 | FAuthenticationErrorInvalidConfiguration = -2, 17 | FAuthenticationErrorInvalidOrigin = -3, 18 | FAuthenticationErrorInvalidProvider = -4, 19 | 20 | // User Errors (Email / Password) 21 | FAuthenticationErrorInvalidEmail = -5, 22 | FAuthenticationErrorInvalidPassword = -6, 23 | FAuthenticationErrorInvalidToken = -7, 24 | FAuthenticationErrorUserDoesNotExist = -8, 25 | FAuthenticationErrorEmailTaken = -9, 26 | 27 | // User Errors (Facebook / Twitter / Github / Google) 28 | FAuthenticationErrorDeniedByUser = -10, 29 | FAuthenticationErrorInvalidCredentials = -11, 30 | FAuthenticationErrorInvalidArguments = -12, 31 | FAuthenticationErrorProviderError = -13, 32 | FAuthenticationErrorLimitsExceeded = -14, 33 | 34 | // Client side errors 35 | FAuthenticationErrorNetworkError = -15, 36 | FAuthenticationErrorPreempted = -16, 37 | 38 | FAuthenticationErrorUnknown = -9999 39 | }; 40 | 41 | #endif -------------------------------------------------------------------------------- /RNFirebase/Firebase.framework/Headers/FConfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Firebase iOS Client Library 3 | * 4 | * Copyright © 2015 Firebase - All Rights Reserved 5 | * https://www.firebase.com 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binaryform must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY FIREBASE AS IS AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 20 | * EVENT SHALL FIREBASE BE LIABLE FOR ANY DIRECT, 21 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #import 30 | 31 | /** 32 | * Configuration object for Firebase. You can get the default FConfig object via 33 | * `[Firebase defaultConfig]` and modify it. You must make all changes to it before 34 | * you create your first Firebase instance. 35 | */ 36 | @interface FConfig : NSObject 37 | 38 | /** 39 | * By default the Firebase client will keep data in memory while your application is running, but not 40 | * when it is restarted. By setting this value to YES, the data will be persisted to on-device (disk) 41 | * storage and will thus be available again when the app is restarted (even when there is no network 42 | * connectivity at that time). Note that this property must be set before creating your first Firebase 43 | * reference and only needs to be called once per application. 44 | * 45 | * If your app uses Firebase Authentication, the client will automatically persist the user's authentication 46 | * token across restarts, even without persistence enabled. But if the auth token expired while offline and 47 | * you've enabled persistence, the client will pause write operations until you successfully re-authenticate 48 | * (or explicitly unauthenticate) to prevent your writes from being sent unauthenticated and failing due to 49 | * security rules. 50 | */ 51 | @property (nonatomic) BOOL persistenceEnabled; 52 | 53 | /** 54 | * By default Firebase will use up to 10MB of disk space to cache data. If the cache grows beyond this size, 55 | * Firebase will start removing data that hasn't been recently used. If you find that your application caches too 56 | * little or too much data, call this method to change the cache size. This property must be set before creating 57 | * your first Firebase reference and only needs to be called once per application. 58 | * 59 | * Note that the specified cache size is only an approximation and the size on disk may temporarily exceed it 60 | * at times. 61 | */ 62 | @property (nonatomic) NSUInteger persistenceCacheSizeBytes; 63 | 64 | /** 65 | * Sets the dispatch queue on which all events are raised. The default queue is the main queue. 66 | */ 67 | @property (nonatomic, strong) dispatch_queue_t callbackQueue; 68 | 69 | @end 70 | -------------------------------------------------------------------------------- /RNFirebase/Firebase.framework/Headers/FDataSnapshot.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Firebase iOS Client Library 3 | * 4 | * Copyright © 2013 Firebase - All Rights Reserved 5 | * https://www.firebase.com 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binaryform must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY FIREBASE AS IS AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 20 | * EVENT SHALL FIREBASE BE LIABLE FOR ANY DIRECT, 21 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #import 30 | 31 | @class Firebase; 32 | 33 | /** 34 | * An FDataSnapshot contains data from a Firebase location. Any time you read 35 | * Firebase data, you receive the data as an FDataSnapshot. 36 | * 37 | * FDataSnapshots are passed to the blocks you attach with observeEventType:withBlock: or observeSingleEvent:withBlock:. 38 | * They are efficiently-generated immutable copies of the data at a Firebase location. 39 | * They can't be modified and will never change. To modify data at a location, 40 | * use a Firebase reference (e.g. with setValue:). 41 | */ 42 | @interface FDataSnapshot : NSObject 43 | 44 | 45 | /** @name Navigating and inspecting a snapshot */ 46 | 47 | /** 48 | * Get an FDataSnapshot for the location at the specified relative path. 49 | * The relative path can either be a simple child key (e.g. 'fred') 50 | * or a deeper slash-separated path (e.g. 'fred/name/first'). If the child 51 | * location has no data, an empty FDataSnapshot is returned. 52 | * 53 | * @param childPathString A relative path to the location of child data. 54 | * @return The FDataSnapshot for the child location. 55 | */ 56 | - (FDataSnapshot *) childSnapshotForPath:(NSString *)childPathString; 57 | 58 | 59 | /** 60 | * Return YES if the specified child exists. 61 | * 62 | * @param childPathString A relative path to the location of a potential child. 63 | * @return YES if data exists at the specified childPathString, else false. 64 | */ 65 | - (BOOL) hasChild:(NSString *)childPathString; 66 | 67 | 68 | /** 69 | * Return YES if the DataSnapshot has any children. 70 | * 71 | * @return YES if this snapshot has any children, else NO. 72 | */ 73 | - (BOOL) hasChildren; 74 | 75 | 76 | /** 77 | * Return YES if the DataSnapshot contains a non-null value. 78 | * 79 | * @return YES if this snapshot contains a non-null value, otherwise NO. 80 | */ 81 | - (BOOL) exists; 82 | 83 | 84 | /** @name Data export */ 85 | 86 | /** 87 | * Returns the raw value at this location, coupled with any metadata, such as priority. 88 | * 89 | * Priorities, where they exist, are accessible under the ".priority" key in instances of NSDictionary. 90 | * For leaf locations with priorities, the value will be under the ".value" key. 91 | */ 92 | - (id) valueInExportFormat; 93 | 94 | 95 | /** @name Properties */ 96 | 97 | /** 98 | * Returns the contents of this data snapshot as native types. 99 | * 100 | * Data types returned: 101 | * * NSDictionary 102 | * * NSArray 103 | * * NSNumber (also includes booleans) 104 | * * NSString 105 | * 106 | * @return The data as a native object. 107 | */ 108 | @property (strong, readonly, nonatomic) id value; 109 | 110 | 111 | /** 112 | * Get the number of children for this DataSnapshot. 113 | * 114 | * @return An integer indicating the number of children. 115 | */ 116 | @property (readonly, nonatomic) NSUInteger childrenCount; 117 | 118 | 119 | /** 120 | * Get a Firebase reference for the location that this data came from 121 | * 122 | * @return A Firebase instance for the location of this data 123 | */ 124 | @property (nonatomic, readonly, strong) Firebase* ref; 125 | 126 | 127 | /** 128 | * The key of the location that generated this FDataSnapshot. 129 | * 130 | * @return An NSString containing the key for the location of this FDataSnapshot. 131 | */ 132 | @property (strong, readonly, nonatomic) NSString* key; 133 | 134 | 135 | /** 136 | * An iterator for snapshots of the child nodes in this snapshot. 137 | * You can use the native for..in syntax: 138 | * 139 | * for (FDataSnapshot* child in snapshot.children) { 140 | * ... 141 | * } 142 | * 143 | * @return An NSEnumerator of the children 144 | */ 145 | @property (strong, readonly, nonatomic) NSEnumerator* children; 146 | 147 | /** 148 | * The priority of the data in this FDataSnapshot. 149 | * 150 | * @return The priority as a string, or nil if no priority was set. 151 | */ 152 | @property (strong, readonly, nonatomic) id priority; 153 | 154 | @end 155 | -------------------------------------------------------------------------------- /RNFirebase/Firebase.framework/Headers/FEventType.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Firebase iOS Client Library 3 | * 4 | * Copyright © 2013 Firebase - All Rights Reserved 5 | * https://www.firebase.com 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binaryform must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY FIREBASE AS IS AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 20 | * EVENT SHALL FIREBASE BE LIABLE FOR ANY DIRECT, 21 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef Firebase_FEventType_h 30 | #define Firebase_FEventType_h 31 | 32 | /** 33 | * This enum is the set of events that you can observe at a Firebase location. 34 | */ 35 | typedef NS_ENUM(NSInteger, FEventType) { 36 | FEventTypeChildAdded, // 0, fired when a new child node is added to a location 37 | FEventTypeChildRemoved, // 1, fired when a child node is removed from a location 38 | FEventTypeChildChanged, // 2, fired when a child node at a location changes 39 | FEventTypeChildMoved, // 3, fired when a child node moves relative to the other child nodes at a location 40 | FEventTypeValue // 4, fired when any data changes at a location and, recursively, any children 41 | }; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /RNFirebase/Firebase.framework/Headers/FMutableData.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Firebase iOS Client Library 3 | * 4 | * Copyright © 2013 Firebase - All Rights Reserved 5 | * https://www.firebase.com 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binaryform must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY FIREBASE AS IS AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 20 | * EVENT SHALL FIREBASE BE LIABLE FOR ANY DIRECT, 21 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #import 30 | 31 | /** 32 | * An FMutableData instance is populated with data from a Firebase location. 33 | * When you are using runTransactionBlock:, you will be given an instance containing the current 34 | * data at that location. Your block will be responsible for updating that instance to the data 35 | * you wish to save at that location, and then returning using [FTransactionResult successWithValue:]. 36 | * 37 | * To modify the data, set its value property to any of the native types support by Firebase: 38 | * * NSNumber (includes BOOL) 39 | * * NSDictionary 40 | * * NSArray 41 | * * NSString 42 | * * nil / NSNull to remove the data 43 | * 44 | * Note that changes made to a child FMutableData instance will be visible to the parent. 45 | */ 46 | @interface FMutableData : NSObject 47 | 48 | 49 | /** @name Inspecting and navigating the data */ 50 | 51 | 52 | /** 53 | * Returns boolean indicating whether this mutable data has children. 54 | * 55 | * @return YES if this data contains child nodes. 56 | */ 57 | - (BOOL) hasChildren; 58 | 59 | 60 | /** 61 | * Indicates whether this mutable data has a child at the given path. 62 | * 63 | * @param path A path string, consisting either of a single segment, like 'child', or multiple segments, 'a/deeper/child' 64 | * @return YES if this data contains a child at the specified relative path 65 | */ 66 | - (BOOL) hasChildAtPath:(NSString *)path; 67 | 68 | 69 | /** 70 | * Used to obtain an FMutableData instance that encapsulates the data at the given relative path. 71 | * Note that changes made to the child will be visible to the parent. 72 | * 73 | * @param path A path string, consisting either of a single segment, like 'child', or multiple segments, 'a/deeper/child' 74 | * @return An FMutableData instance containing the data at the given path 75 | */ 76 | - (FMutableData *) childDataByAppendingPath:(NSString *)path; 77 | 78 | 79 | /** @name Properties */ 80 | 81 | 82 | /** 83 | * This method is deprecated. 84 | * 85 | * @return An FMutableData instance containing the data at the parent location, or nil if this is the top-most location 86 | */ 87 | @property (strong, readonly, nonatomic) FMutableData* parent __attribute__((deprecated("Deprecated. Do not use.")));; 88 | 89 | 90 | /** 91 | * To modify the data contained by this instance of FMutableData, set this to any of the native types support by Firebase: 92 | * 93 | * * NSNumber (includes BOOL) 94 | * * NSDictionary 95 | * * NSArray 96 | * * NSString 97 | * * nil / NSNull to remove the data 98 | * 99 | * Note that setting the value will override the priority at this location. 100 | * 101 | * @return The current data at this location as a native object 102 | */ 103 | @property (strong, nonatomic) id value; 104 | 105 | 106 | /** 107 | * Set this property to update the priority of the data at this location. Can be set to the following types: 108 | * 109 | * * NSNumber 110 | * * NSString 111 | * * nil / NSNull to remove the priority 112 | * 113 | * @return The priority of the data at this location 114 | */ 115 | @property (strong, nonatomic) id priority; 116 | 117 | 118 | /** 119 | * @return The number of child nodes at this location 120 | */ 121 | @property (readonly, nonatomic) NSUInteger childrenCount; 122 | 123 | 124 | /** 125 | * Used to iterate over the children at this location. You can use the native for .. in syntax: 126 | * 127 | * for (FMutableData* child in data.children) { 128 | * ... 129 | * } 130 | * 131 | * Note that this enumerator operates on an immutable copy of the child list. So, you can modify the instance 132 | * during iteration, but the new additions will not be visible until you get a new enumerator. 133 | */ 134 | @property (readonly, nonatomic, strong) NSEnumerator* children; 135 | 136 | 137 | /** 138 | * @return The key name of this node, or nil if it is the top-most location 139 | */ 140 | @property (readonly, nonatomic, strong) NSString* key; 141 | 142 | 143 | @end 144 | -------------------------------------------------------------------------------- /RNFirebase/Firebase.framework/Headers/FQuery.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Firebase iOS Client Library 3 | * 4 | * Copyright © 2013 Firebase - All Rights Reserved 5 | * https://www.firebase.com 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binaryform must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY FIREBASE AS IS AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 20 | * EVENT SHALL FIREBASE BE LIABLE FOR ANY DIRECT, 21 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #import 30 | #import "FEventType.h" 31 | #import "FDataSnapshot.h" 32 | 33 | typedef NSUInteger FirebaseHandle; 34 | 35 | /** 36 | * An FQuery instance represents a query over the data at a particular location. 37 | * 38 | * You create one by calling one of the query methods (queryStartingAtPriority:, queryEndingAtPriority:, etc.) 39 | * on a Firebase reference. The query methods can be chained to further specify the data you are interested in 40 | * observing 41 | */ 42 | @interface FQuery : NSObject 43 | 44 | 45 | /** @name Attaching observers to read data */ 46 | 47 | /** 48 | * observeEventType:withBlock: is used to listen for data changes at a particular location. 49 | * This is the primary way to read data from Firebase. Your block will be triggered 50 | * for the initial data and again whenever the data changes. 51 | * 52 | * Use removeObserverWithHandle: to stop receiving updates. 53 | * @param eventType The type of event to listen for. 54 | * @param block The block that should be called with initial data and updates. It is passed the data as an FDataSnapshot. 55 | * @return A handle used to unregister this block later using removeObserverWithHandle: 56 | */ 57 | - (FirebaseHandle) observeEventType:(FEventType)eventType withBlock:(void (^)(FDataSnapshot* snapshot))block; 58 | 59 | 60 | /** 61 | * observeEventType:andPreviousSiblingKeyWithBlock: is used to listen for data changes at a particular location. 62 | * This is the primary way to read data from Firebase. Your block will be triggered 63 | * for the initial data and again whenever the data changes. In addition, for FEventTypeChildAdded, FEventTypeChildMoved, and 64 | * FEventTypeChildChanged events, your block will be passed the key of the previous node by priority order. 65 | * 66 | * Use removeObserverWithHandle: to stop receiving updates. 67 | * 68 | * @param eventType The type of event to listen for. 69 | * @param block The block that should be called with initial data and updates. It is passed the data as an FDataSnapshot 70 | * and the previous child's key. 71 | * @return A handle used to unregister this block later using removeObserverWithHandle: 72 | */ 73 | - (FirebaseHandle) observeEventType:(FEventType)eventType andPreviousSiblingKeyWithBlock:(void (^)(FDataSnapshot* snapshot, NSString* prevKey))block; 74 | 75 | 76 | /** 77 | * observeEventType:withBlock: is used to listen for data changes at a particular location. 78 | * This is the primary way to read data from Firebase. Your block will be triggered 79 | * for the initial data and again whenever the data changes. 80 | * 81 | * The cancelBlock will be called if you will no longer receive new events due to no longer having permission. 82 | * 83 | * Use removeObserverWithHandle: to stop receiving updates. 84 | * 85 | * @param eventType The type of event to listen for. 86 | * @param block The block that should be called with initial data and updates. It is passed the data as an FDataSnapshot. 87 | * @param cancelBlock The block that should be called if this client no longer has permission to receive these events 88 | * @return A handle used to unregister this block later using removeObserverWithHandle: 89 | */ 90 | - (FirebaseHandle) observeEventType:(FEventType)eventType withBlock:(void (^)(FDataSnapshot* snapshot))block withCancelBlock:(void (^)(NSError* error))cancelBlock; 91 | 92 | 93 | /** 94 | * observeEventType:andPreviousSiblingKeyWithBlock: is used to listen for data changes at a particular location. 95 | * This is the primary way to read data from Firebase. Your block will be triggered 96 | * for the initial data and again whenever the data changes. In addition, for FEventTypeChildAdded, FEventTypeChildMoved, and 97 | * FEventTypeChildChanged events, your block will be passed the key of the previous node by priority order. 98 | * 99 | * The cancelBlock will be called if you will no longer receive new events due to no longer having permission. 100 | * 101 | * Use removeObserverWithHandle: to stop receiving updates. 102 | * 103 | * @param eventType The type of event to listen for. 104 | * @param block The block that should be called with initial data and updates. It is passed the data as an FDataSnapshot 105 | * and the previous child's key. 106 | * @param cancelBlock The block that should be called if this client no longer has permission to receive these events 107 | * @return A handle used to unregister this block later using removeObserverWithHandle: 108 | */ 109 | - (FirebaseHandle) observeEventType:(FEventType)eventType andPreviousSiblingKeyWithBlock:(void (^)(FDataSnapshot* snapshot, NSString* prevKey))block withCancelBlock:(void (^)(NSError* error))cancelBlock; 110 | 111 | 112 | /** 113 | * This is equivalent to observeEventType:withBlock:, except the block is immediately canceled after the initial data is returned. 114 | * 115 | * @param eventType The type of event to listen for. 116 | * @param block The block that should be called. It is passed the data as an FDataSnapshot. 117 | */ 118 | - (void) observeSingleEventOfType:(FEventType)eventType withBlock:(void (^)(FDataSnapshot* snapshot))block; 119 | 120 | 121 | /** 122 | * This is equivalent to observeEventType:withBlock:, except the block is immediately canceled after the initial data is returned. In addition, for FEventTypeChildAdded, FEventTypeChildMoved, and 123 | * FEventTypeChildChanged events, your block will be passed the key of the previous node by priority order. 124 | * 125 | * @param eventType The type of event to listen for. 126 | * @param block The block that should be called. It is passed the data as an FDataSnapshot and the previous child's key. 127 | */ 128 | - (void) observeSingleEventOfType:(FEventType)eventType andPreviousSiblingKeyWithBlock:(void (^)(FDataSnapshot* snapshot, NSString* prevKey))block; 129 | 130 | 131 | /** 132 | * This is equivalent to observeEventType:withBlock:, except the block is immediately canceled after the initial data is returned. 133 | * 134 | * The cancelBlock will be called if you do not have permission to read data at this location. 135 | * 136 | * @param eventType The type of event to listen for. 137 | * @param block The block that should be called. It is passed the data as an FDataSnapshot. 138 | * @param cancelBlock The block that will be called if you don't have permission to access this data 139 | */ 140 | - (void) observeSingleEventOfType:(FEventType)eventType withBlock:(void (^)(FDataSnapshot* snapshot))block withCancelBlock:(void (^)(NSError* error))cancelBlock; 141 | 142 | 143 | /** 144 | * This is equivalent to observeEventType:withBlock:, except the block is immediately canceled after the initial data is returned. In addition, for FEventTypeChildAdded, FEventTypeChildMoved, and 145 | * FEventTypeChildChanged events, your block will be passed the key of the previous node by priority order. 146 | * 147 | * The cancelBlock will be called if you do not have permission to read data at this location. 148 | * 149 | * @param eventType The type of event to listen for. 150 | * @param block The block that should be called. It is passed the data as an FDataSnapshot and the previous child's key. 151 | * @param cancelBlock The block that will be called if you don't have permission to access this data 152 | */ 153 | - (void) observeSingleEventOfType:(FEventType)eventType andPreviousSiblingKeyWithBlock:(void (^)(FDataSnapshot* snapshot, NSString* prevKey))block withCancelBlock:(void (^)(NSError* error))cancelBlock; 154 | 155 | /** @name Detaching observers */ 156 | 157 | /** 158 | * Detach a block previously attached with observeEventType:withBlock:. 159 | * 160 | * @param handle The handle returned by the call to observeEventType:withBlock: which we are trying to remove. 161 | */ 162 | - (void) removeObserverWithHandle:(FirebaseHandle)handle; 163 | 164 | 165 | /** 166 | * Detach all blocks previously attached to this Firebase location with observeEventType:withBlock: 167 | */ 168 | - (void) removeAllObservers; 169 | 170 | /** 171 | * By calling `keepSynced:YES` on a location, the data for that location will automatically be downloaded and 172 | * kept in sync, even when no listeners are attached for that location. Additionally, while a location is kept 173 | * synced, it will not be evicted from the persistent disk cache. 174 | * 175 | * @param keepSynced Pass YES to keep this location synchronized, pass NO to stop synchronization. 176 | */ 177 | - (void) keepSynced:(BOOL)keepSynced; 178 | 179 | 180 | /** @name Querying and limiting */ 181 | 182 | 183 | /** 184 | * This method is deprecated in favor of using queryStartingAtValue:. This can be used with queryOrderedByPriority 185 | * to query by priority. 186 | * 187 | * queryStartingAtPriority: is used to generate a reference to a limited view of the data at this location. 188 | * The FQuery instance returned by queryStartingAtPriority: will respond to events at nodes with a priority 189 | * greater than or equal to startPriority 190 | * 191 | * @param startPriority The lower bound, inclusive, for the priority of data visible to the returned FQuery 192 | * @return An FQuery instance, limited to data with priority greater than or equal to startPriority 193 | */ 194 | - (FQuery *) queryStartingAtPriority:(id)startPriority __attribute__((deprecated("Use [[FQuery queryOrderedByPriority] queryStartingAtValue:] instead"))); 195 | 196 | 197 | /** 198 | * This method is deprecated in favor of using queryStartingAtValue:childKey:. This can be used with queryOrderedByPriority 199 | * to query by priority. 200 | * 201 | * queryStartingAtPriority:andChildName: is used to generate a reference to a limited view of the data at this location. 202 | * The FQuery instance returned by queryStartingAtPriority:andChildName will respond to events at nodes with a priority 203 | * greater than startPriority, or equal to startPriority and with a name greater than or equal to childName 204 | * 205 | * @param startPriority The lower bound, inclusive, for the priority of data visible to the returned FQuery 206 | * @param childName The lower bound, inclusive, for the name of nodes with priority equal to startPriority 207 | * @return An FQuery instance, limited to data with priority greater than or equal to startPriority 208 | */ 209 | - (FQuery *) queryStartingAtPriority:(id)startPriority andChildName:(NSString *)childName __attribute__((deprecated("Use [[FQuery queryOrderedByPriority] queryStartingAtValue:childKey:] instead"))); 210 | 211 | /** 212 | * This method is deprecated in favor of using queryEndingAtValue:. This can be used with queryOrderedByPriority 213 | * to query by priority. 214 | * 215 | * queryEndingAtPriority: is used to generate a reference to a limited view of the data at this location. 216 | * The FQuery instance returned by queryEndingAtPriority: will respond to events at nodes with a priority 217 | * less than or equal to startPriority and with a name greater than or equal to childName 218 | * 219 | * @param endPriority The upper bound, inclusive, for the priority of data visible to the returned FQuery 220 | * @return An FQuery instance, limited to data with priority less than or equal to endPriority 221 | */ 222 | - (FQuery *) queryEndingAtPriority:(id)endPriority __attribute__((deprecated("Use [[FQuery queryOrderedByPriority] queryEndingAtValue:] instead"))); 223 | 224 | 225 | /** 226 | * This method is deprecated in favor of using queryEndingAtValue:childKey:. This can be used with queryOrderedByPriority 227 | * to query by priority. 228 | * 229 | * queryEndingAtPriority:andChildName: is used to generate a reference to a limited view of the data at this location. 230 | * The FQuery instance returned by queryEndingAtPriority:andChildName will respond to events at nodes with a priority 231 | * less than endPriority, or equal to endPriority and with a name less than or equal to childName 232 | * 233 | * @param endPriority The upper bound, inclusive, for the priority of data visible to the returned FQuery 234 | * @param childName The upper bound, inclusive, for the name of nodes with priority equal to endPriority 235 | * @return An FQuery instance, limited to data with priority less than endPriority or equal to endPriority and with a name less than or equal to childName 236 | */ 237 | - (FQuery *) queryEndingAtPriority:(id)endPriority andChildName:(NSString *)childName __attribute__((deprecated("Use [[FQuery queryOrderedByPriority] queryEndingAtValue:childKey:] instead"))); 238 | 239 | 240 | /** 241 | * This method is deprecated in favor of using queryEqualToValue:. This can be used with queryOrderedByPriority 242 | * to query by priority. 243 | * 244 | * queryEqualToPriority: is used to generate a reference to a limited view of the data at this location. 245 | * The FQuery instance returned by queryEqualToPriority: will respond to events at nodes with a priority equal to 246 | * supplied argument. 247 | * 248 | * @param priority The priority that the data returned by this FQuery will have 249 | * @return An Fquery instance, limited to data with the supplied priority. 250 | */ 251 | - (FQuery *) queryEqualToPriority:(id)priority __attribute__((deprecated("Use [[FQuery queryOrderedByPriority] queryEqualToValue:] instead"))); 252 | 253 | 254 | /** 255 | * This method is deprecated in favor of using queryEqualAtValue:childKey:. This can be used with queryOrderedByPriority 256 | * to query by priority. 257 | * 258 | * queryEqualToPriority:andChildName: is used to generate a reference to a limited view of the data at this location. 259 | * The FQuery instance returned by queryEqualToPriority:andChildName will respond to events at nodes with a priority 260 | * equal to the supplied argument with a name equal to childName. There will be at most one node that matches because 261 | * child names are unique. 262 | * 263 | * @param priority The priority that the data returned by this FQuery will have 264 | * @param childName The name of nodes with the right priority 265 | * @return An FQuery instance, limited to data with the supplied priority and the name. 266 | */ 267 | - (FQuery *) queryEqualToPriority:(id)priority andChildName:(NSString *)childName __attribute__((deprecated("Use [[FQuery queryOrderedByPriority] queryEqualToValue:childKey:] instead"))); 268 | 269 | /** 270 | * This method is deprecated in favor of using queryLimitedToFirst:limit or queryLimitedToLast:limit instead. 271 | * 272 | * queryLimitedToNumberOfChildren: is used to generate a reference to a limited view of the data at this location. 273 | * The FQuery instance returned by queryLimitedToNumberOfChildren: will respond to events from at most limit child nodes. 274 | * 275 | * @param limit The upper bound, inclusive, for the number of child nodes to receive events for 276 | * @return An FQuery instance, limited to at most limit child nodes. 277 | */ 278 | - (FQuery *) queryLimitedToNumberOfChildren:(NSUInteger)limit __attribute__((deprecated("Use [FQuery queryLimitedToFirst:limit] or [FQuery queryLimitedToLast:limit] instead"))); 279 | 280 | 281 | /** 282 | * queryLimitedToFirst: is used to generate a reference to a limited view of the data at this location. 283 | * The FQuery instance returned by queryLimitedToFirst: will respond to at most the first limit child nodes. 284 | * 285 | * @param limit The upper bound, inclusive, for the number of child nodes to receive events for 286 | * @return An FQuery instance, limited to at most limit child nodes. 287 | */ 288 | - (FQuery *) queryLimitedToFirst:(NSUInteger)limit; 289 | 290 | 291 | /** 292 | * queryLimitedToLast: is used to generate a reference to a limited view of the data at this location. 293 | * The FQuery instance returned by queryLimitedToLast: will respond to at most the last limit child nodes. 294 | * 295 | * @param limit The upper bound, inclusive, for the number of child nodes to receive events for 296 | * @return An FQuery instance, limited to at most limit child nodes. 297 | */ 298 | - (FQuery *) queryLimitedToLast:(NSUInteger)limit; 299 | 300 | /** 301 | * queryOrderBy: is used to generate a reference to a view of the data that's been sorted by the values of 302 | * a particular child key. This method is intended to be used in combination with queryStartingAtValue:, 303 | * queryEndingAtValue:, or queryEqualToValue:. 304 | * 305 | * @param key The child key to use in ordering data visible to the returned FQuery 306 | * @return An FQuery instance, ordered by the values of the specified child key. 307 | */ 308 | - (FQuery *) queryOrderedByChild:(NSString *)key; 309 | 310 | /** 311 | * queryOrderedByKey: is used to generate a reference to a view of the data that's been sorted by child key. 312 | * This method is intended to be used in combination with queryStartingAtValue:, queryEndingAtValue:, 313 | * or queryEqualToValue:. 314 | * 315 | * @return An FQuery instance, ordered by child keys. 316 | */ 317 | - (FQuery *) queryOrderedByKey; 318 | 319 | /** 320 | * queryOrderedByValue: is used to generate a reference to a view of the data that's been sorted by child value. 321 | * This method is intended to be used in combination with queryStartingAtValue:, queryEndingAtValue:, 322 | * or queryEqualToValue:. 323 | * 324 | * @return An FQuery instance, ordered by child value. 325 | */ 326 | - (FQuery *) queryOrderedByValue; 327 | 328 | /** 329 | * queryOrderedByPriority: is used to generate a reference to a view of the data that's been sorted by child 330 | * priority. This method is intended to be used in combination with queryStartingAtValue:, queryEndingAtValue:, 331 | * or queryEqualToValue:. 332 | * 333 | * @return An FQuery instance, ordered by child priorities. 334 | */ 335 | - (FQuery *) queryOrderedByPriority; 336 | 337 | /** 338 | * queryStartingAtValue: is used to generate a reference to a limited view of the data at this location. 339 | * The FQuery instance returned by queryStartingAtValue: will respond to events at nodes with a value 340 | * greater than or equal to startValue. 341 | * 342 | * @param startValue The lower bound, inclusive, for the value of data visible to the returned FQuery 343 | * @return An FQuery instance, limited to data with value greater than or equal to startValue 344 | */ 345 | - (FQuery *) queryStartingAtValue:(id)startValue; 346 | 347 | /** 348 | * queryStartingAtValue:childKey: is used to generate a reference to a limited view of the data at this location. 349 | * The FQuery instance returned by queryStartingAtValue:childKey will respond to events at nodes with a value 350 | * greater than startValue, or equal to startValue and with a key greater than or equal to childKey. 351 | * 352 | * @param startValue The lower bound, inclusive, for the value of data visible to the returned FQuery 353 | * @param childKey The lower bound, inclusive, for the key of nodes with value equal to startValue 354 | * @return An FQuery instance, limited to data with value greater than or equal to startValue 355 | */ 356 | - (FQuery *) queryStartingAtValue:(id)startValue childKey:(NSString *)childKey; 357 | 358 | /** 359 | * queryEndingAtValue: is used to generate a reference to a limited view of the data at this location. 360 | * The FQuery instance returned by queryEndingAtValue: will respond to events at nodes with a value 361 | * less than or equal to endValue. 362 | * 363 | * @param endValue The upper bound, inclusive, for the value of data visible to the returned FQuery 364 | * @return An FQuery instance, limited to data with value less than or equal to endValue 365 | */ 366 | - (FQuery *) queryEndingAtValue:(id)endValue; 367 | 368 | /** 369 | * queryEndingAtValue:childKey: is used to generate a reference to a limited view of the data at this location. 370 | * The FQuery instance returned by queryEndingAtValue:childKey will respond to events at nodes with a value 371 | * less than endValue, or equal to endValue and with a key less than or equal to childKey. 372 | * 373 | * @param endValue The upper bound, inclusive, for the value of data visible to the returned FQuery 374 | * @param childKey The upper bound, inclusive, for the key of nodes with value equal to endValue 375 | * @return An FQuery instance, limited to data with value less than or equal to endValue 376 | */ 377 | - (FQuery *) queryEndingAtValue:(id)endValue childKey:(NSString *)childKey; 378 | 379 | /** 380 | * queryEqualToValue: is used to generate a reference to a limited view of the data at this location. 381 | * The FQuery instance returned by queryEqualToValue: will respond to events at nodes with a value equal 382 | * to the supplied argument. 383 | * 384 | * @param value The value that the data returned by this FQuery will have 385 | * @return An Fquery instance, limited to data with the supplied value. 386 | */ 387 | - (FQuery *) queryEqualToValue:(id)value; 388 | 389 | /** 390 | * queryEqualToValue:childKey: is used to generate a reference to a limited view of the data at this location. 391 | * The FQuery instance returned by queryEqualToValue:childKey will respond to events at nodes with a value 392 | * equal to the supplied argument with a name equal to childKey. There will be at most one node that matches because 393 | * child keys are unique. 394 | * 395 | * @param value The value that the data returned by this FQuery will have 396 | * @param childKey The name of nodes with the right value 397 | * @return An FQuery instance, limited to data with the supplied value and the key. 398 | */ 399 | - (FQuery *) queryEqualToValue:(id)value childKey:(NSString *)childKey; 400 | 401 | 402 | /** @name Properties */ 403 | 404 | 405 | /** 406 | * Get a Firebase reference for the location of this query. 407 | * 408 | * @return A Firebase instance for the location of this query. 409 | */ 410 | @property (nonatomic, readonly, strong) Firebase* ref; 411 | 412 | @end 413 | -------------------------------------------------------------------------------- /RNFirebase/Firebase.framework/Headers/FTransactionResult.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Firebase iOS Client Library 3 | * 4 | * Copyright © 2013 Firebase - All Rights Reserved 5 | * https://www.firebase.com 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * 2. Redistributions in binaryform must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY FIREBASE AS IS AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 20 | * EVENT SHALL FIREBASE BE LIABLE FOR ANY DIRECT, 21 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #import 30 | #import "FMutableData.h" 31 | 32 | /** 33 | * Used for runTransactionBlock:. An FTransactionResult instance is a container for the results of the transaction. 34 | */ 35 | @interface FTransactionResult : NSObject 36 | 37 | /** 38 | * Used for runTransactionBlock:. Indicates that the new value should be saved at this location 39 | * 40 | * @param value An FMutableData instance containing the new value to be set 41 | * @return An FTransactionResult instance that can be used as a return value from the block given to runTransactionBlock: 42 | */ 43 | + (FTransactionResult *) successWithValue:(FMutableData *)value; 44 | 45 | 46 | /** 47 | * Used for runTransactionBlock:. Indicates that the current transaction should no longer proceed. 48 | * 49 | * @return An FTransactionResult instance that can be used as a return value from the block given to runTransactionBlock: 50 | */ 51 | + (FTransactionResult *) abort; 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /RNFirebase/Firebase.framework/Headers/FirebaseApp.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | /** 4 | * All Firebase references to the same database share a connection, persistent cache, etc. FirebaseApp 5 | * represents this shared state and can be accessed from any reference via its `app` property. 6 | * It has methods for managing your Firebase connection, etc. 7 | * 8 | * There is a one-to-one relationship between a FirebaseApp instance and a connection to Firebase. 9 | */ 10 | @interface FirebaseApp : NSObject 11 | 12 | /** 13 | * The Firebase client automatically queues writes and sends them to the server at the earliest opportunity, 14 | * depending on network connectivity. In some cases (e.g. offline usage) there may be a large number of writes 15 | * waiting to be sent. Calling this method will purge all outstanding writes so they are abandoned. 16 | * 17 | * All writes will be purged, including transactions and {@link Firebase#onDisconnect} writes. The writes will 18 | * be rolled back locally, perhaps triggering events for affected event listeners, and the client will not 19 | * (re-)send them to the Firebase backend. 20 | */ 21 | - (void)purgeOutstandingWrites; 22 | 23 | 24 | /** 25 | * Shuts down our connection to the Firebase backend until goOnline is called. 26 | */ 27 | - (void)goOffline; 28 | 29 | /** 30 | * Resumes our connection to the Firebase backend after a previous goOffline call. 31 | */ 32 | - (void)goOnline; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /RNFirebase/Firebase.framework/Headers/FirebaseServerValue.h: -------------------------------------------------------------------------------- 1 | @interface FirebaseServerValue : NSObject 2 | 3 | + (NSDictionary *) timestamp; 4 | 5 | @end -------------------------------------------------------------------------------- /RNFirebase/Firebase.framework/Info.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/holmesal/react-native-firebase/37ed6cb77efd65276fc92ebf6890ddd02cb4fb3b/RNFirebase/Firebase.framework/Info.plist -------------------------------------------------------------------------------- /RNFirebase/Firebase.framework/Modules/module.modulemap: -------------------------------------------------------------------------------- 1 | framework module Firebase { 2 | umbrella header "Firebase.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /RNFirebase/Firebase.framework/NOTICE: -------------------------------------------------------------------------------- 1 | Google LevelDB 2 | Copyright (c) 2011 The LevelDB Authors. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | 8 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 9 | 10 | * Neither the name of Google Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 11 | 12 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 13 | 14 | -- 15 | 16 | Square Socket Rocket 17 | Copyright 2012 Square Inc. 18 | 19 | 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 20 | 21 | http://www.apache.org/licenses/LICENSE-2.0 22 | 23 | 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. 24 | 25 | -- 26 | 27 | APLevelDB 28 | Created by Adam Preble on 1/23/12. 29 | Copyright (c) 2012 Adam Preble. All rights reserved. 30 | 31 | Permission is hereby granted, free of charge, to any person obtaining a copy 32 | of this software and associated documentation files (the "Software"), to deal 33 | in the Software without restriction, including without limitation the rights 34 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 35 | copies of the Software, and to permit persons to whom the Software is 36 | furnished to do so, subject to the following conditions: 37 | 38 | The above copyright notice and this permission notice shall be included in 39 | all copies or substantial portions of the Software. 40 | 41 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 42 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 43 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 44 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 45 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 46 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 47 | THE SOFTWARE. 48 | -------------------------------------------------------------------------------- /RNFirebase/RNFirebase.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RNFirebase.swift 3 | // RNFirebase 4 | // 5 | // Created by Alonso Holmes on 10/1/15. 6 | // Copyright (c) 2015 Alonso Holmes. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import Firebase 11 | import FBSDKLoginKit 12 | 13 | /** 14 | 15 | { 16 | :: FirebaseReference 17 | } 18 | 19 | */ 20 | 21 | @objc(RNFirebase) 22 | class RNFirebase: NSObject, RCTInvalidating { 23 | 24 | var refs: [String:Firebase] 25 | 26 | var bridge: RCTBridge! 27 | 28 | override init() { 29 | if Firebase.defaultConfig().persistenceEnabled == false { 30 | Firebase.defaultConfig().persistenceEnabled = true; 31 | } 32 | self.refs = [:]; 33 | super.init(); 34 | } 35 | 36 | // deinit { 37 | // print("deiniting: \(self)"); 38 | // } 39 | 40 | func invalidate() { 41 | for(_, ref) in self.refs { 42 | ref.removeAllObservers(); 43 | } 44 | self.refs = [:] 45 | } 46 | 47 | // Return an existing ref, or create one if none exists 48 | func getRef(path: String) -> Firebase! { 49 | if((self.refs[path]) == nil) { 50 | self.refs[path] = Firebase(url: path); 51 | } 52 | return self.refs[path]; 53 | } 54 | 55 | // Maps string event types to Firebase event types 56 | func getEventType(stringEvent: String) -> FEventType { 57 | switch stringEvent { 58 | case "value": 59 | return FEventType.Value 60 | case "child_added": 61 | return FEventType.ChildAdded 62 | case "child_moved": 63 | return FEventType.ChildMoved 64 | case "child_removed": 65 | return FEventType.ChildRemoved 66 | default: 67 | return FEventType.Value 68 | } 69 | } 70 | 71 | // This will be called over the bridge when an event listener is to be added 72 | // when data changes at this location, we'll emit events. why not use a callback? 73 | // callbacks are designed to be called once (see https://facebook.github.io/react-native/docs/native-modules-ios.html#callbacks) 74 | @objc func on(path: String, event: String) -> Void { 75 | print(String(format: "Listening to path %@ and event %@", path, event)); 76 | let ref = self.getRef(path); 77 | let eventType = self.getEventType(event); 78 | // Listen to this event at this ref 79 | ref.observeEventType(eventType, withBlock: { snap in 80 | let eventName = String(format: "RNFirebase-%@-%@", path, event); 81 | let val:AnyObject! = snap.value; 82 | var key:AnyObject! = snap.key; 83 | if (key == nil) { 84 | key = ""; 85 | } 86 | self.bridge.eventDispatcher.sendAppEventWithName(eventName, body: [ 87 | "data": val, 88 | "key": key 89 | ]); 90 | }) 91 | } 92 | 93 | @objc func keepSynced(path: String, shouldSync: Bool) -> Void { 94 | let ref = self.getRef(path); 95 | print("syncing \(path)"); 96 | ref.keepSynced(shouldSync); 97 | } 98 | 99 | // This will remove a previously-added event listener 100 | // TODO - implement the ability to remove a specific listener 101 | @objc func off(path: String) -> Void { 102 | let ref = self.getRef(path); 103 | ref.removeAllObservers(); 104 | } 105 | 106 | @objc func set(path: String, value: AnyObject, callback: RCTResponseErrorBlock?) -> Void { 107 | let ref = self.getRef(path); 108 | ref.setValue(value, withCompletionBlock: { (err, ref) -> Void in 109 | if let response = callback { 110 | response(err); 111 | } 112 | }) 113 | } 114 | 115 | @objc func update(path: String, value: AnyObject, callback: RCTResponseErrorBlock?) -> Void { 116 | let ref = self.getRef(path); 117 | ref.updateChildValues(value as! [NSObject : AnyObject]) { (err, ref) -> Void in 118 | if let response = callback { 119 | response(err); 120 | } 121 | } 122 | } 123 | 124 | 125 | /** 126 | * Authenticatoin 127 | */ 128 | 129 | @objc func getAuth(path: String, callback: RCTResponseSenderBlock) -> Void { 130 | let ref = self.getRef(path); 131 | self.emitAuthData(path, authData: ref.authData, callback: callback); 132 | } 133 | 134 | @objc func unauth(path: String) -> Void { 135 | let ref = self.getRef(path); 136 | ref.unauth(); 137 | self.emitAuthData(path, authData: nil, callback: nil); 138 | } 139 | 140 | @objc func authWithFacebook(path: String, callback: RCTResponseSenderBlock) -> Void { 141 | let ref = self.getRef(path); 142 | let facebookLogin = FBSDKLoginManager(); 143 | 144 | let existingAuthData:FAuthData? = ref.authData; 145 | 146 | if (existingAuthData != nil) { 147 | self.emitAuthData(path, authData: existingAuthData, callback: callback); 148 | } else { 149 | facebookLogin.logInWithReadPermissions(["email"], fromViewController:nil, handler: { (facebookResult, facebookError) -> Void in 150 | if facebookError != nil { 151 | print("Facebook login failed. Error \(facebookError)"); 152 | let error:NSDictionary = RCTMakeAndLogError("facebookLoginFailed", facebookError, nil); 153 | self.emitAuthError(path, error: error, callback: callback); 154 | } else if facebookResult.isCancelled { 155 | print("Facebook login was cancelled."); 156 | let error:NSDictionary = RCTMakeError("loginCancelled", nil, nil); 157 | self.emitAuthError(path, error: error, callback: callback); 158 | } else { 159 | print("facebook login succeeded!"); 160 | let accessToken = FBSDKAccessToken.currentAccessToken().tokenString; 161 | ref.authWithOAuthProvider("facebook", token: accessToken, withCompletionBlock: { (err, authData) -> Void in 162 | if err != nil { 163 | print("firebase auth error") 164 | let error:NSDictionary = RCTMakeAndLogError("firebase auth error", err, nil); 165 | self.emitAuthError(path, error: error, callback: callback); 166 | } else { 167 | print("auth succeeded") 168 | self.emitAuthData(path, authData: authData, callback: callback); 169 | } 170 | }) 171 | } 172 | }) 173 | } 174 | } 175 | 176 | func emitAuthError(path: String, error: NSDictionary, callback: RCTResponseSenderBlock?) -> Void { 177 | // Call the callback with the error 178 | if (callback != nil) { 179 | callback!([error, NSNull()]); 180 | } 181 | // Send an auth event over the bridge 182 | let eventName = String(format: "RNFirebase-%@-%@", path, "auth"); 183 | self.bridge.eventDispatcher.sendAppEventWithName(eventName, body: [ 184 | "err": error, 185 | "authData": NSNull() 186 | ]); 187 | } 188 | 189 | func emitAuthData(path: String, authData: FAuthData?, callback: RCTResponseSenderBlock?) -> Void { 190 | var safeAuthData:AnyObject; 191 | if (authData == nil) { 192 | safeAuthData = NSNull(); 193 | } else { 194 | safeAuthData = [ 195 | "uid":authData!.uid, 196 | "expires":authData!.expires, 197 | "provider":authData!.provider, 198 | "auth":authData!.auth, 199 | "token":authData!.token, 200 | "providerData":authData!.providerData 201 | ]; 202 | } 203 | if (callback != nil) { 204 | callback!([NSNull(), safeAuthData]); 205 | } 206 | 207 | // Send an auth event over the bridge 208 | let eventName = String(format: "RNFirebase-%@-%@", path, "auth"); 209 | self.bridge.eventDispatcher.sendAppEventWithName(eventName, body: [ 210 | "err": NSNull(), 211 | "authData": safeAuthData 212 | ]); 213 | } 214 | 215 | func applyQueryOperation(ref: Firebase, operation: NSDictionary) -> FQuery{ 216 | let opName = operation["name"]; 217 | switch opName as! NSString { 218 | case "orderByChild": 219 | return ref.queryOrderedByChild(operation["key"] as! String); 220 | case "orderByKey": 221 | return ref.queryOrderedByKey(); 222 | case "orderByValue": 223 | return ref.queryOrderedByValue(); 224 | case "orderByPriority": 225 | return ref.queryOrderedByPriority(); 226 | case "startAtValue": 227 | return ref.queryStartingAtValue(operation["value"]); 228 | case "startAtValueAndKey": 229 | return ref.queryStartingAtValue(operation["value"], childKey: operation["key"] as! String); 230 | case "endAtValue": 231 | return ref.queryEndingAtValue(operation["value"]); 232 | case "endAtValueAndKey": 233 | return ref.queryEndingAtValue(operation["value"], childKey: operation["key"] as! String); 234 | case "equalToValue": 235 | return ref.queryEqualToValue(operation["value"]); 236 | case "equalToValueAndKey": 237 | return ref.queryEqualToValue(operation["value"], childKey: operation["key"] as! String); 238 | case "limitToFirst": 239 | return ref.queryLimitedToFirst(operation["limit"] as! UInt); 240 | case "limitToLast": 241 | return ref.queryLimitedToLast(operation["limit"] as! UInt); 242 | case "limit": 243 | return ref.queryLimitedToNumberOfChildren(operation["limit"] as! UInt); 244 | default: 245 | print("unrecognized query operation: \(opName)"); 246 | return ref 247 | } 248 | } 249 | 250 | @objc func onQuery(path: String, event: String, operations: Array, eventKey: String) -> Void { 251 | print(operations); 252 | let ref = self.getRef(path); 253 | var query = FQuery(); 254 | // Apply query operations 255 | for op in operations { 256 | // let operation:Dictionary = op; 257 | print(op) 258 | query = self.applyQueryOperation(ref, operation: op); 259 | } 260 | // Add the event listener to the query 261 | query.observeEventType(self.getEventType(event), withBlock: { snap in 262 | let val:AnyObject! = snap.value; 263 | var key:AnyObject! = snap.key; 264 | if (key == nil) { 265 | key = ""; 266 | } 267 | self.bridge.eventDispatcher.sendAppEventWithName(eventKey, body: [ 268 | "data": val, 269 | "key": key 270 | ]); 271 | }) 272 | } 273 | 274 | } 275 | -------------------------------------------------------------------------------- /RNFirebase/RNFirebaseBridge.m: -------------------------------------------------------------------------------- 1 | // 2 | // RNFirebase.m 3 | // RNFirebase 4 | // 5 | // Created by Alonso Holmes on 10/1/15. 6 | // Copyright (c) 2015 Alonso Holmes. All rights reserved. 7 | // 8 | 9 | #import "RCTBridgeModule.h" 10 | #import "RCTLog.h" 11 | 12 | @interface RCT_EXTERN_MODULE(RNFirebase, NSObject) 13 | 14 | RCT_EXTERN_METHOD(on:(NSString *)path event:(NSString *)event); 15 | RCT_EXTERN_METHOD(keepSynced:(NSString *)path shouldSync:(BOOL)shouldSync); 16 | RCT_EXTERN_METHOD(off:(NSString *)path); 17 | RCT_EXTERN_METHOD(set:(NSString *)path value:(id)value callback:(id)callback); 18 | RCT_EXTERN_METHOD(update:(NSString *)path value:(id)value callback:(id)callback); 19 | RCT_EXTERN_METHOD(getAuth:(NSString *)path callback:(RCTResponseSenderBlock)callback); 20 | RCT_EXTERN_METHOD(unauth:(NSString *)path); 21 | RCT_EXTERN_METHOD(authWithFacebook:(NSString *)path callback:(RCTResponseSenderBlock)callback); 22 | 23 | RCT_EXTERN_METHOD(onQuery:(NSString *)path event:(NSString *)event operations:(NSArray *)operations eventKey:(NSString *)eventKey); 24 | 25 | 26 | @end -------------------------------------------------------------------------------- /RNFirebaseDataSnapshot.js: -------------------------------------------------------------------------------- 1 | // https://www.firebase.com/docs/web/api/datasnapshot 2 | 3 | class FirebaseDataSnapshot { 4 | 5 | constructor(data, ref) { 6 | this.data = data; 7 | this._ref = ref; 8 | } 9 | 10 | notImplemented() { 11 | console.error(`${arguments.callee.caller.name} is not implemented :-(`); 12 | } 13 | 14 | val() { 15 | return this.data; 16 | } 17 | key() { 18 | return this.ref().key(); 19 | } 20 | 21 | ref() { 22 | return this._ref; 23 | } 24 | 25 | // TODO - implement these methods 26 | exists() { 27 | this.notImplemented() 28 | } 29 | child() { 30 | this.notImplemented() 31 | } 32 | forEach() { 33 | this.notImplemented() 34 | } 35 | hasChild() { 36 | this.notImplemented() 37 | } 38 | hasChildren() { 39 | this.notImplemented() 40 | } 41 | name() { 42 | this.notImplemented() 43 | } 44 | numChildren() { 45 | this.notImplemented() 46 | } 47 | getPriority() { 48 | this.notImplemented() 49 | } 50 | exportVal() { 51 | this.notImplemented() 52 | } 53 | } 54 | 55 | module.exports = FirebaseDataSnapshot; -------------------------------------------------------------------------------- /RNFirebaseQuery.js: -------------------------------------------------------------------------------- 1 | var _ = require('lodash') 2 | var React = require('react-native'); 3 | var FirebaseDataSnapshot = require('./RNFirebaseDataSnapshot') 4 | var {RNFirebase} = React.NativeModules; 5 | var {NativeAppEventEmitter} = React; 6 | /** 7 | 8 | Basic approach - serialize the query operations, pass them over the bridge, and apply them on the objective-c side. 9 | 10 | Good first task - create a superclass for methods like .on() and .getEventKey() to reduce the amount of copy pasta between this class and RNFirebase 11 | 12 | */ 13 | 14 | class FirebaseQuery { 15 | 16 | constructor(ref) { 17 | this.ref = ref; 18 | // We'll keep track of query operations and order in an array, which we'll pass over the bridge 19 | this.operations = []; 20 | } 21 | 22 | notImplemented() { 23 | console.error(`${arguments.callee.caller.name} is not implemented :-(`); 24 | } 25 | 26 | serializeSingleOperation(op) { 27 | return _.map(op, (v, k) => { 28 | if (k != 'name'){ 29 | return `${k}=${v},` 30 | } 31 | }) 32 | } 33 | 34 | serializeOperations() { 35 | return _.map(this.operations, (o) => { 36 | return `:${o.name}(${this.serializeSingleOperation(o)}):` 37 | }); 38 | } 39 | 40 | // Given an event string type, get the event key for use over the bridge 41 | getEventKey(event) { 42 | return `RNFirebase-${this.ref.toString()}-${event}-${this.serializeOperations()}`; 43 | } 44 | 45 | // Ref-like operations 46 | on(eventType, callback) { 47 | let eventKey = this.getEventKey(eventType) 48 | RNFirebase.onQuery(this.ref.toString(), eventType, this.operations, eventKey); 49 | // Listen for events emitted on this ref 50 | NativeAppEventEmitter.addListener(eventKey, (ev) => { 51 | // If this data has a different key, then we're dealing with a child 52 | console.info(ev, this) 53 | if (ev.key === "") { 54 | ev.key = null; 55 | } 56 | if (ev.key !== this.ref.key()) { 57 | var ref = this.ref.child(ev.key()); 58 | } else { 59 | var ref = this; 60 | } 61 | this.handleEvent(ev, ref, callback); 62 | }); 63 | } 64 | 65 | // Given some data passed over the bridge, create a data snapshot and call the registered callback 66 | handleEvent(ev, ref, callback) { 67 | // console.debug('got event', ev); 68 | let snap = new FirebaseDataSnapshot(ev.data, ref); 69 | callback(snap); 70 | } 71 | 72 | off() { 73 | this.notImplemented() 74 | } 75 | 76 | once() { 77 | this.notImplemented() 78 | } 79 | 80 | ref() { 81 | return this.ref; 82 | } 83 | 84 | // Query methods 85 | 86 | orderByChild(key) { 87 | this.operations.push({ 88 | name: 'orderByChild', 89 | key: key 90 | }); 91 | return this; 92 | } 93 | 94 | orderByKey(key) { 95 | this.operations.push({ 96 | name: 'orderByKey' 97 | }); 98 | return this; 99 | } 100 | 101 | orderByValue() { 102 | this.operations.push({ 103 | name: 'orderByValue' 104 | }); 105 | return this; 106 | } 107 | 108 | orderByPriority() { 109 | this.operations.push({ 110 | name: 'orderByPriority' 111 | }); 112 | return this; 113 | } 114 | 115 | startAt(value, key) { 116 | if (key) { 117 | this.operations.push({ 118 | name: 'startAtValueAndKey', 119 | value: value, 120 | key: key 121 | }); 122 | } else { 123 | this.operations.push({ 124 | name: 'startAtValue', 125 | value: value 126 | }); 127 | } 128 | return this; 129 | } 130 | 131 | endAt(value, key) { 132 | if (key) { 133 | this.operations.push({ 134 | name: 'endAtValueAndKey', 135 | value: value, 136 | key: key 137 | }); 138 | } else { 139 | this.operations.push({ 140 | name: 'endAtValue', 141 | value: value 142 | }); 143 | } 144 | return this; 145 | } 146 | 147 | equalTo(value, key) { 148 | if (key) { 149 | this.operations.push({ 150 | name: 'equalToValueAndKey', 151 | value: value, 152 | key: key 153 | }); 154 | } else { 155 | this.operations.push({ 156 | name: 'equalToValue', 157 | value: value 158 | }); 159 | } 160 | return this; 161 | } 162 | 163 | limitToFirst(limit) { 164 | this.operations.push({ 165 | name: 'limitToFirst', 166 | limit: limit 167 | }); 168 | return this; 169 | } 170 | 171 | limitToLast(limit) { 172 | this.operations.push({ 173 | name: 'limitToLast', 174 | limit: limit 175 | }); 176 | return this; 177 | } 178 | 179 | limit(limit) { 180 | this.operations.push({ 181 | name: 'limit', 182 | limit: limit 183 | }); 184 | return this; 185 | } 186 | } 187 | 188 | module.exports = FirebaseQuery; -------------------------------------------------------------------------------- /RNFirebaseTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | alonsoholmes.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /RNFirebaseTests/RNFirebaseTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RNFirebaseTests.swift 3 | // RNFirebaseTests 4 | // 5 | // Created by Alonso Holmes on 10/2/15. 6 | // Copyright (c) 2015 Alonso Holmes. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import XCTest 11 | 12 | class RNFirebaseTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | XCTAssert(true, "Pass") 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measureBlock() { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /example.js: -------------------------------------------------------------------------------- 1 | var Firebase = require('./RNFirebase'); 2 | 3 | var ref = new Firebase('https://podcast.firebaseio.com/test'); 4 | 5 | ref.on('child_added', (snap) => { 6 | console.info('got value!'); 7 | console.info(snap.val()); 8 | }); 9 | 10 | console.info(`the path for this ref is ${ref.toString()}`); -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-firebase", 3 | "version": "0.0.2", 4 | "description": "A react-native module that wraps the native firebase iOS SDK", 5 | "main": "RNFirebase.js", 6 | "scripts": { 7 | "test": "npm test" 8 | }, 9 | "keywords": [ 10 | "react", 11 | "native", 12 | "react-native", 13 | "firebase" 14 | ], 15 | "author": "alonso holmes ", 16 | "license": "MIT", 17 | "dependencies": { 18 | "console-shim": "^1.0.3", 19 | "firebase": "^2.3.1", 20 | "lodash": "^3.10.1" 21 | }, 22 | "peerDependencies": { 23 | "react-native": ">=0.11.4" 24 | } 25 | } 26 | --------------------------------------------------------------------------------