Facebook iOS SDK - Sending a facebook user an app request

前端 未结 5 1526
野趣味
野趣味 2021-02-10 16:18

Im trying to send an app request through facebook using the facebook iOS SDK, im using the following code:

NSString *message = [[NSString alloc] initWithFormat:@         


        
相关标签:
5条回答
  • 2021-02-10 16:23

    andyc,using that way you can only send the App request. And please make sure you have registered you App as "App On Facbook". The problem is that in order to have the notification displayed on the desktop website, your Facebook App needs to have a Canvas URL defined. The URL doesn't even need to be valid, it just needs to be defined in the Settings of the App. I have verified with a test app that this does indeed resolve the problem. This is done intentionally by Facebook because when the user clicks on the notification, they are sent to your Canvas URL on the desktop website

    I have done things in same way and i am getting the App request in my Notifications. still you have problem with sending app request then please view below link

    "apprequests" dialog reports success, recipients receive nothing

    0 讨论(0)
  • 2021-02-10 16:24

    It is not possible to send an app request without the dialog, using just POST method.

    According to the docs:

    This SDK provides a method for popping up a Facebook dialog. The currently supported dialogs are the login and permissions dialogs used in the authorization flow, and a dialog for publishing posts to a user's feed.

    So you can't post an app request via standard dialogs either. It works only for web applications.

    0 讨论(0)
  • 2021-02-10 16:32

    I was able to send a request using Ruby via a standard POST to /me/apprequests. I supplied an valid access_token for the app and the "message" parameter. It's possible, the iOS SDK just doesn't have a dialog for it yet.

    NOTE: the user has to have installed the application once before you can send them notifications and invites. So Andrew is correct. There's no way to send an app request to invite someone to join a new app quite yet.

    0 讨论(0)
  • 2021-02-10 16:39

    Try this code,

    NSDictionary *params = @{@"to":text};
    
    NSString *message = @"MESSAGE";
    NSString *title = @"TITLE";
    
    [FBWebDialogs presentRequestsDialogModallyWithSession:nil
                                                  message:message
                                                    title:title
                                               parameters:params handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error)
     {
         if (error)
         {
             UIAlertView *Alert = [[UIAlertView alloc]initWithTitle:@"Alert" message:@"Request not sent" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
             [Alert show];
         }
         else
         {
             if (result == FBWebDialogResultDialogNotCompleted)
             {
                 // Case B: User clicked the "x" icon
                 UIAlertView *Alert = [[UIAlertView alloc]initWithTitle:@"Alert" message:@"Canceled request" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
                 [Alert show];
                 NSLog(@"User canceled request.");
             }
             else
             {
                 UIAlertView *Alert = [[UIAlertView alloc]initWithTitle:@"Success" message:@"Request sent successfully" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
                 [Alert show];
                 NSLog(@"Request Sent. %@", params);
             }
         }
     }];
    
    0 讨论(0)
  • 2021-02-10 16:47

    You can easily send the app request very easily by Using Facebook SDK

    For Making App Request Please Make sure Following steps

    1)Make sure you have added the latest Facebook SDK in Your Application Folder

    if not,you may download from this link.

    Now you just need to Add FBConnect Folder in your Project Folder.

    2)Then Make sure you have Registered your iphone App as "App on Facebook" Type Select how your app integrates with Facebook under Basic App Settings.

    if not,you can do that here.

    NSString *friendId=@"FacebookId Of Your Friends";
    
    NSLog(@"%@",friendId);
    
    NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"Hi please add me as a friend.",  @"message",
                                       friendId, @"to",
                                       nil];
     [appDelegate.facebook dialog:@"apprequests" andParams:params  andDelegate:self];
    

    Please Don't Forget To Adopt the FBdialogDelegate protocol first in your ViewController Class.

    0 讨论(0)
提交回复
热议问题