Search Unity

PlayerPrefs lost in iOS 12 only

Discussion in 'iOS and tvOS' started by BenoitFreslon, Apr 8, 2019.

  1. BenoitFreslon

    BenoitFreslon

    Joined:
    Jan 16, 2013
    Posts:
    136
    Hello,

    I'm using Unity 2018.1.9f2 to build for iOS and Android.

    Some iOS users complain about losing all their data. I don't know how to reproduce this issue.
    I'm using AntiCheat ToolKit to encrypt the data but the developer of this plugin never encountered this issue.

    Sometimes, I use "PlayerPrefs.Save()" Do you think it could be the problem?

    No problem on Android...

    Thanks.
     
  2. Neonlyte

    Neonlyte

    Joined:
    Oct 17, 2013
    Posts:
    92
    Did you use save encryption with the crypto key set to device ID? I use ACTk also, and I used to receive reports that player loses all data saved with ObscuredPrefs. I changed the crypto key to a fixed value rather than using the device ID (I forgot the exact ACTk API) and the issue is no longer reported.
     
  3. BenoitFreslon

    BenoitFreslon

    Joined:
    Jan 16, 2013
    Posts:
    136
    Hello Neonlyte,

    I'm not using a dynamic Crypto Key, but just a static string.
    I want to remove the encryption but I don't know if I will lose all previous datas.
     
  4. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,284
    Hey guys @BenoitFreslon @Neonlyte
    I'm really sorry to hear this happens =(

    There were reports of data loss long time ago with LockToDevice feature enabled and on iOS only.
    It was caused by iOS update where Apple forbidden some low-level hardware info gathering so Unity had to change the way how they do generate unique device ID which ACTk uses to lock saves to the current device.

    This issue was worked around back then in ACTk to prevent future data loss and there was exposed DeviceId property to let you manage unique ID yourself, e.g. using some other anchor to lock to, like user ID or anything else.

    Unfortunately I had no other reports about data loss since then and couldn't reproduce the current Benoit's problem myself on my end.

    I've just emailed Benoit about switching back to the regular Player Prefs but I'm not sure it will help and the cause was ACTk's ObscredPrefs since it was used without locking feature so no unique IDs were involved into encryption and all it does in such setup - just writes encrypted data to the vanilla PlayerPrefs and reads it back with decryption. And that encryption \ decryption do not depend on any external factors.

    Feel free to report any cases of the data loss if you'll encounter any to help with such incidents investigation.
     
    Neonlyte likes this.