iOS 微信客户端未安装授权登录,审核被拒
iOS 微信客户端未安装授权登录,审核被拒
作为一名 iOS 开发者,你可能会遇到这样的问题:在你的应用中使用微信授权登录功能,但由于未安装微信的情况下,审核被拒。这种情况下,你需要了解如何处理未安装微信的场景,并且按照苹果的审核指南进行修改。
第一次做微信授权登录功能
当你第一次尝试在你的应用中使用微信授权登录功能时,你可能会忽略未安装微信的情况下的处理。这种情况下,审核人员会发现你的应用没有正确处理未安装微信的场景,因此被拒。
查阅资料和微信开发文档
为了解决这个问题,你需要查阅苹果的审核指南和微信开发文档。在这些文档中,你会找到两种解决方法:
第一种:如果未安装微信,则不显示微信登入按钮在这种情况下,你可以通过以下方式处理未安装微信的情况:
* 在你的应用中,不显示微信登入按钮。
* 当用户点击登入按钮时,提示用户下载并安装微信。
第二种:使用 WXApi 的回调函数另一种解决方法是使用 WXApi 的回调函数。在这种情况下,你可以通过以下方式处理未安装微信的情况:
* 使用 WXApi 的 `handleOpenURL` 回调函数来检测是否有微信的授权请求。
* 如果用户已经安装了微信,则使用 WXApi 的 `sendAuthRequest` 方法来发送授权请求。
示例代码下面是示例代码,展示如何处理未安装微信的情况:
```objectivecimport
import "WXApi.h"
@interface ViewController : UIViewController@end@implementation ViewController- (void)viewDidLoad {
[super viewDidLoad];
// 不显示微信登入按钮 UIButton *wxButton = [[UIButton alloc] initWithFrame:CGRectMake(100,200,100,30)];
wxButton.backgroundColor = [UIColor blueColor];
[wxButton setTitle:@"微信登入" forState:UIControlStateNormal];
[self.view addSubview:wxButton];
// 使用 WXApi 的回调函数 [WXApi handleOpenURL:[NSURL URLWithString:@"weixin://"]];
}
- (void)touchesBegan:(NSSet
// 当用户点击登入按钮时,提示用户下载并安装微信 UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"提示" message:@"未安装微信,请下载并安装微信后再试。" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
// 使用 WXApi 的 sendAuthRequest 方法来发送授权请求 [WXApi sendAuthRequestWithScope:WXLoginScopeBaseInfo callback:^(BOOL success, id result) {
if (success) {
// 授权成功后,使用微信的 API 来获取用户信息 [self getUserInfo];
} else {
// 授权失败后,提示用户重新授权 UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"提示" message:@"授权失败,请重新授权。" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
// 使用 WXApi 的 sendAuthRequest 方法来发送授权请求 [WXApi sendAuthRequestWithScope:WXLoginScopeBaseInfo callback:^(BOOL success, id result) {
if (success) {
// 授权成功后,使用微信的 API 来获取用户信息 [self getUserInfo];
} else {
// 授权失败后,提示用户重新授权 UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"提示" message:@"授权失败,请重新授权。" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
// 使用 WXApi 的 sendAuthRequest 方法来发送授权请求 [WXApi sendAuthRequestWithScope:WXLoginScopeBaseInfo callback:^(BOOL success, id result) {
if (success) {
// 授权成功后,使用微信的 API 来获取用户信息 [self getUserInfo];
} else {
// 授权失败后,提示用户重新授权 UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"提示" message:@"授权失败,请重新授权。" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
// 使用 WXApi 的 sendAuthRequest 方法来发送授权请求 [WXApi sendAuthRequestWithScope:WXLoginScopeBaseInfo callback:^(BOOL success, id result) {
if (success) {
// 授权成功后,使用微信的 API 来获取用户信息 [self getUserInfo];
} else {
// 授权失败后,提示用户重新授权 UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"提示" message:@"授权失败,请重新授权。" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
// 使用 WXApi 的 sendAuthRequest 方法来发送授权请求 [WXApi sendAuthRequestWithScope:WXLoginScopeBaseInfo callback:^(BOOL success, id result) {
if (success) {
// 授权成功后,使用微信的 API 来获取用户信息 [self getUserInfo];
} else {
// 授权失败后,提示用户重新授权 UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"提示" message:@"授权失败,请重新授权。" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
// 使用 WXApi 的 sendAuthRequest 方法来发送授权请求 [WXApi sendAuthRequestWithScope:WXLoginScopeBaseInfo callback:^(BOOL success, id result) {
if (success) {
// 授权成功后,使用微信的 API 来获取用户信息 [self getUserInfo];
} else {
// 授权失败后,提示用户重新授权 UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"提示" message:@"授权失败,请重新授权。" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
// 使用 WXApi 的 sendAuthRequest 方法来发送授权请求 [WXApi sendAuthRequestWithScope:WXLoginScopeBaseInfo callback:^(BOOL success, id result) {
if (success) {
// 授权成功后,使用微信的 API 来获取用户信息 [self getUserInfo];
} else {
// 授权失败后,提示用户重新授权 UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"提示" message:@"授权失败,请重新授权。" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
// 使用 WXApi 的 sendAuthRequest 方法来发送授权请求 [WXApi sendAuthRequestWithScope:WXLoginScopeBaseInfo callback:^(BOOL success, id result) {
if (success) {
// 授权成功后,使用微信的 API 来获取用户信息 [self getUserInfo];
} else {
// 授权失败后,提示用户重新授权 UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"提示" message:@"授权失败,请重新授权。" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
// 使用 WXApi 的 sendAuthRequest 方法来发送授权请求 [WXApi sendAuthRequestWithScope:WXLoginScopeBaseInfo callback:^(BOOL success,