简体   繁体   English

使用App Store收据唯一标识iOS iTunes帐户吗?

[英]Uniquely identify iOS iTunes accounts using App Store receipts?

There are several questions on SO that discuss mechanisms for uniquely identifying iOS users by their iTunes account (for instance, Uniquely identifying an iOS user ). 关于SO的几个问题讨论了通过iTunes帐户唯一标识iOS用户的机制(例如, 唯一标识iOS用户 )。 I've been trying to implement this in a different way, basically using the App Store receipt's opaque value field. 我一直在尝试以其他方式实现此目的,基本上是使用App Store收据的opaque value字段。 This article seems to suggest that (at least for OS X apps) the opaque value field basically contains a unique ID to the user's iTunes account (NOT the email address, of course!), which suggests that this ID would be the same for different devices under the same iTunes account. 本文似乎建议(至少对于OS X应用程序而言), opaque value字段基本上包含用户iTunes帐户的唯一ID(当然不是电子邮件地址!),这表明该ID对于不同的用户将是相同的同一iTunes帐户下的设备。

I've tried this on apps with no in-app purchase implemented, but I'm seeing that while the appStoreReceiptURL property of NSBundle contains a valid URL, that file never exists in the apps that I've tried (which were downloaded from the app store and were then updated with the test code using Xcode). 我已经在未实现应用内购买的应用上尝试过此操作,但是我看到虽然NSBundleappStoreReceiptURL属性包含有效的URL,但该文件在我尝试过的应用中从未存在过(该文件是从应用商店,然后使用Xcode更新测试代码)。

Is the receipt supposed to always exist, even for free/paid apps without IAP? 即使没有IAP的免费/付费应用程序,收据也应该始终存在吗? Has anyone attempted to uniquely identify iTunes users using the receipt? 是否有人尝试使用收据来唯一标识iTunes用户? It seems like a very promising approach. 这似乎是一种非常有前途的方法。

You need to make an SKReceiptRefreshRequest to generate a receipt if you can't find one. 如果找不到收据,您需要进行SKReceiptRefreshRequest生成收据。

let receiptRequest = SKReceiptRefreshRequest()
receiptRequest.delegate = self
receiptRequest.start()

The below link has tips for a few other issues you may encounter: 以下链接提供了您可能遇到的其他一些问题的提示:

App Store Receipt Validation App Store收据验证

I was trying to solve the same problem. 我试图解决同样的问题。 What I understood is there is no unique ID we can trust in Apple documentation but possible workaround is to use iCloud record ID. 据我了解,Apple文档中没有可以信任的唯一ID,但是可能的解决方法是使用iCloud记录ID。

Using iCloud record ID (CKRecordID) 使用iCloud记录ID(CKRecordID)

Swift3/4+ 迅捷3/4 +

    let container = CKContainer.default()
    container.fetchUserRecordID() {
        recordID, error in

        if let err = error {
            print(err.localizedDescription)
        }
        else if recID = recordID {
            print("fetched ID \(recID.recordName ?? "NA")")
        }
    }

For automatically created records, the ID name string is based on a UUID and is therefore guaranteed to be unique. 对于自动创建的记录,ID名称字符串基于UUID,因此保证是唯一的。

In Purchase receipt 在采购收据中

In my case, I wanted to block upgrade/downgrade by DIFFERENT iTunes account in server side. 就我而言,我想通过服务器端的不同iTunes帐户阻止升级/降级。 So I use original_purchase_date for this (Assuming multiple purchase is impossible in one user account at the same fraction of time). 因此,我为此使用了original_purchase_date(假设在同一时间段内不可能在一个用户帐户中进行多次购买)。 This ID will be same always after initial purchase for that particular iTunes account. 最初购买该特定iTunes帐户后,此ID将始终相同。 I save this ID in server along with Product_ID and always check this ID in receipt when user upgrade/downgrade (When app send new receipt). 我将此ID与Product_ID一起保存在服务器中,并在用户升级/降级时(在应用发送新收据时)始终在收据中检查此ID。 If it's different for same product ID, I assume it's different user tries to upgrade the product. 如果相同的产品ID不同,那么我认为是不同的用户尝试升级产品。

original_purchase_date - In an auto-renewable subscription receipt, this indicates the beginning of the subscription period, even if the subscription has been renewed original_purchase_date-在可自动续订的订阅收据中,这表示订阅期的开始,即使订阅已续订也是如此

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM