現在、アプリの iOS バージョンに Facebook SDK を追加しようとしています。ログイン、ログアウト、共有、およびリクエスト機能は現在すべて動作していますが、MessageDialog 機能を動作させるのに苦労しています。現在、Facebook アプリと Facebook Messenger アプリがデバイスにインストールされています。ただし、「FBDialog canPresentMessageDialogWithParams:params」を呼び出すたびに、false が返されます。
アプリがまだ開発モードにある間は、この機能は機能しないと思いますが、それは単なる推測です。Message Dialog が開発中のアプリで動作するかどうか知っている人はいますか? または、私が間違っていることについて何か考えがありますか?
骨の折れる間違いを犯した場合に備えて、コードも含めました。どんな助けでも大歓迎です!
// Check if the Facebook app is installed and we can present the share dialog
FBLinkShareParams *params = [[FBLinkShareParams alloc] init];
params.link = [NSURL URLWithString:@"https://www.facebook.com/"];
params.name = @"Flash Bear";
params.caption = nil;
params.picture = nil;
params.linkDescription = @"I'm playing Flash Bear. Why don't you come join me?";
// If the Facebook Messenger app is installed and we can present the share dialog
if ([FBDialogs canPresentMessageDialogWithParams:params]) {
// Present message dialog
[FBDialogs presentMessageDialogWithParams:params
clientState:nil
handler: ^(FBAppCall *call, NSDictionary *results, NSError *error) {
if(error) {
// An error occurred, we need to handle the error
// See: https://developers.facebook.com/docs/ios/errors
NSLog(@"Error messaging link: %@", error.description);
} else {
// Success
NSLog(@"result %@", results);
}
}];
} else {
// Present the feed dialog
// Put together the dialog parameters
UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"Sorry!"
message:@"There was an error connecting to FB Messenger. Please make sure that it is installed."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[message show];
}