Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App Store login popup appearing all the time! #307

Closed
4 of 9 tasks
funkenstrahlen opened this issue Nov 23, 2017 · 63 comments
Closed
4 of 9 tasks

App Store login popup appearing all the time! #307

funkenstrahlen opened this issue Nov 23, 2017 · 63 comments
Labels
status: needs analysis community analysis is needed

Comments

@funkenstrahlen
Copy link

funkenstrahlen commented Nov 23, 2017

Platform

  • iOS
  • macOS
  • tvOS

In app purchase type

  • Consumable
  • Non-consumable
  • Auto-Renewable Subscription
  • Non-Renewing Subscription

Environment

  • Sandbox
  • Production

Version

0.11.0

Related issues

Report

Issue summary

I call verifyReceipt and verifySubscription in applicationDidFinishLaunchingWithOptions to verify that the user is still a valid subscriber of my premium service.

Right now in Test Flight beta testing I see the App Store login alert popping up every time I open the app. This is very annoying.

Is there a better best practise way to verify subscription status? I know Apple recommends doing this via my own server, but I do not want to go this way.

What did you expect to happen

No popup to sign in. Verification runs in the background.

What happened instead

Right now in Test Flight beta testing I see the App Store login alert popping up every time I open the app.

@arslanraza
Copy link

@funkenstrahlen I am facing the same issue. Were you able to find a fix for this one yet ?

@funkenstrahlen
Copy link
Author

I could not find out the source of the issue. It looks like it does refresh the receipt from the App Store. However after looking at the code this should not happen because the receipt is already stored on disk.

I will try to find out more via debugging.

@SirComet
Copy link

SirComet commented Dec 6, 2017

I had the same issue, its an issue of sandbox I think because once in production it doesn't happen.

just make sure you are verifying in production and not in sandbox.

@funkenstrahlen
Copy link
Author

funkenstrahlen commented Dec 6, 2017

@SirComet Thank you for your answer! How can I be sure this does not happen in production too? There seems to be no way to test this via Testflight because this will use the Sandbox backend too. I really do not want to release my app as long as I can not be sure this works correctly because it is extremely annoying for the users.

@funkenstrahlen
Copy link
Author

funkenstrahlen commented Dec 7, 2017

I read about a way to test this but have not confirmed yet:

  • change release settings to manual release
  • submit app in iTunes connect for review
  • wait for approval
  • create promo code to install the unreleased app version on your device
  • test subscriptions

@funkenstrahlen
Copy link
Author

I did some debugging on this. Subscription verification runs with the commands listed above perfectly fine and seems to have nothing to do with the login popup.

I found a suggestion that I have an unfinished transaction. However I can not see any transaction being passed to me in applicationDidBecomeActive. I also am sure to finish all transactions correctly.

Any further ideas?

@quytruong1808
Copy link

quytruong1808 commented Dec 13, 2017

Thank @funkenstrahlen
I have the same issue. And I don't want to release to production until someone can confirm that problem is from sandbox env.

@funkenstrahlen
Copy link
Author

funkenstrahlen commented Dec 13, 2017

  • Its not caused by refreshing the receipt in background from iTunes. The popup even occurs when I remove all of my IAP code.
  • I did not use a separate sandbox account to test the subscription IAP. I downloaded the app from TestFlight and used my normal account as it is possible according to Apple. This will also use the sandbox backend tough.
  • I checked for unfinished transactions: Nothing. I even called restoreTransactions to replay all transactions and finish them in case, but everything looks correct.

The request for password I see is for my actuall AppleID but in the sandbox environment.

The weird thing is: This seems to happen very randomly. Sometimes it takes 20s after I launch the app until the popup occurs. All of my code that has something to do with subscriptions is finished already (verified through logging). I feel like my code has NOTHING to do with this popup.

I did not have this issue before working with IAP. However even installing an old version from TestFlight which does not have any IAP in it does bring up the popup now.

I am really out of ideas why this does happen.

@funkenstrahlen funkenstrahlen changed the title [Question] How to verify subscription best practise? App Store login popup appearing all the time! Dec 13, 2017
@zdesiree
Copy link

