SKPaymentQueue addTransactionObserver 在应用内购买后启动时要求输入 App Store 密码
我的应用程序使用应用内购买,我的大多数用户都可以正常购买,没有任何问题。对于这些人来说,我的应用程序会在购买成功后下载内容,他们很高兴。
然而,对于越来越多的用户来说,一旦他们成功完成应用内购买,此后每次启动应用程序时都会要求他们输入 App Store 密码。我相信这种情况发生在调用:
[[SKPaymentQueue defaultQueue] addTransactionObserver:observer];
我根据Apple应用程序内购买指南中的步骤6调用启动时:
- 存档指南:https://web.archive.org/web/20130515222703/https ://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/StoreKitGuide/AddingaStoretoYourApplication/AddingaStoretoYourApplication.html
- 实际指南:https://developer.apple.com/library/content/ Documentation/NetworkingInternet/Conceptual/StoreKitGuide/Chapters/DeliverProduct.html#//apple_ref/doc/uid/TP40008267-CH5-SW4
我的猜测是,由于某种原因,Apple 的应用内购买服务器没有注册交易成功完成 - 即使我
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
在交易完成并且我的内容已成功下载时调用。
2 个问题:
还有其他人看到这个吗?
有人有建议的修复吗?
赏金编辑:
这是使用不同 Apple-ID 进行的交易。这就是为什么除非您在对话框中输入正确的凭据,否则它无法完成。问题应该是:
- 我怎样才能防止这种死交易(交易尚未完成,用户没有网络,同时更改App-ID)?
- 如何修剪
SkPaymentQueue
?
My app is using in-app purchases, and most of my users can purchase just fine without any problems. For these folks, my app downloads the content after the purchase succeeds and they are happy.
However, for a growing number of my users, once they complete a successful in-app purchase they are being asked for their App Store password every time the app starts up after that. I believe this is happening on the call to:
[[SKPaymentQueue defaultQueue] addTransactionObserver:observer];
which I am calling on startup in accordance with step 6 in Apple's in-app purchase guide:
- archived guide: https://web.archive.org/web/20130515222703/https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/StoreKitGuide/AddingaStoretoYourApplication/AddingaStoretoYourApplication.html
- actual guide: https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/StoreKitGuide/Chapters/DeliverProduct.html#//apple_ref/doc/uid/TP40008267-CH5-SW4
My guess is that, for some reason, Apple's in-app purchase servers aren't registering that the transaction finished successfully - even though I call
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
when the transaction is completed and my content has been successfully downloaded.
2 questions:
Is anyone else seeing this?
Does anyone have a suggested fix?
BOUNTY EDIT:
Its a transaction which was made with a different Apple-ID. Thats why it cannot be finished unless you type in the right credentials into the dialog. The Question should be either:
- How can I prevent such dead transactions (transaction has not been finished, user has no network, meanwhile changes App-ID)?
- How can you prune the
SkPaymentQueue
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(14)
我遇到了同样的问题。请确保您调用
了交易的所有三种状态:SKPaymentTransactionStatePurchased、SKPaymentTransactionStateRestored、SKPaymentTransactionStateFailed。
I had the same problem.make sure that you call
for all three states of the transactions: SKPaymentTransactionStatePurchased, SKPaymentTransactionStateRestored, SKPaymentTransactionStateFailed.
我遇到了同样的问题,即在通话时出现登录提示:
即使我没有使用我的应用程序(在主屏幕或其他应用程序中),它也会时不时地出现,这真的很烦人。环顾四周,似乎有很多关于这个问题的建议答案,但我终于从我收集的内容的组合中找到了解决方案。
注意:在执行步骤 1 之前,我已在 iTunes Connect 中删除了测试沙盒帐户。我不确定这是否会影响解决方案。
为了解决这个问题,我这样做了:
就是这样。从那时起,每当我运行我的应用程序时,登录提示就会停止出现,并且也会随机停止出现。
希望这有帮助!
I had the same problem of having the login prompt coming up at the call:
It would also come up every now and then even when I wasn't using my app (on the home screen or in other apps), which was really annoying. Looking around, there seem to be so many suggested answers to this issue but I finally found a solution from a combination of what I've gathered.
Note: Before step 1, I had removed the test sandbox account in iTunes Connect. I'm not sure if that would affect the solution.
To solve the problem this is what I did:
That's it. From then on the login prompt stopped coming up whenever I ran my app and also stopped coming up at random times.
Hope this helps!
请勿删除此处的答案。正是这个特定的 Stackoverflow 问题误导了我,让我困惑了好几天。
我将其放在这里是因为有很多非常糟糕的答案提供了有关如何解决问题的错误信息。
不要:
要做:
就这样,完成所有交易!否则,每次您的应用程序在该设备上启动时,您都会陷入登录请求的无休止循环的地狱。
DO NOT DELETE THE ANSWER HERE. It was this particular Stackoverflow question that misled me and messed me up for days.
I'm putting this here because there are a lot of really bad answers that provide WRONG information on how to resolve the problem.
DO NOT:
DO:
That's it, Finish all transactions! Else you will be sent to the hell of the Endless Loop of sign in requests every single time your App launches on that device.
有一个问题叫做“死循环”。在汽车可再生能源的早期,这是一个大问题,当时大约一周,服务器没有将续订限制为 5 次。获取交易但不调用 finishTransaction 的设备将将该交易传送到设备大约一次一周后,该特定测试用户登录并调用 finishTransaction。如果您切换到飞行模式,您可以在一周内“清除”这些交易 - 但它们会回来。
There is a problem called the "endless loop". It was big issue back in the early days of auto renewables when, for about a week, the servers did not limit renewals to 5. A device that gets a transaction and doesn't call finishTransaction will get that transaction delivered to the device about once a week until that particular test user logs in and calls finishTransaction. If you switch to airplane mode you can 'clear' those transactions for another week - but they come back.
我怀疑这是正确的行为。当您设置委托 SKPaymentQueue 时,尝试检查是否有一些事务需要完成。可能没有未完成的交易,但检查需要登录iTunes。我认为你对此无能为力。
它通常有一定的意义,但对于在每次交易时都要求输入密码的用户来说(例如某些儿童保护),这非常烦人。因此,解决这个问题的唯一方法是在您要请求 iTunes 时显式设置委托。例如,您可以添加一些按钮,例如“恢复我的购买”。不是很漂亮,但绝对不那么烦人。
I suspect that this is a correct behaviour. When you set a delegate SKPaymentQueue try to check if there are some transactions to finalize. There may be no not finished transactions but the fact of checking requires to login in iTunes. And I think you can do nothing with it.
It generally has some sense, but it is pretty annoying for users who have set up asking for a password on each transaction (some child protection for instance). So the only way to struggle with it is to set delegate explicitly when you are about to request iTunes. For example you can add some button like "Restore my purchases". Not very beautiful but definitely less annoying.
如果有人看到此内容并且正在使用 GoogleMobileAds.framework,那么您可能还需要调用
-application:didFinishLaunchingWithOptions:
If anyone is seeing this and is using GoogleMobileAds.framework then you may also need to call
in
-application:didFinishLaunchingWithOptions:
以下是我如何能够一致地重现和解决此问题:
iOS 8.4,应用程序的开发版本。
使用测试(沙盒)Apple 帐户。
恢复购买的交易。
立即关闭应用程序。
注销测试帐户(通过设置)
启动应用程序
现在,每次我启动应用程序时,都会弹出“登录” “ 形式。输入或不输入密码都没关系。我是否进行购买或恢复购买并不重要。如果我删除并重新安装该应用程序也没关系。每次我启动该应用程序时,都会显示 iTunes 登录信息。
修复:硬重启设备。
这是我不知道的。这种情况会在生产环境(已发布的应用程序和实际的苹果登录)中发生吗?我希望不会。
Here's how I can consistently reproduce and resolve this issue:
iOS 8.4, development build of the app.
Use a test(sandbox) Apple Account.
Restore purchased transactions.
Immediately close the app.
Log out of test account (through settings)
Launch app
Now every time I launch the app it will pop up the "login" form. It doesn't matter if I enter the password or not. It doesn't matter if I make purchases or restore the purchases. It doesn't matter if I delete and re-install the app. Every time I launch the app, the iTune login is presented.
Fix: Hard reboot the device.
Here's what I don't know. Will this happen in a production environment (published app and actual apple login)? I hope not.
我在测试IAP时也遇到了同样的问题。
我用3个测试帐户进行了测试。该应用程序不断要求输入两个帐户的密码。即使我没有触摸任何购买/恢复按钮或 addTransactionObserver 。
我认为这是因为之前的某些交易尚未正确完成,但
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
根本无济于事。所以这就是我解决这个问题的方法:
商店询问--我为3个帐户输入6次--直到它不再询问
再次。
灵感来自使用 iTunes 测试用户时的预期顺序
I had the same problem when testing IAP.
I tested with 3 test account. The app kept asking for password for both accounts. Even if I didn't touch any purchase/restore button or
addTransactionObserver
.I think this is because some previous transaction has not finished correctly, but
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
can't help at all.So here's what I did to solve this problem:
store ask for--I input 6 times for 3 account--until it never ask
again.
inspired by Expected sequence when using iTunes test user
删除并重新安装该应用程序将删除与另一个 iTunes 帐户关联的所有旧交易。如果您仍然看到事务发布到通知队列,那么您的逻辑中可能有某个分支没有调用 finishTransaction。
您需要对发布到 paymentQueue:updatedTransactions: 的所有交易调用 finishTransaction,甚至是具有 SKPaymentTransactionStateFailed 的交易。
Deleting and re-installing the app will remove any old transactions associated with another itunes account. If you are still seeing transactions posted to the notification queue, then you likely had some branch in your logic that did not call finishTransaction.
You need to to call finishTransaction on all transactions that are posted to paymentQueue:updatedTransactions:, even ones with SKPaymentTransactionStateFailed.
iOS 更新 5.1.1 中修复了与应用内购买相关的错误
http://support.apple.com/kb/DL1521
bugs related to in app purchases fixed in the iOS update 5.1.1
http://support.apple.com/kb/DL1521
检查以下内容,因为我在 viewDidLoad 方法中有它。当苹果希望我从非消耗性变为消耗性时,我有一个应用程序被拒绝,但是我在 viewDidLoad 方法中留下了以下行:(我认为密码提示是从测试用户切换到普通用户返回到测试用户)
一旦删除,密码请求就会停止。
我已经离开了:
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
该应用程序现已获得批准。
Check for the following as I had it in my viewDidLoad method. I had an app rejected when apple wanted me to go from non-consumable to consumable, however I left the following line in my viewDidLoad method: (I thought the password prompt was a issue with swapping from the test user to normal user back to the test user)
Once removed the request for password stopped.
And I have left:
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
in and the app has now been approved just fine.
您知道,我通过修改 updateTransactions 解决了这个问题。我没有为所有情况添加
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
。You know, I resolved this problem by making a modify in my updatedTransactions. I didn't add the
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
for all situations.我通过删除与此问题相关的 iTunes Connect 测试用户帐户解决了该问题。应用程序实际上再次要求登录,但随后它就消失了(我还删除了应用程序,重新启动iPhone并以普通非沙盒用户身份登录,在其他非沙盒应用程序中进行了真正的恢复,然后启动了该应用程序)
I resolved it by deleting the iTunes Connect test user account related with this issue. App actually asked once again to sign in, but then it disappeared (I've also deleted app, restarted iPhone and logged in as a normal non-sandbox user, made a real restore in other non-sandbox app and then launched the app)
你说:
请注意
add(_observer:
/addTransationObserver: 的文档:
声明调用可能会导致用户通过 App Store 进行身份验证,因此这似乎是预期行为。因此,除了此处的其他答案之外,您可能应该停止调用
addobserver
,直到您准备好潜在地显示应用程序存储登录提示。You said:
Note that the docs for
add(_ observer:
/addTransationObserver:
state that the call may cause the user to authenticate with the App Store, so this appears to be expected behavior.So in addition to other answers here, it may be that you should stop calling
add observer
until you are ready to potentially display an App Store login prompt.