Sto provando a condividere su Facebook utilizzando il codice dal loro tutorial di gioco iOS. La finestra di dialogo si apre e l'immagine e il testo che ho specificato sono presenti, ma quando premo "Invia" appare la barra di caricamento, non viene caricato, quindi vengo reindirizzato alla mia app. Nessun errore viene stampato sulla console e l'app non si arresta in modo anomalo.Errore iOS per pubblicare su Facebook, nessun errore registrato
Quando vado su Facebook per verificare se il messaggio è inviato, ottengo il seguente:..
"Oops, qualcosa è andato storto C'è stato un problema pubblicare la tua stato che abbiamo registrato l'errore e avrà un aspetto dentro."
Ho usato questo codice nell'app precedente e ha funzionato perfettamente. Ho aggiornato l'ID di Facebook, il nome visualizzato di Facebook e lo schema URL in plist.
Ecco il codice:
classe FacebookHandler (derivato da Facebook esercitazione)
#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
My Call
[FacebookHandler Facebook_PostToNewsFeedWithTitle:title withCaption:caption withDescription:description withLink:link withPictureURL:picURL];
UPDATE
Sembra essere un problema con l'app di Facebook. Quando lo provo su un dispositivo con Facebook disinstallato, mi viene chiesto di effettuare il login e poi post con successo. Tuttavia, se Facebook è installato, non viene pubblicato.
Anche io sto affrontando questo problema mentre funziona perfettamente nel simulatore. –
Qualche soluzione fino ad ora? Ho lo stesso problema anche io. –