OGeek|极客世界-中国程序员成长平台

标题: ios - 需要登录 输入 的密码。 [环境: Sandbox] [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 21:25
标题: ios - 需要登录 输入 的密码。 [环境: Sandbox]

当我启动我的 Unity iOS 应用程序时不断提示我:

Enter the password for . [environment sandbox]

注意没有用户名,我不能输入用户名。所以我也不能输入密码。

我删除了对 IAP 的所有引用( channel 和购买文件夹,并禁用了 IAP 服务),删除了 iOS 构建文件夹并重新构建它,然后编译它。

我在 iPhone 上退出了 iTunes。

我仍然提示我。 我附上了截图。

enter image description here



Best Answer-推荐答案


我在使用 RevenueCat(react-native-purchases)的 React Native 应用程序中实现 IAP 时遇到了同样的问题。

我的解决方案:

  1. 在 AppDelegate.h 中,导入 StoreKit 并将 SKPaymentTransactionObserver 添加到 AppDelegate 接口(interface)。
#import <React/RCTBridgeDelegate.h>
#import <UIKit/UIKit.h>
#import <StoreKit/StoreKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate, RCTBridgeDelegate, SKPaymentTransactionObserver>

@property (nonatomic, strong) UIWindow *window;

@end
  1. 在 AppDelegate.m 中,导入 StoreKit 并在 didFinishLaunchingWithOptions 中添加观察者。
#import <StoreKit/StoreKit.h>

@implementation AppDelegate

- (BOOL)applicationUIApplication *)application didFinishLaunchingWithOptionsNSDictionary *)launchOptions
{ 
  [[SKPaymentQueue defaultQueue] addTransactionObserver:self];
...
}
  1. 再次在 AppDelegate.m 中,添加需要的方法 updatedTransactions 以满足 SKPaymentTransactionObserver 的协议(protocol)。
(void)paymentQueueSKPaymentQueue *)queue updatedTransactionsNSArray *)transactions{
  for(SKPaymentTransaction *transaction in transactions){
    switch(transaction.transactionState){
      case SKPaymentTransactionStatePurchasing:
        [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
        NSLog(@"Transaction state -> Purchasing");
        break;
      case SKPaymentTransactionStatePurchased:
        [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
        NSLog(@"Transaction state -> Purchased");
        break;
      case SKPaymentTransactionStateRestored:
        NSLog(@"Transaction state -> Restored");
        [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
        break;
      case SKPaymentTransactionStateFailed:
        if(transaction.error.code == SKErrorPaymentCancelled){
          NSLog(@"Transaction state -> Cancelled");
        }
        [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
        break;
    }
  }
  1. 在出现问题的物理设备上运行应用程序,当消息出现时点击取消。

  2. 在 XCode 中查看 finishTransaction 在任何 switch 案例中被调用。幸运的是,它将被调用的次数与未完成的交易一样多。

在此之后,烦人的消息不应再弹出。就我而言,大约有 15 笔未完成的交易,这就是为什么每 5 分钟就会出现一次消息... ¬¬

我在问题消失后评论了上面的代码,因为正如我所说,我正在使用框架来管理 IAP。

这只是一种解决方法,但希望它对你有用。

关于ios - 需要登录 输入 的密码。 [环境: Sandbox],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53948877/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4