2015-04-03 13 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就会生成一个唯一键。