gpt4 book ai didi

ios - 用户注册期间,Firebase将镜像上传到存储

转载 作者:行者123 更新时间:2023-12-01 20:00:11 25 4
gpt4 key购买 nike

我是Firebase的新手,我一直在关注他们的文档here
但是,我尝试过的任何方法似乎都无效。

我正在尝试做的是:

1)注册用户 -Works

2)在注册过程中让用户选择个人资料图片-不起作用。

代码:

- (void) registerNewUser:(FIRUser *)user

{
FIRUser *currentUser = [FIRAuth auth].currentUser;
NSString *email = emailAddressTxtField.text;
NSString *password = passwordTxtField.text;
NSString *username = usernameTxtField.text;
[[FIRAuth auth]
createUserWithEmail:email
password:password
completion:^(FIRUser *_Nullable user,
NSError *_Nullable error)
{
if (error)
{
NSLog(@"%@", error.localizedDescription);
return;
}
else
{
////ASSIGN NEW USER THEIR NAME////
self.databaseRef = [[FIRDatabase database] reference];
[[[databaseRef child:@"users"] child:user.uid]
setValue:@{@"name": username}];
}
}];
////ESTABLISHED A USER, SO LET'S ASSIGN THEIR PIC TO THEM////
if (profilePicImageView.image)
{
FIRStorageReference *profilePicRef = [[storageRef child:@"images/profilePicture.jpg"] child:currentUser.uid];
FIRStorageMetadata *metadata = [[FIRStorageMetadata alloc] init];
metadata.contentType = @"image/jpeg";
NSData *imageData = UIImageJPEGRepresentation(self.profilePicImageView.image, 0.8);
NSLog(@"metadata from image: %@", metadata);

[profilePicRef putData:imageData metadata:metadata completion:^(FIRStorageMetadata *metadata, NSError *error)
{
if (error != nil)
{
NSString *profileImageURL = metadata.downloadURL.absoluteString;
NSLog(@"Profile Image URL from image: %@", profileImageURL);
[ProgressHUD showSuccess:[NSString stringWithFormat:@"%@ Successfully Registered!!", username]];
[self.segmentedLoginRegister setSelectedSegmentIndex:0];
[self checkSegmentedControl];
[ProgressHUD showSuccess:[NSString stringWithFormat:@"Welcome %@!", username]];
}
else
{
NSLog(@"Failed to Register User with profile image");
}
}];
}
}

附加信息:

照片仅来自用户设备的相机胶卷
调试区域打印:

[通用]创建未知类型的图像格式是错误的

最佳答案

我的猜测是profilePicImageView.image实际上不包含有效的图像对象。

关于ios - 用户注册期间,Firebase将镜像上传到存储,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40137707/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com