2

我写了代码

    - (void)sendRequest {

NSLog(@"SEND REQUEST  ");


// Display the requests dialog
[FBWebDialogs
 presentRequestsDialogModallyWithSession:nil
 message:@"www.demoapp.com"
 title:nil
 parameters:nil
 handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
     if (error) {
         // Error launching the dialog or sending the request.
         NSLog(@"Error sending request.");
         [FBSession.activeSession closeAndClearTokenInformation];
         [FBSession.activeSession close];
         [FBSession setActiveSession:nil];

     } else {
         if (result == FBWebDialogResultDialogNotCompleted) {
             // User clicked the "x" icon
             NSLog(@"User canceled request.");
             [FBSession.activeSession closeAndClearTokenInformation];
             [FBSession.activeSession close];
             [FBSession setActiveSession:nil];

         } else {
             // Handle the send request callback
             NSDictionary *urlParams = [self parseURLParams:[resultURL query]];
             if (![urlParams valueForKey:@"request"]) {
                 // User clicked the Cancel button
                 NSLog(@"User canceled request.");
                 [FBSession.activeSession closeAndClearTokenInformation];
                 [FBSession.activeSession close];
                 [FBSession setActiveSession:nil];

             } else {
                 // User clicked the Send button
                 NSString *requestID = [urlParams valueForKey:@"request"];
                 NSLog(@"Request ID: %@", requestID);

                 [FBSession.activeSession closeAndClearTokenInformation];
                 [FBSession.activeSession close];
                 [FBSession setActiveSession:nil];


             }
         }
     }
 }];
}



  - (NSDictionary*)parseURLParams:(NSString *)query {
NSArray *pairs = [query componentsSeparatedByString:@"&"];
NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
for (NSString *pair in pairs) {
    NSArray *kv = [pair componentsSeparatedByString:@"="];
    NSString *val =
    [kv[1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    params[kv[0]] = val;
}
return params;
}

并称它为

    - (void)sendRequestButtonAction {


NSLog(@"sendRequestButtonAction");


AppDelegate *appDelegate =
(AppDelegate *) [[UIApplication sharedApplication] delegate];
if (FBSession.activeSession.isOpen) {
    [appDelegate sendRequest];
}
}

我从 iPhone 模拟器发送并在 iPhone 设备和 Android 设备中接收,但我无法在 iPad 中接收,

我很惊讶,最终找不到解决方案。请帮忙

4

0 回答 0