SKPaymentQueue addTransactionObserver 在应用内购买后启动时要求输入 App Store 密码

发布于 2024-10-17 18:36:31 字数 1587 浏览 7 评论 0原文

我的应用程序使用应用内购买,我的大多数用户都可以正常购买,没有任何问题。对于这些人来说,我的应用程序会在购买成功后下载内容,他们很高兴。

然而,对于越来越多的用户来说,一旦他们成功完成应用内购买,此后每次启动应用程序时都会要求他们输入 App Store 密码。我相信这种情况发生在调用:

[[SKPaymentQueue defaultQueue] addTransactionObserver:observer];

我根据Apple应用程序内购买指南中的步骤6调用启动时:

我的猜测是,由于某种原因,Apple 的应用内购买服务器没有注册交易成功完成 - 即使我

[[SKPaymentQueue defaultQueue] finishTransaction:transaction];

在交易完成并且我的内容已成功下载时调用。

2 个问题:

  1. 还有其他人看到这个吗?

  2. 有人有建议的修复吗?

赏金编辑

这是使用不同 Apple-ID 进行的交易。这就是为什么除非您在对话框中输入正确的凭据,否则它无法完成。问题应该是:

  1. 我怎样才能防止这种死交易(交易尚未完成,用户没有网络,同时更改App-ID)?
  2. 如何修剪 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:

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:

  1. Is anyone else seeing this?

  2. 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:

  1. How can I prevent such dead transactions (transaction has not been finished, user has no network, meanwhile changes App-ID)?
  2. How can you prune the SkPaymentQueue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(14

软甜啾 2024-10-24 18:36:31

我遇到了同样的问题。请确保您调用

[[SKPaymentQueue defaultQueue] finishTransaction:transaction]; 

了交易的所有三种状态:SKPaymentTransactionStatePurchased、SKPaymentTransactionStateRestored、SKPaymentTransactionStateFailed。

I had the same problem.make sure that you call

[[SKPaymentQueue defaultQueue] finishTransaction:transaction]; 

for all three states of the transactions: SKPaymentTransactionStatePurchased, SKPaymentTransactionStateRestored, SKPaymentTransactionStateFailed.

空气里的味道 2024-10-24 18:36:31

我遇到了同样的问题,即在通话时出现登录提示:

[[SKPaymentQueue defaultQueue] addTransactionObserver:observer];

即使我没有使用我的应用程序(在主屏幕或其他应用程序中),它也会时不时地出现,这真的很烦人。环顾四周,似乎有很多关于这个问题的建议答案,但我终于从我收集的内容的组合中找到了解决方案。

注意:在执行步骤 1 之前,我已在 iTunes Connect 中删除了测试沙盒帐户。我不确定这是否会影响解决方案。

为了解决这个问题,我这样做了:

  1. 从 Xcode 运行你的应用程序。
  2. 等待提示出现。输入所需帐户的密码,然后点击“确定”。
  3. 按设备上的主页按钮。
  4. 从 Xcode 中终止该应用程序。
  5. 从设备中删除该应用程序。
  6. 退出 iTunes 和设置应用程序中的应用程序商店。
  7. 关闭设备,然后重新打开。
  8. 从 App Store 购买一些东西。当系统提示您时,使用生产 Apple ID 帐户登录。 (我假设您应该能够在“设置”应用程序下的 iTunes 和 App Store 中使用生产帐户登录,但这就是我的做法)。
  9. 返回 Xcode 并再次运行您的应用程序。 (这应该是新安装,因为您之前删除了该应用程序。)
  10. 等待登录提示出现。
  11. 点击取消。应该会出现一个对话框,显示“需要登录。点击继续并登录以检查下载。[环境:沙盒]”。这是与以前的一个关键区别。当我按“取消”时,当它要求我输入密码时,我从未出现过此对话框。
  12. 点击继续。
  13. 输入帐户的密码。

就是这样。从那时起,每当我运行我的应用程序时,登录提示就会停止出现,并且也会随机停止出现。

希望这有帮助!

I had the same problem of having the login prompt coming up at the call:

[[SKPaymentQueue defaultQueue] addTransactionObserver:observer];

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:

  1. Run your app from Xcode.
  2. Wait for the prompt to come up. Type in the password for the account it wants and tap OK.
  3. Press the Home button on the device.
  4. Kill the app from Xcode.
  5. Delete the app from the device.
  6. Log out of iTunes & App Store in the Settings app.
  7. Turn off the device and then turn it back on.
  8. Purchase something from the App Store. When it prompts you, log in with a production Apple ID account. (I'm assuming you should be able to just log in with a production account in iTunes & App Store under the Settings app but this is how I did it).
  9. Go back to Xcode and run your app again. (This should be a new install, as you deleted the app before.)
  10. Wait for the login prompt to come up.
  11. Tap Cancel. A dialog saying "Sign In Required. Tap Continue and sign in to check for downloads. [Environment: Sandbox]" should come up. This was a key difference from before. I never had this dialog come up when I pressed Cancel when it was asking me for the password.
  12. Tap Continue.
  13. Enter the password for the account.

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!

晨敛清荷 2024-10-24 18:36:31

请勿删除此处的答案。正是这个特定的 Stackoverflow 问题误导了我,让我困惑了好几天。

我将其放在这里是因为有很多非常糟糕的答案提供了有关如何解决问题的错误信息。

不要:

  • 删除沙箱测试用户。这使得问题无法解决,您必须联系 Apple 开发者支持来手动解决。
  • 如果删除沙盒测试用户,当随后反复提示您以该用户身份登录并完成交易时,您将无法完成交易,因此被称为无限循环问题。您也无法再次添加已删除的测试用户;开发者门户显示该用户 ID 已被使用。
  • 删除应用程序或重新安装 iOS 或任何其他此类废话。没有效果,没有解决问题,还浪费很多时间。

要做:

  • 对所有事务调用“完成”。
  • 如果由于某种原因被中断,只需在应用程序的后续运行中完成即可。该应用程序将重复发送付款队列通知,直到您调用完成为止:

[[SKPaymentQueue defaultQueue] finishTransaction:交易];

就这样,完成所有交易!否则,每次您的应用程序在该设备上启动时,您都会陷入登录请求的无休止循环的地狱。

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:

  • Delete the sandbox test user. This makes it impossible to resolve the problem and you will have to contact Apple developer support to resolve manually.
  • If you delete the sandbox test user, when you are subsequently repeatedly prompted to log in as that user and complete the transaction, you can't, hence the name Endless Loop problem. Nor will you be able to add the deleted test user again; the developer portal says the user id has already been used.
  • Delete the App or re-install iOS or any other such nonsense. It has no effect, doesn't solve the problem and wastes a lot of time.

DO:

  • Call Finish for ALL transactions.
  • If one is interrupted for some reason, simply complete on a subsequent run of the App. The app will be repeatedly sent the payment queue notice until you call finish on it:

[[SKPaymentQueue defaultQueue] finishTransaction:transaction];

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.

回忆凄美了谁 2024-10-24 18:36:31

有一个问题叫做“死循环”。在汽车可再生能源的早期,这是一个大问题,当时大约一周,服务器没有将续订限制为 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.

ぇ气 2024-10-24 18:36:31

我怀疑这是正确的行为。当您设置委托 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.

紫﹏色ふ单纯 2024-10-24 18:36:31

如果有人看到此内容并且正在使用 GoogleMobileAds.framework,那么您可能还需要调用

[GADMobileAds disableAutomatedInAppPurchaseReporting];

-application:didFinishLaunchingWithOptions:

If anyone is seeing this and is using GoogleMobileAds.framework then you may also need to call

[GADMobileAds disableAutomatedInAppPurchaseReporting];

in -application:didFinishLaunchingWithOptions:

无声情话 2024-10-24 18:36:31

以下是我如何能够一致地重现和解决此问题:

iOS 8.4,应用程序的开发版本。

  1. 使用测试(沙盒)Apple 帐户。

  2. 恢复购买的交易。

    [[SKPaymentQueuedefaultQueue]restoreCompletedTransactions]
    
  3. 立即关闭应用程序。

  4. 注销测试帐户(通过设置)

  5. 启动应用程序

现在,每次我启动应用程序时,都会弹出“登录” “ 形式。输入或不输入密码都没关系。我是否进行购买或恢复购买并不重要。如果我删除并重新安装该应用程序也没关系。每次我启动该应用程序时,都会显示 iTunes 登录信息。

修复:硬重启设备。

这是我不知道的。这种情况会在生产环境(已发布的应用程序和实际的苹果登录)中发生吗?我希望不会。

Here's how I can consistently reproduce and resolve this issue:

iOS 8.4, development build of the app.

  1. Use a test(sandbox) Apple Account.

  2. Restore purchased transactions.

    [[SKPaymentQueue defaultQueue] restoreCompletedTransactions]
    
  3. Immediately close the app.

  4. Log out of test account (through settings)

  5. 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.

涙—继续流 2024-10-24 18:36:31

我在测试IAP时也遇到了同样的问题。

我用3个测试帐户进行了测试。该应用程序不断要求输入两个帐户的密码。即使我没有触摸任何购买/恢复按钮或 addTransactionObserver 。

我认为这是因为之前的某些交易尚未正确完成,但 [[SKPaymentQueue defaultQueue] finishTransaction:transaction]; 根本无济于事。

所以这就是我解决这个问题的方法:

  1. 无论应用多少次,都输入每个帐户的密码
    商店询问--我为3个帐户输入6次--直到它不再询问
    再次。
  2. 进入设置并注销Apple ID。
  3. 正常退出应用程序——不要在 Xcode 中终止它。然后杀死任务列表中的进程。
  4. 从设备中删除应用程序(仅删除应用程序将不起作用,它仍然会要求输入密码)
  5. 重新启动设备
  6. 从 Xcode 再次运行应用程序/在您的情况下从应用程序商店重新安装应用程序。

灵感来自使用 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:

  1. input the password for each account no matter how many times app
    store ask for--I input 6 times for 3 account--until it never ask
    again.
  2. go to the setting and sign out the apple ID.
  3. quit the app normally--don't terminate it in Xcode. then kill the process in task list.
  4. remove the app from device (simply remove the app won't work it'll still ask for password )
  5. reboot the device
  6. Run the app again from Xcode/in your case reinstall the app from app store.

inspired by Expected sequence when using iTunes test user

木槿暧夏七纪年 2024-10-24 18:36:31

删除并重新安装该应用程序将删除与另一个 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.

绾颜 2024-10-24 18:36:31

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

超可爱的懒熊 2024-10-24 18:36:31

检查以下内容,因为我在 viewDidLoad 方法中有它。当苹果希望我从非消耗性变为消耗性时,我有一个应用程序被拒绝,但是我在 viewDidLoad 方法中留下了以下行:(我认为密码提示是从测试用户切换到普通用户返回到测试用户)

[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];

一旦删除,密码请求就会停止。

我已经离开了:[[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)

[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];

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.

一抹淡然 2024-10-24 18:36:31

您知道,我通过修改 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.

oО清风挽发oО 2024-10-24 18:36:31

我通过删除与此问题相关的 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)

埖埖迣鎅 2024-10-24 18:36:31

你说:

但是,对于越来越多的用户来说,一旦他们成功完成应用内购买,之后每次启动应用时都会被要求提供 App Store 密码。我相信这是在调用时发生的:

[[SKPaymentQueue defaultQueue] addTransactionObserver:observer];

请注意 add(_observer: / addTransationObserver: 的文档: 声明调用可能会导致用户通过 App Store 进行身份验证,因此这似乎是预期行为。

// 不保留观察者。当队列有观察者时,事务数组只会与服务器同步。 这可能需要用户进行身份验证。

open func add(_observer: SKPaymentTransactionObserver)
open func remove(_observer: SKPaymentTransactionObserver)

因此,除了此处的其他答案之外,您可能应该停止调用 addobserver ,直到您准备好潜在地显示应用程序存储登录提示。

You said:

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];

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.

// Observers are not retained. The transactions array will only be synchronized with the server while the queue has observers. This may require that the user authenticate.

open func add(_ observer: SKPaymentTransactionObserver)
open func remove(_ observer: SKPaymentTransactionObserver)

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文