Tôi đang cố gắng chia sẻ lên Facebook bằng cách sử dụng mã từ hướng dẫn trò chơi iOS của họ. Hộp thoại bật lên và hình ảnh và văn bản tôi chỉ định hiện diện, nhưng khi tôi nhấn "Gửi" thanh tải xuất hiện, không tải, sau đó tôi được chuyển hướng đến ứng dụng của mình. Không có lỗi nào được in trên bảng điều khiển và ứng dụng không bị lỗi.iOS không đăng trên Facebook, không có lỗi nào được ghi
Khi tôi đi trên Facebook để kiểm tra xem tin nhắn đã được đăng, tôi nhận được như sau:..
"Rất tiếc, Một cái gì đó đã đi sai Có vấn đề đăng trạng thái của bạn Chúng tôi đã ghi lại các lỗi và sẽ xem xét vào đó. "
Tôi đã sử dụng mã này trong ứng dụng trước và nó hoạt động hoàn toàn tốt. Tôi đã cập nhật ID Facebook, Tên hiển thị trên Facebook và Lược đồ URL trong plist.
Đây là mã:
FacebookHandler lớp (có nguồn gốc từ Facebook hướng dẫn)
#import "FacebookHandler.h"
@implementation FacebookHandler
+ (void) Facebook_CreateNewSession
{
// initialize Facebook
FBSession* session = [[FBSession alloc] init];
[FBSession setActiveSession: session];
}
+ (void) Facebook_Login
{
NSArray *permissions = [[NSArray alloc] initWithObjects:
@"email",
nil];
// Attempt to open the session. If the session is not open, show the user the Facebook login UX
[FBSession openActiveSessionWithReadPermissions:permissions allowLoginUI:true completionHandler:^(FBSession *session, FBSessionState status, NSError *error)
{
// Did something go wrong during login? I.e. did the user cancel?
if (status == FBSessionStateClosedLoginFailed || status == FBSessionStateCreatedOpening) {
// If so, just send them round the loop again
[[FBSession activeSession] closeAndClearTokenInformation];
[FBSession setActiveSession:nil];
[self Facebook_CreateNewSession];
}
else
{
}
}];
}
+ (void) Facebook_PostToNewsFeedWithTitle:(NSString*)title withCaption:(NSString*)caption withDescription:(NSString*)description withLink:(NSString*)link withPictureURL:(NSString*)picURL
{
// check if user is logged in
if ([FBSession activeSession] == nil)
{
[FacebookHandler Facebook_CreateNewSession];
[FacebookHandler Facebook_Login];
}
// This function will invoke the Feed Dialog to post to a user's Timeline and News Feed
// It will attemnt to use the Facebook Native Share dialog
// If that's not supported we'll fall back to the web based dialog.
NSString *linkURL = link;
NSString *pictureURL = picURL;
// Prepare the native share dialog parameters
FBShareDialogParams *shareParams = [[FBShareDialogParams alloc] init];
shareParams.link = [NSURL URLWithString:linkURL];
shareParams.name = title;
shareParams.caption= caption;
shareParams.picture= [NSURL URLWithString:pictureURL];
shareParams.description = description;
if ([FBDialogs canPresentShareDialogWithParams:shareParams]){
[FBDialogs presentShareDialogWithParams:shareParams
clientState:nil
handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
if(error) {
NSLog(@"Error publishing story.");
} else if (results[@"completionGesture"] && [results[@"completionGesture"] isEqualToString:@"cancel"]) {
NSLog(@"User canceled story publishing.");
} else {
NSLog(@"Story published.");
}
}];
}else {
// Prepare the web dialog parameters
NSDictionary *params = @{
@"name" : shareParams.name,
@"caption" : shareParams.caption,
@"description" : shareParams.description,
@"picture" : pictureURL,
@"link" : linkURL
};
// Invoke the dialog
[FBWebDialogs presentFeedDialogModallyWithSession:nil
parameters:params
handler:
^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
NSLog(@"Error publishing story.");
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
NSLog(@"User canceled story publishing.");
} else {
NSLog(@"Story published.");
}
}}];
}
}
@end
Gọi My
[FacebookHandler Facebook_PostToNewsFeedWithTitle:title withCaption:caption withDescription:description withLink:link withPictureURL:picURL];
CẬP NHẬT
Dường như có vấn đề với ứng dụng Facebook. Khi thử nó trên một thiết bị với Facebook gỡ cài đặt, tôi được yêu cầu đăng nhập và sau đó nó đăng thành công. Tuy nhiên, nếu Facebook được cài đặt, nó sẽ không được đăng.
Tôi cũng đang gặp vấn đề này trong khi nó hoạt động tốt trong trình mô phỏng. –
Bất kỳ giải pháp nào cho đến nay? Tôi có cùng một vấn đề quá. –