這樣做我有Facebook的共享在我的iOS應用程序工作正常時FB沒有安裝。並且我已經安裝了fb以使用最新的api(4.7.x),現在共享並不起作用。我檢查了我是否擁有publish_actions權限(我在調用此方法之前執行了此操作,在開放圖形設置,操作類型和功能中檢查了'expicitly shared'。我正在驗證內容(我沒有收到錯誤)並擁有代表,沒有它的方法被調用。
-(void)shareWithFacebook:(NSString *)message
{
if ([[FBSDKAccessToken currentAccessToken] hasGranted:@"publish_actions"])
{
NIDINFO(@"Facebook sharing has publish_actions permission");
}
else
{
FBSDKLoginManager *loginManager = [[FBSDKLoginManager alloc] init];
[loginManager logInWithPublishPermissions:@[@"publish_actions"]
handler:^(FBSDKLoginManagerLoginResult *result, NSError *error)
{
NIDERROR(@"Facebook sharing getting publish_actions permission failed: %@", error);
}
];
}
NSMutableDictionary *properties = [NSMutableDictionary dictionaryWithDictionary: @{
@"og:type": @"article",
@"og:title": @"Bloc",
@"og:description": message,
@"og:url": @"http://getonbloc.com/download"
}];
FBSDKShareOpenGraphObject *object = [FBSDKShareOpenGraphObject objectWithProperties:properties];
// Create the action
FBSDKShareOpenGraphAction *action = [FBSDKShareOpenGraphAction actionWithType:@"mynamespace:Share" object:object key:@"article"];
[action setString:@"true" forKey:@"fb:explicitly_shared"];
// Create the content
FBSDKShareOpenGraphContent *content = [[FBSDKShareOpenGraphContent alloc] init];
content.action = action;
content.previewPropertyName = @"article";
// Share the content
FBSDKShareAPI *shareAPI = [[FBSDKShareAPI alloc] init];
shareAPI.shareContent = content;
shareAPI.delegate = self;
NSError *error;
if([shareAPI validateWithError:&error] == NO)
{
NIDERROR(@"Facebook sharing content failed: %@", error);
}
[shareAPI share];
}
#pragma mark - FBSDKSharingDelegate
- (void) sharer:(id<FBSDKSharing>)sharer didCompleteWithResults:(NSDictionary *)results
{
NIDINFO(@"Facebook sharing completed: %@", results);
}
- (void) sharer:(id<FBSDKSharing>)sharer didFailWithError:(NSError *)error
{
NIDERROR(@"Facebook sharing failed: %@", error);
}
- (void) sharerDidCancel:(id<FBSDKSharing>)sharer
{
NIDINFO(@"Facebook sharing cancelled.");
}
沒有ios9問題。 FB最新api(4.7.x)問題 –