Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sign-In Required Enter the password for . [Environment: Sandbox]

When I launch my Unity iOS App is keeps prompting me:

Enter the password for . [environment sandbox]

Notice there is no username and I cannot put a username. So I cannot enter a password either.

I deleted all references to the IAP (channel & purchasing folders, and disabled the IAP service), deleted the iOS build folder and rebuilt it, then compiled it.

I logged out of iTunes on the iPhone.

I still prompts me. I have attached a screenshot.

enter image description here

like image 328
Spinteractive Avatar asked Dec 27 '18 17:12

Spinteractive


3 Answers

I had the same issue implementing IAP in a React Native app with RevenueCat (react-native-purchases).

My solution:

  1. Inside AppDelegate.h, import StoreKit and add SKPaymentTransactionObserver to 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. Inside AppDelegate.m, import StoreKit and in didFinishLaunchingWithOptions add the observer.
#import <StoreKit/StoreKit.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{ 
  [[SKPaymentQueue defaultQueue] addTransactionObserver:self];
...
}
  1. Again inside AppDelegate.m, add the required method updatedTransactions to meet the protocol of SKPaymentTransactionObserver.
(void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)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. Run the app on your physical device that is presenting the issue, when the message comes up tap Cancel.

  2. Review in the XCode that finishTransaction was called inside of any of the switch cases. Luckily it will be called as many times as unfinished transactions there were.

After this, the annoying message shouldn't be pop up any more. In my case, there were like 15 unfinished transactions and that why the message showed up every 5 minutes... ¬¬

I commented the above code after the issue was gone because, as I said, I'm using a framework to manage IAPs.

This is just a work around but hope it works for you.

like image 160
Luis Galvez Avatar answered Oct 10 '22 19:10

Luis Galvez


I had the same problem recently where I was constantly being asked for credentials for the sandbox account "." - It would happen whenever I opened the app in question or whenever network connectivity changed. I have no idea how it got into that state but I found that Milos had the answer.

Essentially, you need to setup a SKPaymentTransactionObserver if you don't already have one (you probably have one). Then inside paymentQueue:updatedTransactions: (docs), loop through all transactions in the queue, calling on each transaction:

Swift:

SKPaymentQueue.default().finishTransaction(transaction)

Obj-C:

[[SKPaymentQueue defaultQueue] finishTransaction:transaction];

I had to remove existing code I had in the transaction queue loop, as it seemed to trigger the credentials dialog and meant that other transactions wouldn't finish.

Running the app with those temporary changes has fixed the problem for me afaik, so it looks like the transaction queue was just borked.

like image 40
roarster Avatar answered Oct 10 '22 19:10

roarster


Nothing worked until reset the device on Erase All Content and Settings in the Settings app.

like image 1
Joey Avatar answered Oct 10 '22 19:10

Joey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!