Note that there are some explanatory texts on larger screens.

plurals
  1. POiOS6 social framework bring up No Account Alert
    primarykey
    data
    text
    <p>Similar to <a href="https://stackoverflow.com/questions/14145322/ios-6-social-framework-not-going-to-settings-or-no-alert">iOS 6 Social framework not going to settings or no alert</a> but i am trying to use SLRequest:</p> <p>I am trying to bring up the alert "No Facebook Account" when the user has not logged in to Facebook in the Settings. I have found that the alert appear AFTER you present the SLComposeViewController, rather than inside the if statement.</p> <pre><code>if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) { SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook]; //setup controller and callback code [self presentViewController:controller animated:YES completion:nil]; } </code></pre> <p>However, I am trying to use SLRequest and i dont want to present the SLComposeViewController, but instead, after checking the accounts, popup the alert. My code is here:</p> <pre><code>- (void)postImageFB { if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) { NSLog(@"can post"); } else { NSLog(@"cant post"); } ACAccountStore *accountStore = [[ACAccountStore alloc] init]; ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook]; NSArray *accountsArray = [accountStore accountsWithAccountType:accountType]; NSLog(@"accounts: %i", [accountsArray count]); // Is it possible to popup the alert here if accounts = 0? NSDictionary *options = @{ ACFacebookAppIdKey: @"123456789", ACFacebookPermissionsKey: @[@"publish_stream"], ACFacebookAudienceKey: ACFacebookAudienceFriends }; [accountStore requestAccessToAccountsWithType:accountType options:options completion:^(BOOL granted, NSError *error) { if(granted) { NSArray *accountsArray = [accountStore accountsWithAccountType:accountType]; if ([accountsArray count] &gt; 0) { ACAccount *facebookAccount = [accountsArray objectAtIndex:0]; NSDictionary *parameters = @{@"message": @"testing"}; SLRequest *facebookRequest = [SLRequest requestForServiceType:SLServiceTypeFacebook requestMethod:SLRequestMethodPOST URL:[NSURL URLWithString:@"https://graph.facebook.com/me/photos"] parameters:parameters]; [facebookRequest addMultipartData: [self getImageDataFromPlistWithFilename:@"image1.png"] withName:@"source" type:@"multipart/form-data" filename:@"TestImage"]; facebookRequest.account = facebookAccount; [facebookRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) { if (error) { NSLog(@"%@",error.description); } else { NSLog(@"responedata:%@", [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]); } }]; } } }]; } </code></pre>
    singulars
    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