在允许使用解析ios注册之前,请检查唯一的电话号码(Check for unique phone number before allowed to sign up with parse ios)

编程入门 行业动态 更新时间:2024-10-24 07:34:05
在允许使用解析ios注册之前,请检查唯一的电话号码(Check for unique phone number before allowed to sign up with parse ios)

我已经将我的应用程序与解析框架集成,并在注册过程中添加了一些额外的字段,其中一个是电话号码。 我想检查以确保输入的电话号码在被允许注册之前是唯一的,就像解析用户名和电子邮件一样。 但是,我无法在任何地方找到有关如何操作的文档。

我已经尝试在PFUser上运行查询以检查输入的电话号码是否在Users表中,但查询将不起作用(结果总是为nil),除非它包含在signUpInBackgroundWithBlock代码中。 但是,无论查询结果如何,在此处放置查询仍会上传要解析的信息。 有没有人找到办法做到这一点? 提前致谢!

I've integrated my app with the parse framework and have added a few extra fields during the sign up process, one of those being phone number. I'd like to check to make sure the phone number entered is unique prior to them being allowed to sign up, like parse does for username and email. However, I can't find documentation anywhere on how to do so.

I've tried running a query on PFUser to check if the entered phone number is in the Users table but the query won't work (results are always nil) unless its included in the signUpInBackgroundWithBlock of code. However, putting the query here still uploads the info to parse no matter the results of the query. Has anyone found a way to do this? Thanks in advance!

最满意答案

如果您分享您的查询会有所帮助,但类似下面的内容应该可以解决问题:

PFQuery *query = [PFQuery queryWithClassName:@"User"]; [query whereKey:@"phoneNo" equalTo:@"0123456"]; [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) { if (!error) { // The find succeeded. if (objects.count == 0) { //Allow Number to be saved } else { //Give warning that the number is already in use } } else { // Log details of the failure NSLog(@"Error: %@ %@", error, [error userInfo]); } }];

}

Would be helpful if you share your query but something like the following should probably do the trick:

PFQuery *query = [PFQuery queryWithClassName:@"User"]; [query whereKey:@"phoneNo" equalTo:@"0123456"]; [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) { if (!error) { // The find succeeded. if (objects.count == 0) { //Allow Number to be saved } else { //Give warning that the number is already in use } } else { // Log details of the failure NSLog(@"Error: %@ %@", error, [error userInfo]); } }];

}

更多推荐

本文发布于:2023-04-29 10:14:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1335948.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:请检查   电话号码   unique   Check   ios

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!