How to find out WHEN a user bought the app / installed it for the first time (possible without UDID?)

♀尐吖头ヾ 提交于 2019-11-30 04:57:00

问题


I would like to find out when a user first bought my app... so far, I havent found a clean way and a UDID seemed to be the only option.

Ideally there would be a receipt I can get via StoreKit but so far.. nada

have I missed something ? Does anybody have an idea?


The situation is that I have a subscription and the FIRST issue (from the time you buy the app should be free). If I reinstall at a later time.. I should always get the original issue)

example: I buy the app in 10.2010 I install and run it and get the subscription issue from 10.2010 for free (no in-app purchase) Now I delete the app I Install it 1.2013 and I only get the subscription from 10.2010 for free! NOT The new one


回答1:


You can just store a flag in the keychain. The contents of the keychain are preserved across app reinstalls.

To get the first installation time of your app, check when the first time the app binary has been written to disk:

if (flag_in_keychain_not_present()) {
    // installed for the first time
    set_flag_in_keychain();

    struct stat st;
    stat([NSBundle mainBundle].executablePath.UTF8String, &st);
    time_t installed = st.st_mtime;
}



回答2:


I haven't used Store Kit yet, but tell me if I'm wrong,

1) it requires a server at a point or another

2) when we use it to "buy" (not a subscription or a consumable) something we can retrieve this purchase on all devices using the same iTunes Account

My point, create a in app purchase free item, when it passes through you server the first time store it in a database and next time it is called with the same account "enable" the issue corresponding to the first free purchase



来源:https://stackoverflow.com/questions/16354886/how-to-find-out-when-a-user-bought-the-app-installed-it-for-the-first-time-po

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!