2013-04-22 16 views
8

iOS uygulamasmı denemek için kullanıcıları Facebook'ta davet etmeye çalışıyorum (henüz mağazada değil, henüz tamamlamadı). Ben davet gönder isteyen kullanıcıları seçip vurduğundaFacebook'taki facebook kullanıcısını facebook'ta davet edin: davetiye gönderilmiyor

Ancak
- (void)shareWithFriends:(id)sender 
{ 
    UIAlertView *alert = [[UIAlertView alloc] 
          initWithTitle:@"Invite Friends" 
          message:@"If you enjoy using this app, would you mind taking a moment to invite a few friends that you think will also like it?" 
          delegate:self 
          cancelButtonTitle:@"No Thanks" 
          otherButtonTitles:@"Tell Friends!", nil]; 
    [alert show]; 
} 

- (void)alertView:(UIAlertView *)alertView 
didDismissWithButtonIndex:(NSInteger)buttonIndex { 
    if (buttonIndex == 0) { 
     // User has clicked on the No Thanks button, do not ask again 
     NSLog(@"Chitty user says he doesn't wanna share"); 
    } else if (buttonIndex == 1) { 
     // User has clicked on the Tell Friends button 
     [self performSelector:@selector(sendRequest) withObject:nil afterDelay:0.5]; 
    } 
} 

- (void)sendRequest { 
    // Display the requests dialog 

    NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:nil]; 
    [FBWebDialogs presentRequestsDialogModallyWithSession:nil 
                message:[NSString stringWithFormat:@"Try this app, brah!"] 
                title:nil 
               parameters:params 
                handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) { 
                 if (error) { 
                  // Case A: Error launching the dialog or sending request. 
                  NSLog(@"Error sending request."); 
                 } else { 
                  if (result == FBWebDialogResultDialogNotCompleted) { 
                   // Case B: User clicked the "x" icon 
                   NSLog(@"User canceled request."); 
                  } else { 
                   NSLog(@"Request Sent."); 
                  } 
                 }}]; 


} 

, Gönder:

aşağıdaki kodu kullanmayı deneyin sonra kullanıcının kimliğini doğrulamak ve facebook API kullanmak. Hiçbir şey olmuyor. "İstek Gönderildi" ifadesini alıyorum. NSLog aracılığıyla ama arkadaşım bunu almıyor.

Herhangi bir fikrin var mı?

cevap

0

Paramları ne zaman dolduruyorsunuz?

ben bildirim mesajı sadece 'Facebook App hem Android/iOS içinde ancak web kullanıcısının edebilirsiniz geldiğini fark

4

Eğer alıcı olarak boş bir facebook kullanıcı adı gönderirseniz FB API nazik tamamlanmış bir eylemi gönderir biliyorum Görmüyoruz, umarım Facebook'tan bir uygulama değil midir? Ayrıca, davetiyelerinizin başarılı bir şekilde gönderilmesini sağlamak için resultURL sorgusunu ayrıştırmanız gerekir.

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

[FBWebDialogs presentRequestsDialogModallyWithSession:nil 
                 message:SL_FB_INVITE_DESCRIPTION 
                 title:SL_FB_INVITE_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] autorelease]; 
       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] autorelease]; 
    for (NSString *pair in pairs) 
    { 
     NSArray *kv = [pair componentsSeparatedByString:@"="]; 

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

    return params; 
} 
0

Bu isteğin başka kullanıcılara ulaşmadığını nereden biliyorsunuz? Herhangi bir bildirim almayacaklarını biliyorsunuz, this adresine gidebilirler link:

Uygulamanızda bir tuval uygulaması olarak bir platform olarak bir Facebook uygulamanız olmalıdır. Daha sonra kullanıcılar bildirim alacak.

0

Her zaman uygulamanızın açık olduğu platformlara bağlıdır. Örneğin: yalnızca mobil cihazlarda kullanılabilen bir uygulamanız varsa, davet edilen arkadaşlar yalnızca facebook.com adresinde değil, telefonlarındaki isteği görür. Ayrıca facebook.com'da bir tuval uygulamanız varsa, facebook.com'da da görünecektir.

Bu konuyla ilgili daha fazla bilgiyi, "Gönderme Deneyimi" [1] 'nin uygulamalar tarafından gönderilen İsteklerin [1] belgesinde bulabilirsiniz.

[1] https://developers.facebook.com/docs/games/requests/v2.0#receive

İlgili konular