Facebook request is not sending on all devices?

145 views Asked by At

I wrote code

    - (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;
}

and calling it like

    - (void)sendRequestButtonAction {


NSLog(@"sendRequestButtonAction");


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

I am sending from iPhone simulator and receiving in iPhone device and Android Device, but I am unable to receive in iPad,

I am amazed and cannot find solution at my end. Please help

0

There are 0 answers