Same problem here, I hoped this has something todo with the sandbox environment and submitted the app anyway but Apple rejected it because of "Unable to access app due to 'Sign In to iTune Store' prompt". When I remove all my IAP code it stops appearing. Happy for any help and suggestions.

@bizz84
Copy link
Owner

bizz84 commented Dec 20, 2017

@funkenstrahlen thank you for the report and apologies for the late reply.

Yes, the login popup is something that I have previously seen myself and I suspect it is to do with unfinished transactions. I have even seen it appearing randomly while using other apps, likely because once a purchase is started, it can continue even if the app is backgrounded or killed.

Like everyone else, I don't have clear reproduction steps and I haven't found a reliable way of testing this in sandbox / production.

I'll try to spend a bit of time on this and see if I can be of any help.

@bizz84 bizz84 added the status: needs analysis community analysis is needed label Dec 20, 2017
@funkenstrahlen
Copy link
Author

When I remove all my IAP code it stops appearing.

Interesting. This did not have the same effect for me.

Yes, the login popup is something that I have previously seen myself and I suspect it is to do with unfinished transactions.

This was also my initial thought and is also suggested on many forum threads. However how can I debug this? All approaches to find out what's going on did not help:

I added logging to my code in App Delegate that does check for new unfinished transactions. It does reliably get called when the subscription does auto renew and it finishes the transaction. I can confirm it finished because it does not appear in the queue again.

I also can confirm the popup is not related to an unfinished transaction that is hanging in the queue because of messing around with iTunes Connect sandbox users. I see this error also on test devices that only have seen the app version I released via Test Flight. On these devices I only use the main device Apple ID to test the IAP. On these devices the popup does also appear very often.

Very weird: Even after removing the app from my devices I still sometimes see the popup requesting a login?! This really confuses me.

Previously I talked about this approach to test in production:

I read about a way to test this but have not confirmed yet:
change release settings to manual release
submit app in iTunes connect for review
wait for approval
create promo code to install the unreleased app version on your device
test subscriptions

This does only work if the app is not released on the App Store yet. As I am working on an app update to include subscriptions this does not work for me.

@bizz84
Copy link
Owner

bizz84 commented Dec 22, 2017

I discovered a bug in completeTransactions that may (or may not) be relevant. See #322.

@bizz84
Copy link
Owner

bizz84 commented Dec 22, 2017

This issue may be related to #288.

@funkenstrahlen
Copy link
Author

funkenstrahlen commented Dec 22, 2017

This is the code I execute in App Delegate when my app is launched:

    static func completeIAPTransactions() {
        SwiftyStoreKit.completeTransactions(atomically: true) { purchases in
            var isVerifySubscriptionRequired = false
            
            for purchase in purchases {
                if purchase.needsFinishTransaction {
                    SwiftyStoreKit.finishTransaction(purchase.transaction)
                }
                switch purchase.transaction.transactionState {
                case .purchased, .restored, .failed: isVerifySubscriptionRequired = true
                default: break
                }
            }
            
            if isVerifySubscriptionRequired {
                verify(.premiumOneYear)
            }
        }
    }

As I use atomically: true this is probably not the source of my problem.

I basically finish all transactions that require it. Because checking subscription status is done independantly on the receipt.

@bizz84
Copy link
Owner

bizz84 commented Dec 23, 2017

@funkenstrahlen Do your popups look like this?

8 sign-in-to-itunes-store

3 apple-id-verification

I have seen them randomly appearing outside the app.

@funkenstrahlen
Copy link
Author

I run via TestFlight. The popup looks like this for me (explicitly referring to the sandbox environment).

img_0105

I also see the popup in your second screenshot but this only happens when I logout of my regular Apple ID in iOS settings App Store and use a special sandbox testing account. When running in TestFlight I do not see the seconds kind of popup. I also do not feel like the "login in settings" popup is related to the issue.

@bizz84
Copy link
Owner

bizz84 commented Dec 23, 2017

@funkenstrahlen To diagnose your problem, I would try to determine if the login popup is triggered by completeTransactions() or verifyReceipt(). At the moment you call both.

Could you try the following scenarios in AppDelegate and report in which cases the popup appears?

  • Don't call anything
  • Call completeTransactions() only
  • Call verifyReceipt() only

