Swift:如果孩子的观察员被移除,则不会调用Firebase身份验证观察员
问题描述:
假设ref = Firebase(url: "your firebase url")
。
REF的孩子将是childRef = ref.childByAppendingPath("child")
Swift:如果孩子的观察员被移除,则不会调用Firebase身份验证观察员
如果我有ref.observeAuthEventWithBlock
听在裁判认证的变化,然后我用childRef.removeAllObservers()
,在裁判的权威性观察者不再侦听更改。
这是为什么?
答
我制作了一个小的应用程序复制的问题(ObjC代码遵循)
以观察auth'ing的代码是:
[myRootRef observeAuthEventWithBlock:^(FAuthData *authData) {
NSLog(@"got an auth event");
}];
,我们有子节点
child = [myRootRef childByAppendingPath:@"child_path"];
则初始AUTH是
[myRootRef authUser:@"[email protected]" password:@"pw" withCompletionBlock:^(NSError *error, FAuthData *authData) {
NSLog(@"authentication 1 success");
[child removeAllObservers];
[self doAuth];
}
}];
的doAuth方法简单权威性的其他用户,并输出“验证成功2”
got an auth event
got an auth event
authentication 1 success
authentication 2 success
因此,大家可以看到它的工作如广告 - 我无法复制的问题。我的猜测是错误可能在于你的代码中的其他地方。
好的,会检查其他可能的原因。谢谢! – rishramanathan