Debugging intermittent failures with Apple IAP - ios

I'm working on an app with Swift 3, XCode 8.1, iOS 10.1.1. I'm testing my in-app purchases on my iPhone. About 30-40% of my purchase attempts are failing with SKError code 0: Cannot connect to iTunes Store. However, I can't figure out the pattern of the failures. IAPs that fail will frequently work if you just try again - same build, no changes, etc.
Things I've checked:
I've verified that the product identifiers are correct, and have successfully purchased each IAP multiple times. There does not appear to be any problem getting the list of available products.
I'm using a sandbox tester (gone through 6 of them at this point), having signed out of my regular account.
I'm on my iPhone, not on Simulator.
I've tried it under different network speeds using the Network Link Conditioner, with no change other than the success/failures happen faster or slower.
My device has plenty of space, and the IAP isn't downloading anything anyway.
Twitter isn't showing any complaints from other people about App Store issues.
This same behavior is happening on two different devices, both iPhone 6.
Each IAP is live and available.
Restoring purchases appears to work every time. I've seen some people on SO have success resetting their device when they can't get any IAP to work, but I'm hesitant to do that when my symptoms seem different.
Any suggestions on how to debug further?

Related

Unity IAP not working in Apple Testflight

Having issues for the past days trying to make the IAP work on TestFlight for my 1st game app.
IAP works fine in Unity Editor (fake store) and also on Google Play (internal test track).
I don't receive any product prices from the apple store and the buy buttons have no effect (no callbacks on ProcessPurchase or OnPurchaseFailed since I show popup windows for both scenarios).
Below is the status of my app and IAP :
From other similar threads everything should be ok and working as TestFlight doesn't require the IAPs to be submitted nor it requires for sandbox users to be manually created.
Any hints on what to further test or how could I check logs/warnings/errors are much appreciated, thanks.
Tools used : Unity 2019.3.0 (IAP 2.0.6) and XCode 11.3.1
Update 1: OnInitializeFailed() is called with NoProductsAvailable err
The reason why the initialization failed with NoProductsAvailable was because I didn't have an active agreement for paid apps, although it is testflight and there are no real money involved, you still need to have this setup.
Here is how it should look like :
Once this was solved the IAPs worked fine.

Unity Codeless IAP IOS build rejected

I have a problem using Unity's codeless API in conjunction with IOS.
Apple keeps rejecting the build with the following message:
Guideline 2.1 - Performance - App Completeness
We found that your in-app purchase products exhibited one or more bugs
when reviewed on iPad running iOS 12.1 on Wi-Fi.
Specifically, no action takes place when we initiate the purchase.
Some notes:
I succesfully built and published the app on android.
The IOS version works with the uploaded build. I can make in app purchases when i run the app on my iphone.
I have filled in all the required legal/ financial information and have a valid contract for purchases as defined in the ios docs.
The build is set as "release" and "development build" is NOT checked.
After rejection by apple, all the in app purchases in the developer console are marked as requiring action.
Specifically it is now showing that the localizations are invalid. However no further information is given. I suspect this is just because the build is rejected?
So, has anyone had a similar problem? Having the app run fine when using the development build on a local phone, but still having it rejected because of the aforementioned reason?
In the end i requested i call with Apple to discuss the rejection of my IOS build(s).
It had been rejected 3/4 times with the same reason.
The reason: A problem on their part. They suspect they had a misconfigured environment on their side, which resulted in a not working build on Ipad.
I did not have to upload a new build, they reused the last rejected one and it was approved within hours of my call.
I suspect that the developers might have been confused, seeing that the app was entirely in dutch. This can seriously cause some confusing, because the representative on the phone had trouble locating some IAP functionality himself like the restore button.
So should you have the same problem:
If your app is in a non-english language, specificy where the reviewers have to click for In App Products, where the Restore button is and similar key parts of your app.
Request a call with Apple if you are sure that you did everything correctly. Talking on the phone with them really helps speed up the review process and clarify any misunderstandings.

Fabric data different from iTunes Connect data

Our Daily New User-count from Fabric is consistently bigger than the App Units per day that we get from iTunes Connect.
Fabric defines Daily New Users as
The number of new app installations across all devices seen on a given
day.
And iTunes connect defines App Units as
The number of first-time app downloads made on the App Store using iOS
8 or tvOS 9, or later. App updates, downloads from the same Apple ID
onto other devices, and redownloads to the same device are not
counted. Family Sharing downloads are included for free apps, but not
for paid apps.
What can cause this discrepancy? I can see many reasons for how Fabric could report a lower number (such as users downloading the app but never opening it, or waiting too long to open it), but not the other way around. Our average send-usage-to-developers opt-in rate is 23%, but that does not affect the App Units number if I am not mistaken.
Is your app available on both iPhone and iPad? If so, then the fact that, as you point out, Apple doesn't count downloads from the same Apple ID onto other devices might be causing this discrepancy? You can install iPhone apps on your iPad even if it's not officially supported, so the rule might still be affecting your app. Also, if your app is a paid app, then the Family sharing rules would also affect the numbers. I've actually wondered how iTunes counts new users, so thanks for that info!
I'm not sure why the numbers are consistently bigger for you on Fabric, because for my app they alternate a bit.
I hope you might have got the answer. If not follow the link below http://help.apple.com/itc/appanalytics/#/itc7bea1545f
It seems there are users who don't opt-in app analytics data.
Apple only shows data from users who have agreed to share their
diagnostics and usage information with app developers.