@funkenstrahlen
Copy link
Author

funkenstrahlen commented Dec 23, 2017

@bizz84 I already did have this idea and tried to investigate exactly like this. I learned that even if I do not call anything the popup still appears. See #307 (comment)

Does it help if I also test for the two other cases you mentioned?

@bizz84
Copy link
Owner

bizz84 commented Dec 23, 2017

@funkenstrahlen If you don't call anything and still get a popup then I can only think somehow there is some internal state set by StoreKit at the system level for your app.

Nasty issue this is. It would really help if we could get consistent reproduction steps.

Maybe I'll try to test a few scenarios, write down steps and take screenshots.

@funkenstrahlen
Copy link
Author

@bizz84 Yes this is really a difficult issue because it is so hard to debug.

I am currently running a version of my app on my device directly from the App Store. This version does not contain any IAP code (this is the old version). I do not get the popup at every app launch now. It still does appear from time to time though. It even does popup 10 times repeating then! So weird :O

@bizz84
Copy link
Owner

bizz84 commented Dec 28, 2017

@funkenstrahlen I also noticed the login popup outside the app even though all the transactions are finished.

After some research, I found this:

https://stackoverflow.com/questions/38828163/skpaymentqueue-does-not-finish-skpaymenttransaction-for-an-auto-renewable-subscr

I think what is happening is that auto-renewable subscriptions add new transactions to the queue when they get renewed. This can be particularly annoying in sandbox mode as the durations are compressed:

1 week : 3 minutes
1 month : 5 minutes
2 months : 10 minutes
3 months : 15 minutes
6 months : 30 minutes
1 year : 1 hour

So it could be that StoreKit adds new transactions and these trigger the popup at random times.

This theory is also confirmed as sometimes I get new transactions in completeTransactions for auto-renewable subscriptions I purchased before.

A few things to test:

  • In production, do the subscriptions auto-renew without triggering the login popup if the user is logged in?
  • In sandbox, do we ever get login popups if we configure the app with any IAPs other than auto-renewable subscriptions?

@funkenstrahlen
Copy link
Author

funkenstrahlen commented Dec 29, 2017

@bizz84 You are right. I am aware that auto-renewable subscriptions do automatically renew 6 times in the sandbox environment. I did confirm with logging that the auto-renew process is registered as a new transaction in my app and gets finished successfully. This is why I know I can process new transactions in App Delegate successfully when they actually appear in the queue.

I understand your idea that this can cause the popup to appear even when the app is not running. However I also see this popup after all 6 renew transactions are finished and my app goes back to invalid subscription purchase state because the user is no longer premium.

In sandbox, do we ever get login popups if we configure the app with any IAPs other than auto-renewable subscriptions?

This is actually an interesting question. Let's see if we can find out.

@bizz84
Copy link
Owner

bizz84 commented Dec 29, 2017

@funkenstrahlen I've been doing some testing with a weekly subscription on sandbox.

Test 1

When purchasing a subscription, I got this message:

subscriptionlogic

After the purchase, I've been able to verify that every three minutes I get a new item in the receipt.
However, no transactions show up until I restart the app and completeTransactions() captures them.

Test 2

I purchased a subscription, and logged out of my sandbox account in Settings.

  • After three minutes, no more items were added to the receipt.
  • Restarting the app also didn't capture any more transactions in completeTransactions()

So it looks like signing out stops the subscriptions from renewing (maybe this is what the message about cancelling a subscription in Settings means).


Still, no answer to the random login popups.

@funkenstrahlen
Copy link
Author

funkenstrahlen commented Dec 29, 2017

However, no transactions show up until I restart the app and completeTransactions() captures them.

As far as I know this is how it is supposed to be?

So it looks like signing out stops the subscriptions from renewing (maybe this is what the message about cancelling a subscription in Settings means).

I do not think this is correct. Signing out should have no effect on subscription renewal. However as long as your are signed out you will not get transaction updates in the app of course. When you log back in you should see multiple auto renewals then.

