8

Facebook のユーザーを招待して iOS アプリを試してもらいたいと考えています (まだストアになく、まだ完成していません)。

Facebook API を使用してユーザーを認証し、次のコードを使用しようとしています。

- (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.");
                                                          }
                                                      }}];


}

ただし、招待状を送信するユーザーを選択して [送信] をクリックすると、何も起こりません。「リクエストを送信しました」と表示されます。NSLog を使用していますが、友人が受信していません。

何か案は?

4

4 に答える 4

4

通知メッセージは Android/iOS の両方の Facebook アプリでのみ送信されることに気付きましたが、Web ユーザーはそれを見ることができません。Facebook からの実装ではないことを願っていますか? また、招待状が正常に送信されたことを確認するには、resultURL クエリを解析する必要があります。

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;
}
于 2013-05-31T21:30:10.457 に答える
0

リクエストが他のユーザーに届いていないことをどのように確認できますか? 彼らは通知を受け取らず、次のリンクにアクセスしてアクセスできることを知っておく必要があります。

キャンバス ページを持つプラットフォームとして、アプリに Facebook アプリが必要です。その後、ユーザーは通知を受け取ります。

于 2014-06-09T13:26:36.137 に答える
0

それは常に、アプリが使用されているプラ​​ットフォームに依存します。たとえば、モバイルでのみ利用可能なアプリがある場合、招待された友人は、facebook.com ではなく、電話でのみリクエストを確認します。facebook.com にもキャンバス アプリがある場合は、facebook.com にも表示されます。

詳しくは、アプリから送信されるリクエストの「受信エクスペリエンス」[1] に関するドキュメントを参照してください。

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

于 2014-06-09T13:32:10.360 に答える