Solved

Randomly and false-zero-Entitlements returned from purchaseProduct:withCompletion

  • 22 October 2021
  • 69 replies
  • 931 views


Show first post

69 replies

Userlevel 3
Badge +5

Yeah, it would be easier if this were widespread, but unfortunately we haven’t had anyone else report something of this severity. 


Could be conflicting extensions, could be a race condition or something off about your integration with us. 

Have you shared code samples with us? That’s why I suggested a little pairing session. There might be something innocuous that one of our engineers could figure out. We don’t generally offer this, but in this case we’ve pretty much exhausted other investigation methods.

Userlevel 3
Badge +8

I do appreciate the generous offer, I have one file that has all your API, so your world is contained.  Let us do that, I am ready…

Userlevel 3
Badge +8

@taquitos I opened a ticker as you mentioned.  Happy to share code or change it and see what is happening.  What should I do next?  It is a form that I filled and submitted, not sure what is next

I am attaching a legitimate error I hope from one user, the user didn’t complain but I always get an attachment with the latest error and I thought to share it with you guys.

@taquitos I opened a ticker as you mentioned.  Happy to share code or change it and see what is happening.  What should I do next?  It is a form that I filled and submitted, not sure what is next

I am attaching a legitimate error I hope from one user, the user didn’t complain but I always get an attachment with the latest error and I thought to share it with you guys.

That’s perfect, I think @cody is going to dig in some more. 

 

@imougy I’m a huge fan of this suggestion. Could you open a new topic here and include what you’d like the API to look like and what you’d want to get from it? I bet there are other folks who might want to add their $0.02 😄

Userlevel 5
Badge +8

@imougy I’m going through all the code, logs and comments to get a better understanding, and would love to set up a live coding session so we can finally figure this out. 

 

Before that, just a question: are you using any other SDK / plugin in your app, or otherwise do you have any date extensions in your code? 

 

I want to set up a testing up with as similar a setup as you have as possible to see if I can reproduce locally, which would be immensely helpful

Userlevel 3
Badge +8

I am using swift manager to install Hero, Firebase, RevenueCat. I can share with you the date extension, but I don’t think this is the reason because the issue happens to all users, me included and I am in USA region. 
please feel free to set up the love coding session and I can also send you my date extensions if you like. 

Badge

@taquitos ,

 

After taking a look at our code, we noticed we are using the Datadog SDK, which has a similar extension on ISO8601Formatter signature as the RevenueCat SDK (both of them have the class conform to a protocol of the same name)  (https://github.com/DataDog/dd-sdk-ios/blob/9cdb8fe7615949554e8a6af2ddbe2857050fed35/Sources/Datadog/Core/Utils/DateFormatting.swift)

Do you think this could cause any issues?

Userlevel 3
Badge +8

I have no way to reproduce, it is pure random. What I can do is grab this branch and make a new App Store binary and see if users complain.  Btw, beta 8 reduced the issue by a lot but it still happens. 
what do you think? Should I grab this branch and make a new App Store release?

Oh wow! Yeah, maybe that could do it. We recently rewrote our iso8601DateFormatter to use the newer `ISO8601DateFormatter`, but haven’t released a beta with it include: https://github.com/RevenueCat/purchases-ios/blob/main/Purchases/FoundationExtensions/DateFormatter%2BExtensions.swift

We’re still finishing up the last bit of StoreKit2 additions and then we’ll release another Beta. Are you able to test out this theory building from `main`?

Userlevel 5
Badge +8

@imougy let’s hold off from using the branch in that case, and set up a coding session. Do you have some time tomorrow or early next week? What timezone are you in? 

Userlevel 3
Badge +8

@Andy sounds good tomorrow anytime.  I am PST time. Thank you so much.

Userlevel 5
Badge +8

Awesome! I’ll DM you to coordinate the exact date / time. 

 

Also, do you happen to know the OS version in use by the folks who’re still facing the issue? I think the date formatter we’re using might have some issues with iOS 11.0-11.2

Userlevel 3
Badge +8

@taquitos Another user error, he is a subscriber but can’t see anything.

Good luck!

Ooof, this new error is actually on Apple’s server. They do some weird stuff with errors that makes it difficult to fully understand what the problem is sometimes, but we have a thread open on it and are going to work on a workaround, you can follow along: https://github.com/RevenueCat/purchases-ios/issues/392#issuecomment-804996692

I was able to chase down the exact response that was sent when your customer encountered: 

RevenueCat LastError: Error Domain=RevenueCat.ErrorCode Code=12 "Received malformed response from the backend." UserInfo={generated_by=<snip> getSubscriberData(appUserID:completion:), NSUnderlyingError=0x2823f5f50 {Error Domain=RevenueCat.UnexpectedBackendResponseSubErrorCode Code=8 "(null)" UserInfo={NSUnderlyingError=0x280c84c80 {Error Domain=RevenueCat.CustomerInfoError Code=1 "(null)"}

The json is ok and I can manually instantiate the objects with the exact response. I met with @Andy to discuss this and we walked through the code again. The only places where we could generate this error is if:
“subscriberData["first_seen"]” is empty, or the date format is incorrect.
OR:
“subscriberData["original_app_user_id"]” is nil.
Both of these conditions were ok in the response!
So that leaves us with some questions: what other sdks do you current use? Do you have any of your own Date extensions that you’re using? The thought is that maybe you’re using an SDK that could: 
1) swizzle some of the foundation date parsing stuff (we’ve seen it)
2) have the same named Date extension so runtime resolution of the extension is non-determinate.

We really appreciate you tracking this stuff down with us. At this point, I’ve added yet more error handling to a new pr, but I think something outside our control is going on since the exact json responses that are causing issues for you are not causing issues in my testing. If I could repro this, it would be so much easier 😔

 

 

 

Badge

@taquitos ,

I didn’t even realize that change was not in beta-7! So ignore my previous post. Because it turns out the rewrite wasn’t the issue, it was actually a solution!
 

@imougy 

The original issue is resolved by using the recent change to use the `ISO8601DateFormatter`. https://github.com/RevenueCat/purchases-ios/issues/1096#issuecomment-997470529

It seems the original `iso8601dateformatter` code had subtle buggy issues for users with unconventional calendar or date/time settings for non-US locales. After we used a version of the SDK with the rewritten DateFormatter, our issues were resolved for our users.

Userlevel 3
Badge +8

@Winston Du in my app, I myself get affected from time to time, I get empty customerInfo and need to restore purchases.  I have US local.  The randomness of the issue is a puzzle to me, unless some dates are parsed and others are not!

Anyway, I am eagerly awaiting any fix to test.

@Winston Du  Thanks for the follow up and I hope I can report good news when I get this change. @taquitos please keep me in touch so I can get this change.

Userlevel 5
Badge +8

@imougy I’m so glad to hear that! What a great way to start the week! 😃 I’m so happy we could help!

 

We’ll get the docs updated, hopefully we’ll save others from running into the same thing.

Thanks so much for your patience and help in figuring out what was going on! 

Don’t hesitate to get in touch again if you need any further assistance! 

 

Reply