Today, we’ve got two awesome releases for iOS: Large File Support and Facebook Users.
Large File Support
We already support passing in NSData as attributes on a PFObject. This is handy for small bits of data, but, we don’t recommend it for large data, since that can impact download time when loading the object from our servers.
For large data, you should use our new PFFile class. Head on over to the documentation and give it a try!
With this class, you’ll be able to easily upload large files directly to Parse, and then associate it with PFObjects. The nice thing is now you can have direct control of when the client starts uploading or downloading the PFFile objects, and these events don’t need to happen in conjunction with saving the PFObject.
As an example, this is how you can save a photo as a PFFile object, then associate it with a PFObject:
NSData *imageData = UIImagePNGRepresentation(image);
PFFile *imageFile = [PFFile fileWithName:@"image.png" data:imageData];
[imageFile save];
PFObject *userPhoto = [[PFObject alloc] initWithClassName:@"UserPhoto"];
[userPhoto setObject:@"My trip to Hawaii!" forKey:@"imageName"];
[userPhoto setObject:imageFile forKey:@"imageFile"];
[userPhoto save];
View the full documentation for large file support
Facebook Users
With Parse, it’s now a cinch to add Facebook authentication to your mobile app. We think it’s even easier than using the official Facebook SDK itself!
If you upgrade to the latest Parse SDK, it now includes a copy of the Facebook SDK. PFUser now has native support for authenticating via Facebook, which will create or log in PFUser objects automatically. Head on over to the Parse Facebook documentation to see how easy it is.
For example, this is the code to sign up or log in a Facebook user:
[PFUser logInWithFacebook:permissions block:^(PFUser *user, NSError *error) {
if (!user) {
NSLog(@"Uh oh. The user cancelled the Facebook login.");
} else if (user.isNew) {
NSLog(@"Facebook id @% signed up and logged in!", user.facebookId);
} else {
NSLog(@"Facebook id @% logged in!", user.facebookId);
}
}];
The following happens with this code:
- The user is shown the Facebook login dialog.
- The user authenticates via Facebook, and your app receives a callback.
- Our library receives the Facebook data and saves it to a
PFUser. If it’s a new user based on the Facebook ID, then that user is created, if not, they are simply logged in.
What used to amount to a whole pile of server and client side code is now reduced to a few lines of Parse SDK code.
View the full documentation for Facebook integration