On the top I have a company id
and then I have client id
and then I have time stamp
and then I have data , so I want to check if this company id is present i want to add new client under this company if company id is not present I want to add new node with like above image. what I am doing here Its add a new node every time
LoginResponse *loginResponseObj = [Utililities loadLoginResponseObjectWithKey:LOGIN_RESPONSE_KEY_FOR_USERDEFAULT];
NSMutableDictionary *dataDict = [NSMutableDictionary dictionary];
[dataDict setValue:[NSNumber numberWithFloat:[LocationManager sharedManager].location.coordinate.latitude] forKey:@"lat"];
[dataDict setValue:[NSNumber numberWithFloat:[LocationManager sharedManager].location.coordinate.latitude] forKey:@"lng"];
NSMutableDictionary *timeStampDict = [NSMutableDictionary dictionary];
NSTimeInterval timeInSeconds = [[NSDate date] timeIntervalSince1970];
[timeStampDict setValue:dataDict forKey:[NSString stringWithFormat:@"%.0f",timeInSeconds]];
NSMutableDictionary *fcmDict = [NSMutableDictionary dictionary];
[fcmDict setValue:timeStampDict forKey:loginResponseObj.workerInfo.fcmId];
NSMutableDictionary *companyDict = [NSMutableDictionary dictionary];
[companyDict setValue:fcmDict forKey:[NSString stringWithFormat:@"%.0f",loginResponseObj.workerInfo.companyId]];
[[self.ref child:[NSString stringWithFormat:@"%.0f",loginResponseObj.workerInfo.companyId]]setValue:companyDict];