2015-04-03 27 views
0

火力地堡更新的孩子是通過不刪除舊的價值觀,但在Web和Android它將刪除舊的數據,並增加了在iOS的更新updateChildValues。看起來像在火力點方面的錯誤不能確定。火力地堡updateChildValues工作在IOS而不是在網絡和Android

的iOS代碼

self.viewFirebase = [[Firebase alloc] initWithUrl: [NSString stringWithFormat:@"%@messages/%@",fOrgURL,self.userHash]]; 
Firebase *insertData = [self.viewFirebase childByAutoId]; 
Firebase *notificationRef = [[Firebase alloc] initWithUrl: [NSString stringWithFormat:@"%@notifications/%@/%@/",fOrgURL,fromHash,self.userHash]]; 
    NSDictionary *dummyData = @{@"a":@"0"}; 
    NSDictionary *messageIDDict = @{insertData.key : dummyData}; 

    Firebase *lastData = [notificationRef childByAppendingPath:@"inbox/"]; 

    NSDictionary *lastSentData = @{@"msgs":messageIDDict,@"sender": toHash,@"lastSender":[[AuthDataStore sharedAuth] pushKey], @"text" : messageInput, @"ack":@"ok", @"time":[NSNumber numberWithInt:timeStamp]}; 
    [lastData updateChildValues:lastSentData]; 

的Android代碼

//Note: receiverinbox and notificationMsgs are hashmaps; 
Firebase mNotificationref=new Firebase(FIREBASE_URL+"/notifications"); 
receiverinbox.put("sender",userid); 
receiverinbox.put("text", input)); 
receiverinbox.put("time", Utilities.getCurrentTime()); 
receiverinbox.put("ack","no"); 
notificationMsgs.put(messagepush,placeholder); // messagepush is firebase pushid, placeholder is not null 
receiverinbox.put("msgs",notificationMsgs); 

mNotificationref.child(chatwithid).child(userhash).child("inbox").updateChildren(receiverinbox); 

角JS

var msgsVal = {}; 
msgsval[msgId] = {placeholder : 1}; // MsgID is firebase pushkey 
var rcvrNotificationConvRef = new Firebase(sessionURL + '/notifications/' + $scope.ustoId + '/' + msgkey); 
rcvrNotificationConvRef.child('inbox').update({ 
sender: sender, 
time: time, 
text: msgintext, 
ack: 'No', 
lastSender: $scope.usLoggedUserId, 
msgs : msgsVal 
}); 
+0

你能證明你在這三個平臺上運行的代碼?請參閱http://stackoverflow.com/help/mcve。 – 2015-04-03 16:39:36

+0

已添加代碼。讓我知道如果這足夠。 – 2015-04-07 07:08:06

+0

我很快寫下了這個小提琴:http://jsfiddle.net/mngm289m/。你會看到節點最初是空的(它在輸出中記錄了'null'),然後從調用'ref.set'獲得三個值,最後用'ref.update'覆蓋其中的兩個值。如果你看到不同的行爲,你可以修改小提琴來重現你擁有的東西嗎? – 2015-04-07 14:14:10

回答

0

在Android中,我們可以使用push()方法將數據追加到多用戶應用程序的列表。每當將新的子項添加到指定的Firebase引用時,push() method就會生成一個唯一鍵。