2014-02-21 64 views
5

我想從我的iOS本地應用程序發送邀請到Facebook的朋友使用下面的方法使用Facebook SDK的應用程序。iOS的Facebook的sdk邀請朋友請求發送但沒有得到朋友的通知

-(IBAction)ShowFiendDialog:(id)sender 
{ 

    NSDictionary *parameters = @{@"to":@""}; 

    [FBWebDialogs presentRequestsDialogModallyWithSession:FBSession.activeSession 
                message:@"my message" 
                title:@"my title" 
               parameters:parameters 
                handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) 
    { 
     if(error) 
     { 
      NSLog(@"Some errorr: %@", [error description]); 
      UIAlertView *alrt = [[UIAlertView alloc] initWithTitle:@"Invitiation Sending Failed" message:@"Unable to send inviation at this Moment, please make sure your are connected with internet" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil]; 
      [alrt show]; 
      //[alrt release]; 
     } 
     else 
     { 
      if (![resultURL query]) 
      { 
       return; 
      } 

      NSDictionary *params = [self parseURLParams:[resultURL query]]; 
      NSMutableArray *recipientIDs = [[NSMutableArray alloc] init]; 
      for (NSString *paramKey in params) 
      { 
       if ([paramKey hasPrefix:@"to["]) 
       { 
        [recipientIDs addObject:[params objectForKey:paramKey]]; 
       } 
      } 
      if ([params objectForKey:@"request"]) 
      { 
       NSLog(@"Request ID: %@", [params objectForKey:@"request"]); 
      } 
      if ([recipientIDs count] > 0) 
      { 
       //[self showMessage:@"Sent request successfully."]; 
       //NSLog(@"Recipient ID(s): %@", recipientIDs); 
       UIAlertView *alrt = [[UIAlertView alloc] initWithTitle:@"Success!" message:@"Invitation(s) sent successfuly!" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil]; 
       [alrt show]; 
       //[alrt release]; 
      } 

     } 
    }friendCache:nil]; 

} 

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

     [params setObject:[[kv objectAtIndex:1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding] 
        forKey:[[kv objectAtIndex:0] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; 
    } 

    return params; 
} 

使用上面的代碼,我得到了提示所有朋友的列表,並在檢查多個或單個朋友後,該請求已成功發送。但是,當我的朋友在網絡或Facebook本地應用程序中打開Facebook時,不會收到任何通知或消息。我找不到代碼中的錯誤。

請幫我解決這個問題。我的錯誤在哪裏,我該如何解決這個問題?

+0

使用此鏈接將工作http://stackoverflow.com/questions/11796445/facebook-app-requests-arent-shown-on-ios-devices – 2015-10-08 10:49:47

回答

5

你必須在Facebook上配置你的應用程序通過傳遞一些虛擬URL,我也面臨同樣的問題,這樣做爲我工作。 轉到developer.facebook.com,選擇你的應用程序,選擇設置,添加平臺--->添加應用程序,在那裏傳遞任何虛擬網址,也爲你的應用程序添加圖像,這些圖像將在應用程序詳細信息通知中顯示。

+0

它需要提交之前可以做到這一點? –

+0

@GấuUni不,你不需要提交你的應用程序來做到這一點。請記住讓您的應用程序生效(默認情況下,它處於沙箱模式,它不允許應用程序使用除註冊的fb帳戶之外的其他fb帳戶進行測試) –

+1

我已公佈它。每個人都可以授權。我成功發送請求。但我的朋友們沒有收到任何網絡或手機通知。請幫幫我。你能給我一些我可以聯繫你的東西嗎 –