chirag04 / react-native-in-app-utils

A react-native wrapper for handling in-app payments
MIT License
890 stars 185 forks source link

Stuck on "Sign-in Required" infinite loop: App keeps asking for itunes password #136

Open brunolemos opened 6 years ago

brunolemos commented 6 years ago

So it shows the "Sign-in Required" alert. If I press Cancel, it will close it and reopen automatically right after. Same thing if I type the correct password and press Continue.

Is this an issue with this library, react native, ios, or what?

React Native 0.49.5 iOS 11.2

superandrew213 commented 6 years ago

Do you try to restore purchases in the background?

brunolemos commented 6 years ago

@superandrew213 How would it be like in the background? I just call InAppUtils.restorePurchases in the foreground inside a saga

superandrew213 commented 6 years ago

Do you call this when the user presses a button or do you call it automatically in the background to restore all the user's purchases? InAppUtils.restorePurchases will trigger a the "Sign-in Required" prompt when you call it.

brunolemos commented 6 years ago

Oh right. There are both cases:

But why would this cause an infinite loop? Shouldn't it just ask once at max?

superandrew213 commented 6 years ago

I'm triggering InAppUtils.receiptData in the background too but am not having any issues with it so far. However I had the same issue as you if I tried to restore the purchases in the background too.

Try disabling InAppUtils.receiptData and see what happens.

brunolemos commented 6 years ago

No luck. Even after I closed all apps the alert keeps showing to me asking for the password, even if I type it correctly... Seems to be an ios bug.

superandrew213 commented 6 years ago

Try restarting your phone and disable InAppUtils.receiptData

brunolemos commented 6 years ago

Unfortunately didn't work. Infinite loop is still there, even after closing the app...

brunolemos commented 6 years ago

Maybe it's this: https://stackoverflow.com/a/24954219/2228575

Maybe there is some place that should call finishTransaction but it's not calling? https://github.com/chirag04/react-native-in-app-utils/blob/6bf387bb2a831f8e097547ca0fe025702d86bfa9/InAppUtils/InAppUtils.m#L61-L74

brunolemos commented 6 years ago

So, I added a console.log: NSLog(@"xxx updatedTransactions %i", queue.transactions.count);

It's showing there are more than 40 transactions in the queue! But all of them with SKPaymentTransactionStateRestored state.

It definitely seems to be related to finishTransaction not being called somewhere or something like that. Right?

If I tap Cancel 40 times it stops showing the alert, but if I click to restore again they come back.

superandrew213 commented 6 years ago

After you clear the queue, if you press restore once, you get 40 transactions in the queue?

chirag04 commented 6 years ago

@brunolemos if you have 40 transaction in the queue then it means you were testing something and killed/crashed the app before the transaction finished. You will have to manually clear the queue for now

brunolemos commented 6 years ago

After you clear the queue, if you press restore once, you get 40 transactions in the queue?

Not 40, but a lot of them (~6?).

You will have to manually clear the queue for now

Do you mean by code? But what if the users get in this state? I'd like to do some fix that would work for them too

PS there is a possibility this won't happen on production. Found some people saying this may be a bug related to testflight

chirag04 commented 6 years ago

there is a possibility this won't happen on production

Yes. that's the idea. Your app won't be approved by apple if this is happening systematically.

brunolemos commented 6 years ago

Just another info, this is happening to me and all the team that tested (another 2 people) that are not developers

chirag04 commented 6 years ago

i would suggest adding a break point in that switch and see if it's going in a case where we don't have finishTransaction. obviously queue should be flushed before this break point to isolate the problem. you can comment out callback calls to let the queue flush itself first.

jeffie commented 6 years ago

It seems a bug for iOS11,you can try like this, This is what worked for me: https://stackoverflow.com/questions/46257633/ios-11-is-in-app-purchase-testing-using-a-sandbox-user-keeps-asking-to-sign-in

RomanVolkov commented 6 years ago

when you ask for StoreKit to restore purchases it places all previous transaction ins queue. and they should be finished again too

awchang56 commented 6 years ago

I've had this affecting my phone for months. and I found a post that said, if your restore purchases button in your app is working correctly. Run the app on the affected that you think caused the sandbox sign-in required alert, tap the restore purchases button in your app, and it should fix it once and for all, if somehow you do something to make it come back again, you can just do the same thing, hit restore purchases and it should go away again. it's like hitting the reset button. Before doing this, I had exactly 55 alerts that would pwn my phone for 45 straight seconds of tapping and it would happen once or twice a day. Now it never happens. I hope this is helpful.

stack overflow reference