Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit a92cb06

Browse files
committed
Updated push for ios to return the key created. Returned key in an object to be consistent with other resolve methods throughout the code. Incorporated other commit for android code, but added the key-in-object consistency to that also.
1 parent 8fcf2d3 commit a92cb06

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

firebase.android.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,11 @@ firebase.removeEventListener = function (listener, path) {
227227
firebase.push = function (path, val) {
228228
return new Promise(function (resolve, reject) {
229229
try {
230-
instance.child(path).push().setValue(firebase.toHashMap(val));
231-
resolve();
230+
var pushInstance = instance.child(path).push();
231+
pushInstance.setValue(firebase.toHashMap(val));
232+
resolve({
233+
key: pushInstance.getKey()
234+
});
232235
} catch (ex) {
233236
console.log("Error in firebase.push: " + ex);
234237
reject(ex);

firebase.ios.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,11 @@ firebase.addValueEventListener = function (updateCallback, path) {
182182
firebase.push = function (path, val) {
183183
return new Promise(function (resolve, reject) {
184184
try {
185-
instance.childByAppendingPath(path).childByAutoId().setValue(val);
186-
resolve();
185+
var ref = instance.childByAppendingPath(path).childByAutoId();
186+
ref.setValue(val);
187+
resolve({
188+
key: ref.key
189+
});
187190
} catch (ex) {
188191
console.log("Error in firebase.push: " + ex);
189192
reject(ex);

0 commit comments

Comments
 (0)