Note that there are some explanatory texts on larger screens.

plurals
  1. POPhoto Not Uploading on Check In Using Facebook iOS
    primarykey
    data
    text
    <p>So I'm creating an iPhone app that needs to be able to upload a photo when the user checks into a location using the Facebook Graph API.</p> <p>Right now my code is this:</p> <pre><code>if (![delegate.facebook isSessionValid]) [delegate.facebook authorize:[NSArray arrayWithObjects:@"publish_stream", @"offline_access", @"publish_checkins", nil]]; parameters = [NSMutableDictionary dictionaryWithObjectsAndKeys:[placeDictionary objectForKey:@"id"] , @"place", serialisedCoordinates, @"coordinates", message, @"message", pickedImage, @"picture", @"Via the official REDACTED app", @"application", nil]; [delegate.facebook requestWithGraphPath:@"me/checkins" andParams:parameters andHttpMethod:@"POST" andDelegate:fbCheckInResultHandler]; </code></pre> <p>Where 'pickedImage' is the UIImage returned from a UIImagePickerController.</p> <p>Even when I pick an image (i.e., pickedImage != nil), no picture is uploaded when checked in. The check in appears on Facebook with the message, coordinates and app information, just no image.</p> <p>Really hope someone can help.</p> <p>Cheers, Kiran</p> <p>Here is the whole function that is being called when a checkin is made:</p> <pre><code>-(void)fbPostCheckInWithMessage:(NSString *)message andFriends:(NSArray *)friends { if (![delegate.facebook isSessionValid]) { NSLog(@"Session invalid"); [delegate.facebook authorize:[NSArray arrayWithObjects:@"publish_stream", @"offline_access", @"publish_checkins", nil]]; } else { NSLog(@"Session valid"); } NSMutableString *friendsIDString; friendsIDString = [NSMutableString stringWithFormat:@"%@", [[friends objectAtIndex:0] userID]]; if ([friends count] &gt; 1) { for (User *f in taggedFriends) { if (f != [taggedFriends objectAtIndex:0]) { [friendsIDString appendString:[NSString stringWithFormat:@", %@", f.userID]]; } } } NSLog(@"Tagged Friends: %@", friendsIDString); SBJSON *jsonWriter = [SBJSON new]; NSMutableDictionary *locationDictionary = [NSMutableDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"%f", userLocation.coordinate.latitude], @"latitude", [NSString stringWithFormat:@"%f", userLocation.coordinate.longitude], @"longitude", nil]; NSString *serialisedCoordinates = [jsonWriter stringWithObject:locationDictionary]; NSData *pictureData = UIImagePNGRepresentation(pickedImage); NSLog(@"picture: %@", pictureData); NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithObjectsAndKeys:[placeDictionary objectForKey:@"id"] , @"place", serialisedCoordinates, @"coordinates", pictureData, @"message", pickedImage, @"picture", @"Via the official REDACTED app", @"application", nil]; [delegate.facebook requestWithGraphPath:@"me/checkins" andParams:parameters andHttpMethod:@"POST" andDelegate:fbCheckInResultHandler]; } </code></pre> <p>I am using the friendsIDString to get the IDs of the friends the user with. I've removed this functionality from the example here because it was all commented out because I was trying to isolate what was causing the problem (which was the photo tagging). Just wanted to clear that up.</p> <p>--UPDATE-- Here's how I'm setting pickedImage. I use the delegate methods from the UIImagePickerController:</p> <pre><code>-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo { NSLog(@"Picked image"); pickedImage = [[UIImage alloc] init]; pickedImage = image; [imagePickerController dismissModalViewControllerAnimated:YES]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload