gpt4 book ai didi

ios - 当应用程序权限被禁用时,SLComposeViewController 出现问题

转载 作者:行者123 更新时间:2023-11-29 04:06:14 25 4
gpt4 key购买 nike

我正在使用 SLComposeViewController 将文章发布到 facebook 墙。当在设备设置中关闭 facebook 的应用程序权限时,SLComposeViewController 仍然可以通过将文章发布到 facebook 墙来工作。这是 SDK 问题吗?

    SLComposeViewController *facebookViewController=[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
{
SLComposeViewControllerCompletionHandler __block completionHandler=^(SLComposeViewControllerResult result)
{

[facebookViewController dismissViewControllerAnimated:YES completion:nil];

switch(result){
case SLComposeViewControllerResultCancelled:
default:
{
[[[UIAlertView alloc] initWithTitle:@"Facebook"
message:@"Action Cancelled"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil]
show];

[self dismissView];

}
break;
case SLComposeViewControllerResultDone:
{
[[[UIAlertView alloc] initWithTitle:@"Facebook"
message:@"Posted to Facebook successfully"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil]
show];

[self dismissView];

}
break;
}};

[facebookViewController addImage:_shareImage];
[facebookViewController setInitialText:_shareTitle];
[facebookViewController addURL:_shareLink];
[facebookViewController setCompletionHandler:completionHandler];

[self.dashboard presentViewController:facebookViewController animated:YES completion:nil];

}

最佳答案

我自己找到了答案。检查下面的代码

  if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"6.0"))
{
ACAccountStore *accountStore=[[ACAccountStore alloc]init];
ACAccountType * facebookAccountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];

// At first, we only ask for the basic read permission
NSArray * permissions = @[@"publish_stream"];

NSDictionary * dict = @{ACFacebookAppIdKey : @"facebook_appid", ACFacebookPermissionsKey : permissions, ACFacebookAudienceKey : ACFacebookAudienceEveryone};

[accountStore requestAccessToAccountsWithType:facebookAccountType options:dict completion:^(BOOL granted, NSError *error) {
if (granted && error == nil)
{

SLComposeViewController *facebookViewController=[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
SLComposeViewControllerCompletionHandler __block completionHandler=^(SLComposeViewControllerResult result)
{

[facebookViewController dismissViewControllerAnimated:YES completion:nil];

switch(result){
case SLComposeViewControllerResultCancelled:
default:
{
[self dismissView];

}
break;
case SLComposeViewControllerResultDone:
{
[[[UIAlertView alloc] initWithTitle:@"Facebook"
message:@"Posted to Facebook successfully"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil]
show];

[self dismissView];

}
break;
}};

[facebookViewController addImage:_shareImage];
[facebookViewController setInitialText:_shareTitle];
[facebookViewController addURL:_shareLink];
[facebookViewController setCompletionHandler:completionHandler];

[self.dashboard presentViewController:facebookViewController animated:YES completion:nil];
}
else
{
dispatch_async(dispatch_get_main_queue(), ^{
[self dismissView];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message: @"App Permissions disabled in facebook settings."
delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];


});
}
}];

关于ios - 当应用程序权限被禁用时,SLComposeViewController 出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15157982/

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