The message about subscription cancelation in Settings is not working in sandbox mode. This message is intended to production use because you can get to your manage subscriptions page from iOS Settings. This is only available for real Apple IDs. Sandbox subscriptions can not be cancelled manually. This is why they stop renewing automatically after 6 renewals.

@daveluong
Copy link
Contributor

Hi, just want to chip in, we've been observing incessant login popup for consumable iap, not subscription. It's been quite a nightmare for our Beta tester as the popup shows 10-20 times a day

@R0uter
Copy link

R0uter commented Jan 14, 2018

Hello there, however I use the non-consumable iap, it also does popup.

And for my experience, it can be reproduce through TestFlight:
1.download your app from tf
2.then you buy iap use your REAL Apple ID
3. once you do it, sign in required even if you are using other app.

( One more thing, my issue seems it only popup when you open the test app and after your network status changed, eg:from wifi to 4G, from 4G to wifi)

@Vaberer
Copy link

Vaberer commented Jan 15, 2018

I have just got into this situation as well. I'll try to explain my use case:
I already have created a non-consumable in-app purchcase on iTunes connect. some time ago. It works without any problem.

I am just implementing subscriptions. After creating a subscription on iTunes connect and testing it with my real account in the app, the popup starts appearing.

Even if I remove all the code related to SwiftyStore Kit, the popup is showing all the time.

I'm really frustrated.

@funkenstrahlen
Copy link
Author

What about the possibility this is no issue in this framework but actually a bug from Apple?

@DanielZanchi
Copy link

DanielZanchi commented Jan 29, 2018

same issue here. Noticed that:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        print("first")      
        SwiftyStoreKit.completeTransactions(atomically: true) { purchases in
            print(purchases.count)
            print("second") //never gets printed
            for purchase in purchases {
                switch purchase.transaction.transactionState {
                case .purchased, .restored:
                    if purchase.needsFinishTransaction {
                        // Deliver content from server, then:
                        SwiftyStoreKit.finishTransaction(purchase.transaction)
                    }
                // Unlock content
                case .failed, .purchasing, .deferred:
                    break
                }
            }
        }

        return true
}

The "second" print never gets printed.

@funkenstrahlen
Copy link
Author

My guess is that the callback only gets called when there is actually a purchase in the queue. Just take a look at the source code. It’s all here.

We can discuss of course if this is a good expected behaviour of this callback or not. But this should be the topic of another thread maybe? What do you think?

@funkenstrahlen
Copy link
Author

I have one user on test flight beta who reported the login popups are fixed since he upgrade to 11.3 beta. I could not test this myself yet though.

@DanielZanchi
Copy link

I'm continuously getting the login popup (sandbox).
If nothing is inside the queue I don't understand where is the problem.

@funkenstrahlen
Copy link
Author

If nothing is inside the queue I don't understand where is the problem.

Now you have reached the same dead end as everybody else in this thread.

@bloodmajik
Copy link

Hi. Wondering if anyone has resolved this issue?!

@R0uter
Copy link

R0uter commented Jan 31, 2018

Sadly, no. However it will go away when user download your app from App Store.

@bloodmajik
Copy link

Is this 100%? That means it only doesn't work on TestFlight?

@R0uter
Copy link

R0uter commented Jan 31, 2018

Sence I published my app to Appstore, it has been 7 days, all good now.......

@bloodmajik
Copy link

One more question: do you receive a lag between sign in and the pop up that says purchase?

@R0uter
Copy link

R0uter commented Jan 31, 2018

sometimes? I don't think so.

@djvolz
Copy link

djvolz commented Jan 31, 2018

I've been dealing with the exact same issues for auto-renewables as everyone else in this thread. Hopefully 11.3 becoming widely available will put this to rest for future IAP implementers.

@ovdm
Copy link

ovdm commented Feb 23, 2018

I have the same issue. I suspect it is because iOS is automatically checking the the app receipt.

When you do an in-app purchase another receipt is added and because of the testing, some or all, of these are signed with your test user id. iOS automatically checks and potentially updates this chain of receipts linked to your app and it needs you to log in so that in can validate the signature on the receipts. But because of the sandbox environment you are somehow not properly logged in, or at least it kicks users out quickly.

I have not found a solution for this

@christophemarois
Copy link

christophemarois commented Mar 7, 2018