In-App Purchase fails to unlock content on some devices

We have had users reporting that they have paid for our product via in-app purchase but we have failed to unlock the content. The common denominator between these reports is iOS 9 so far. It seems like the purchase with success method does not get called. The IAP seems to work and even says that the purchase has been restored successfully (Apple's own alert), yet it does not deliver the content (unlocks the app).
This is a very odd bug because it works perfectly fine on iOS 10, and there is no reason why it should't work on other older devices. At some point, we had a customer complain of the same issue with iOS 10 as well and we just can't produce the issue. I am using RMStore for my in app purchases but this has not started since we used this library. It has been happening even with standard IAP integration.
Does anyone knows or may have heard of what causes this issue?
Any tips would be great!
I have several apps on the App Store and I'm facing similar issues. For about 1% of the users, the success callback is not called after an in-app purchase. If the users restore their purchases later, the purchased features unlock properly, so the App Store processed the purchase properly, and this is likely a bug in the app. I could never find the issue as I could not reproduce it on any of my devices.
After I just read that you use RMStore, I checked the emails that my users sent me during the last two years about this issue and noticed that this occurs exclusively with apps that use RMStore. While the code of that library looks really clean, I assume that the bug is somewhere hidden in there.
As RMStore hasn't been updated since almost two years, I consider it deprecated and will remove it from my apps in the near future. I will update this answer if the issue persists after the removal.
Update after three months: After the removal of RMStore for the in-app purchase handling from one of my apps, the problems have apparently disappeared.

"Cannot connect to iTunes store" when restoring iOS In App Purchase in iOS simulator

I've looked through the many existing questions related to "Cannot connect to iTunes store" issues with iOS StoreKit and I don't think my situation is covered:
When running in the iOS Simulator, I get the "Cannot connect to iTunes store" error after restoring a previous bought in app purchase. If I hit Cancel, the popup goes away and the restore is successful.
There is no problem at all when buying the in app purchase, only when restoring.
Also, the problem only occurs on the simulator, not when testing on a real iPhone.
I'm pretty sure everything is OK, just wanted to confirm that it is just a simulator bug. Any one else seen this one?
Having researched this as much as I can, and confirmed that there are no issues when running on a device, either in sandbox mode or (since yesterday, when the IAP was approved by Apple) using a real Apple ID, I'm assuming this is a simulator bug and can be ignored.
Contrary to the answer posted by iLive below, and repeated elsewhere on SO, testing IAP on the simulator is explicitly supported by Apple, except for hosted content downloads.
UPDATE: It would appear that since iOS 7, testing IAP on the simulator is no longer properly supported. I've had it working using the non-64bit simulator, but not with the 64bit iPhone simulator. Your milage may vary. As per pix's comment below, Apple also seem to have removed mention of iOS simulator testing from their documentation.
I do not believe you can test your purchases with the simulator.
From the "In-App Purchase Programming Guide":
Store Kit does not operate in iOS Simulator. When running your application in iOS Simulator, Store Kit logs a warning if your application attempts to retrieve the payment queue. Testing the store must be done on actual devices.
If you look at this link, Apple tells you about what you should do:
http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/StoreKitGuide/DevelopingwithStoreKit/DevelopingwithStoreKit.html
You can also check out this link: restore button for in-app purchases error
Hope this helped!
I ran into the same problem. I would get the "Cannot connect to iTunes Store". If you press Retry it will send you to the login prompt. However, if you press cancel, you will get "Restore Purchases Successful". This does seem limited to the simulator.
https://developer.apple.com/library/ios/releasenotes/DeveloperTools/RN-Xcode/index.html#//apple_ref/doc/uid/TP40001051-SW241
StoreKit (In-App purchases) will not work in the Simulator. 13962338
Make sure you use an account which is an sandbox user. I tried to use my personal iCloud account on Sandbox which got rejected with the same error.
As of recent (Version 8 and onwards) Xcode releases, I'd qualify the state of StoreKit in the simulator as partially implemented.
Apple officially says you need to test it on the device, however some calls seem to supported in the Simulator – at least the SKProductRequest always works flawlessly. Completing a purchase may or may not work.

Resources