Facebook iOS SDK - Sending a facebook user an app request

前端 未结 5 1527
野趣味
野趣味 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: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);
             }
         }
     }];
    

提交回复
热议问题