I confirm that the bug is fixed on iOS 11.3 (Beta). Careful though; I had to:

  1. Install the beta provisioning certificate on iOS
  2. Install iOS beta
  3. Install xCode beta
  4. Upgrade to macOS High Sierra

just to test it. That's about 15GB of downloads and several hours of idling

@funkenstrahlen
Copy link
Author

Thank you for testing this an letting us know! I really think we can hopefully mark this issue as closed as soon as iOS 11.3 is released.

@funkenstrahlen
Copy link
Author

funkenstrahlen commented Apr 7, 2018

I can confirm this is fixed in iOS 11.3.

@mrleesin
Copy link

mrleesin commented Aug 4, 2018

What about old iPhone models? ((

@vasadulin
Copy link

I have the same problem with annoying requesting password. iOS 11.4.1

@PittCho
Copy link

PittCho commented Sep 28, 2018

I have the same problem with annoying requesting password. iOS 11.4.1
same.

@NunoAlexandre
Copy link

Same issue. Started with iOS 12...

@exevil
Copy link

exevil commented Oct 8, 2018

+1 here.

@wupshaw
Copy link

wupshaw commented Oct 13, 2018

+1 same issue. Worked fine until iOS 12.

@DanijelHuis
Copy link

DanijelHuis commented Oct 24, 2018

When I call this:

SwiftyStoreKit.purchaseProduct(productIdentifier) { result in
}

It first asks me to enter password and then after purchase is complete it shows "Sign-In Required alert". Purchase is OK even if I tap cancel on second alert. I am testing with sandbox user on iOS 12.

I have tried purchasing product in another app that doesn't use this library but native StoreKit implementation, behavior is the same. It seems Apple messed something on iOS 12, at lease on sandbox.

Edit: I've done some tests

Test 1: iOS 10.3.3, sandbox user, iphone 5, SwiftyStoreKit
Result: OK, login popup appears only once

Test 2: iOS 12.0.1, sandbox user, iphone 7, SwiftyStoreKit
Result: NOK, login popup always appears two times after each purchase

Test 3: iOS 12.0.1, sandbox user, iphone X, SwiftyStoreKit
Result: OK, login popup appears only once

Test 4: iOS 12.0.1, sandbox user, iphone 7, StoreKit
Result: NOK, login popup always appears two times after each purchase

Conclusion: Test 3 is interesting bcs I thought this was related to iOS 12, but it seems it is also related to some other factor. The difference is that I am using iphone 7 privately and it is tied to my icloud account, also I am using it with my normal itunes account for purchases.

I hope this only happens on sandbox environment.

@exevil
Copy link

exevil commented Oct 25, 2018

@DanijelHuis: Try to remove your app from your iPhone 7 and Log Out from both of your normal and sandbox accounts in Settings.

@SohaibSiddique
Copy link

Platform

  • iOS
  • macOS
  • tvOS

In app purchase type

  • Consumable
  • Non-consumable
  • Auto-Renewable Subscription
  • Non-Renewing Subscription

Environment

  • Sandbox
  • Production

Version

0.11.0

Related issues

Report

Issue summary

I call verifyReceipt and verifySubscription in applicationDidFinishLaunchingWithOptions to verify that the user is still a valid subscriber of my premium service.

Right now in Test Flight beta testing I see the App Store login alert popping up every time I open the app. This is very annoying.

Is there a better best practise way to verify subscription status? I know Apple recommends doing this via my own server, but I do not want to go this way.

What did you expect to happen

No popup to sign in. Verification runs in the background.

What happened instead

Right now in Test Flight beta testing I see the App Store login alert popping up every time I open the app.

Hello,
it's late but asking,
how can you handle user verification? it's on user default or any other method?
and which values you get from receipt and verify subscription to the check user still you premium user?

@denirorobert
Copy link

@m-afham
Copy link

m-afham commented Jul 22, 2020

OS: macOS 10.15.5
XCode : 11.2.1
Environment: SandBox, Production
Is I am logged in with apple id while testing? (Yes)

I am getting this each time when I called verifyReceipt method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs analysis community analysis is needed
Projects
None yet
Development

No branches or pull requests