开发者

stuck with sandbox account

I created a test account to check in app purchases. I could purchase and the purchase was successful. After that I found a bug in navigation. I fixed a bug, created another account and deleted the account I logged in in previous session. Now I cannot test the in app purchases anymore, since the app store lo开发者_高级运维g me in automatically with a ghost account that already doesn't exists. I'm asked to enter a password only in spite that before each debug session I sign out from the Store in Settings and delete the previous version of the application. How do I reset this?

Thanks,

Nava


I know this is an old topic, but I had trouble finding a solution and went through some mind-numbing trial and error until I figured out a solution so I thought I would share it here since I was unable to find it anywhere else.

First, make sure after every transaction you call:

    [[SKPaymentQueue defaultQueue] finishTransaction:transaction];

What happened in my case is that a transaction wasn't finished and stayed on the queue so even when I switched to a different sandboxed account it still continued to ask for my old account's password.

To fix it I added:

SKPaymentQueue *queue = [SKPaymentQueue defaultQueue];
for (SKPaymentTransaction *transaction in queue.transactions) {
    [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
}

BEFORE I added the transaction observer, ie this:

[[SKPaymentQueue defaultQueue] addTransactionObserver:self];

Also, in the

(void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions

function, I added this line of code:

[queue finishTransaction:transaction];

in the SKPaymentTransactionStateRestored and SKPaymentTransactionStateFailed cases of the switch statement. Don't add it to the purchased state because you aren't allowed to call finish on that from what I know.

I'm not sure which of the two above steps fixed the bug because it persisted until I signed out of my iPhone, deleted the app, powered it down, and did a clean rebuild/install that it finally stopped asking me for the password to the bugged account. Hope this helps someone.

EDIT: (11/12/15)

So I found out the cause of breaking sandbox accounts. It happened after restoring purchases, then hitting the home key, reopening and hitting the restore button again which caused a crash. The restore stayed in the queue and the above process was the only way to get out of the popups asking for the password.

In order to stop that, I added:

[[SKPaymentQueue defaultQueue] removeTransactionObserver:self];

to by tearDown function (called by applicationDidEnterBackground:) of my main view controller before I nil'd my in-app purchase manager object. I think what was happening is that I added the object as a transaction observer more than once and it was causing the odd behavior. From the looks of it, this seems to have fixed the problem entirely because I haven't been able to recreate the error again.


I had the same problem. This is what solved my problem:

  1. Settings -> Reset -> Reset All Settings
  2. Settings -> iTunes & App Store -> Sign out
  3. Delete the app
  4. Restart the app from XCode

UPDATE: I realized the problem was I had not this line in my code:

[[SKPaymentQueue defaultQueue] finishTransaction:tran];

That means my old transaction was not completed, and iPhone was trying to finalize old transactions which happened before. When I added this line to my code, the old user password request is not happening anymore.


So you mean that even if you go to the Settings App -> Store -> Sign Out, you still get the username from the previous test account? Did you also try to delete the app from your device? That fixed a similar issue for me.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