Objective c Firebase OSX使用电子邮件/密码登录
我正在为现有firebase设置一个非常基本的OSX应用程序,该应用程序带有SimpleLogin和电子邮件/密码验证 这是我正在使用的代码Objective c Firebase OSX使用电子邮件/密码登录,objective-c,macos,firebase,Objective C,Macos,Firebase,我正在为现有firebase设置一个非常基本的OSX应用程序,该应用程序带有SimpleLogin和电子邮件/密码验证 这是我正在使用的代码 - (void) applicationDidFinishLaunching:(NSNotification *)notification { Firebase* ref = [[Firebase alloc] initWithUrl:@"https://myapp.firebaseio.com"]; FirebaseSimpleLogin* a
- (void) applicationDidFinishLaunching:(NSNotification *)notification {
Firebase* ref = [[Firebase alloc] initWithUrl:@"https://myapp.firebaseio.com"];
FirebaseSimpleLogin* authClient = [[FirebaseSimpleLogin alloc] initWithRef:ref];
[authClient loginWithEmail:@"myemail@mydomain.com" andPassword:@"mypassword"
withCompletionBlock:^(NSError* error, FAUser* user) {
if (error != nil) {
// There was an error logging in to this account
NSLog(@"authClient login error: %@", error);
} else {
NSLog(@"Login success.");
}
}];
}
登录成功,我看到了日志输出。但是,“FAUser*用户”为零。怎么用?为什么?
在线搜索/现有问题没有帮助
有什么想法吗
**更新**
iOS中的代码与预期的一样。这只是OSX的问题吗
**更新2**
我在我的OSX项目中直接编译了Firebase/Objective-C简单登录服务(似乎只引用iOS)的源代码,发现登录服务尝试在OSX上存储密钥链数据时出现了“重复项”错误代码
keychain保存操作之后的源代码将继续返回空用户。我认为这里有一个逻辑错误,因为只要不是成功代码,if语句就会计算为true(跳过重复项的特殊情况):
无论如何,通过修改这一小块代码来满足我的需要,我可以继续工作。是的,你说得对。这是一个访问钥匙链的错误 要清除您自己机器上的错误,您可以转到Keychain Access,在右上角搜索“firebase”。您应该得到一个名为
https://auth.firebase.com
。点击它。检查Account
字段是否显示Firebase\
,然后继续删除它。下次启动应用程序时,您必须再次登录
当您尝试同时多次点击同一个钥匙链项目时,似乎会出现这种情况。多次缓慢地访问密钥链似乎没有问题,因此,除非有人在同一台机器上验证许多相同的应用程序,否则您不应该出现错误。(如果你能以其他方式击中它,请分享!)
if (status != noErr) {
user = nil;
}
else if (status == errSecDuplicateItem) {
// TODO: log an error?
user = nil;
}