How to identify if an app is running on a different device from the one it was originally installed on without using the keychain

My goal: To detect if a user changed devices (restored from backup to another device)


Some background: Creating UUID and saving it to the keychain was the best solution for this but

a while back we gave up on iOS keychain completely, mainly because of the dreadful -34018 error.


Links:


https://devforums.apple.com/thread/246122

https://forums.developer.apple.com/thread/4743


Since then we are using NSUserDefaults with in house encryption. My current problem is that a device restore will also restore NSUserDefaults.

I'm looking for a way to identify if a user changed devices.


Things to consider:


Keychain - Like I wrote above, is not usable to us because of the 34018 bug


FileManager - Saving a key \ identifier to a file with NSURLIsExcludedFromBackupKey is also problematic for us because the file can be moved to another device using a JailBroken phone.


Is there any other way to identify that an app that was installed on device A is now running on device B?


Thanks

Replies

I would recommend using the receipt validation process for this.

https://developer.apple.com/library/ios/releasenotes/General/ValidateAppStoreReceipt/Introduction.html#//apple_ref/doc/uid/TP40010573

Can we use it without in-apps ?

I'm not sure what you mean by that. Are you talking about performing the verification at the server level? Because that won't work.

Hey bob133, Thanks for your reply.


Sorry for the confusion, I've only used receipt validation for in-apps,

A couple of questions just to make sure I understand.


NSURL *receiptURL = [[NSBundle mainBundle] appStoreReceiptURL];
NSData *receipt = [NSData dataWithContentsOfURL:receiptURL];


Doing the above on device A and then, after restore, on Device B will generate a different receipt?

Will downloading an app on Device A, deleting it and re downloading it on Device A will generate the same receipt or a different one?

Thanks

What I was talking about was using the App Store receipt to retrieve the device identifier and compare it with the current one. As for whether or not receipts are restored or automatically refreshed, I don't know, but hopefully this will steer you in the right direction. Maybe play with it a little, perhaps with the simulators, and see how it works.

I'll investigate on the subject. Thanks for the tip.

Good luck! Feel free to update this thread or start a new one if you run into trouble or have more questions! 🙂