facebook / facebook/facebook-ios-sdk
GameRequestDialog
- Dominant language
- Swift
- Stars
- 8.1k
- Forks
- 3.7k
- PR merge metrics
- No merged PRs in 30d
Description
### Checklist before submitting a bug report
- [x] I've updated to the latest released version of the SDK
- [x] I've searched for existing [GitHub issues](https://github.com/facebook/facebook-ios-sdk/issues)
- [x] I've looked for existing answers on [Stack Overflow](https://facebook.stackoverflow.com), the [Facebook Developer Community Forum](https://developers.facebook.com/community/) and the [Facebook Developers Group](https://www.facebook.com/groups/fbdevelopers)
- [x] I've read the [Code of Conduct](https://github.com/facebook/facebook-ios-sdk/blob/main/CODE_OF_CONDUCT.md)
- [x] This issue is not security related and can safely be disclosed publicly on GitHub
### Xcode version
16.4
### Facebook iOS SDK version
FBSDKGamingServicesKit (18.0.3)
### Dependency Manager
CocoaPods
### SDK Framework
Gaming Services
### Goals
使用FBSDKGameRequestDialog 邀请分享给好友链接与图片
### Expected results
1.手机设备已安装 Facebook,拉起 app,邀请好友,好友收到邀请信息
2.手机设备未安装 Facebook,拉起网页登记账号与密码,然后邀请好友,好友收到信息
3.手机设备未安装 Facebook,拉起网页登记账号与密码,登录成功后,下次再邀请好友不需要再次输入账号与密码
### Actual results
1.不管手机设备是否已安装 Facebook,都是使用网页登录,邀请对应好友,代理收到邀请成功的回调,但是好友未收到任何信息
2.上次保存的账号信息,点击邀请依然需要网页需要输入账号与密码。
### Steps to reproduce
_No response_
### Code samples & details
```swift
- (void)sendInviteWithMessage:(NSString *)message
title:(nullable NSString *)title
filter:(nullable NSNumber *)filter
url:(nullable NSString *)url
completion:(nullable FBInviteCompletion)completion {
NSLog(@"--222222--currentAccessToken:%@ tokenString:%@ userID:%@ isExpired:%d",[FBSDKAccessToken currentAccessToken],[FBSDKAccessToken currentAccessToken].tokenString,[FBSDKAccessToken currentAccessToken].userID,[FBSDKAccessToken currentAccessToken].isExpired);
// 检查登录状态
if (![FBSDKAccessToken currentAccessToken]) {
__weak typeof(self) weakSelf = self;
[self loginWithCompletion:^(BOOL success, NSString *errorMessage) {
if (success) {
[weakSelf sendInviteWithMessage:message title:title filter:filter url:url completion:completion];
} else {
if (completion) completion(NO, nil, errorMessage);
}
}];
return;
}
self.currentInviteCompletion = completion;
FBSDKGameRequestContent *content = [[FBSDKGameRequestContent alloc] init];
content.message = message ?: @"快来加入我们吧!";
content.title = title ?: @"邀请你一起玩";
if (filter) {
content.filters = [filter integerValue];
} else {
content.filters = FBSDKGameRequestFilterNone;
}
if (url.length > 0) {
content.data = url;
}
FBSDKGameRequestDialog *dialog = [FBSDKGameRequestDialog dialogWithContent:content
delegate:self];
if (!dialog.canShow) {
if (completion) completion(NO, nil, @"无法显示邀请对话框,请确保已安装Facebook应用");
self.currentInviteCompletion = nil;
return;
}
NSError *error;
if ([dialog validateWithError:&error]) {
[dialog show];
} else {
if (completion) completion(NO, nil, error.localizedDescription ?: @"邀请内容验证失败");
self.currentInviteCompletion = nil;
}
}
```
Contributor guide
Assessment
This issue has not been assessed yet.