Pressist CFUUIDRef After App Deleted - iphone

Recently apple has reject apps that uses the unique device identifier (UDID), in my app i am creating once aCFUUIDRef for each device on the first time, which works great.
in my app i am giving to a new user 10 clicks on a button (some service), when i am creating a device id for the first time it sends to the server and this id is now have credit of 10 clicks.
the problem is when the user delete my app it generate a new identifier.
how can i write some file to the iphone withe an identifier lets say for example "MyCustomDeviceID"
and when a user download the app i am checkin if this file is existing, if it does i am getting the saved parameter and if it doesn't i am creating the identifier and then creating the document.
i got to have some way to leave a mark on the iphone.
ideas will be appreciated!

Assuming that you can convert a CFUUIDRef into an NSString, you can store it in the keychain. Items stored in the keychain persist across app deletes. Check out PDKeychainBindingsController for reference.

On iOS you have no "shared space" where save data and maintain it after the application deletion. You have to do it in other ways:
you can enable iCloud for your app and save your id using NSUbiquitousKeyValueStore.
You can save your identifier in NSUserDefaults, so if the app is deleted and then reinstalled it will be available in the backup. (obviously the user have to restore from backup)
Or you can associate the identifier to a nominal account. (you have to create a system where the user can do a registration and login with this nominal account)

Related

Check if app is reinstalled without storing unique id

When my app is first installed, the user gets 5 free consumables. After the consumables are finished, the user then has the option to get purchase 5 additional consumables. Is there a way to check if the app was previously installed. I don't want the user to uninstall and reinstall to get 5 free consumables again.
The plugin I'm using, in_app_purchase, allows retrieval of past consumables, so I thought I could have the user purchase a free consumable on startup, which I could later retrieve if the app is installed, but I don't want the user to go through any extra steps to use the app for the first time.
I would prefer a solution that doesn't require storing a unique id because that would require backend code and getting a unique id isn't possible on iOS.

IOS buy, erase phone, detect previously purchased

I got most of IAP purchase working, using user defaults etc
But supposing a user buys an app, then erases or updates to a new phone.
Then reinstalls the app.
How do I detect that the user has previously purchased the app?
That is what restore functionality is for. See the Restore section of:
https://developer.apple.com/documentation/storekit/in-app_purchase/offering_completing_and_restoring_in-app_purchases
There are three ways:
If you store some purchase indicator in the app keychain, it will be present when the app is re-installed. If you are doing subscriptions also include an expiration date you can check if a subscription is possibly out of date.
If you send the app receipt up to Apple, it will always give you back the most current purchase data - which includes any prior purchases. So on first launch, always send the receipt up to Apple to see if you might want to automatically restore a purchase made previously. Note that sometimes an application receipt will not be present immediately after install (although it should always be there), which is why you also need to allow for option 3.
There is also a SKPaymentQueue’s restoreCompletedTransactions() call you can make to basically replay previous purchase transactions. This is something you should wire to a button somewhere in your UI - Apple requires that. It's not something you want to automatically call as it can prompt for the user to enter their iTunes account password, so you should not rely on this method to restore purchases automatically, but it is good to have in place as a backup for the user.

Encryption of credit card information on iOS application scenario

We want to encrypt credit card informations and save on our server. The encrypt/decrypt keys will be saved on the user's iPhone. But if the user reinstalls the app, we will have lost the keys and we will have no way to decode the card informations.
We want to find a way to save keys on any other safe places. Any suggestions on this issue?
Keychain data stays in place after an app gets deleted. You could eventually rely on this to store the keys (also, this is the most secure place where you can store them).
References:
How to find out WHEN a user bought the app / installed it for the first time (possible without UDID?)
https://forums.developer.apple.com/message/112814

iTunes Connect: How to change the bundle id prior to app submission?

We are getting ready to upload our app. At this point, itunes connect information has been entered. The problem is, we decided to change the name of our app from
ourAppMobile -> ourApp
The concern is that in iTunesConnect the Bundle ID is listed as:
com.ourcompany.ourAppMobile
But, we have changed our app name to ourApp.
What to do? Can the Bundle ID be changed in iTunes Connect. If so, how? If not, what to do?
Thanks.
> Identifiers
>
> SKUICC_MOBILEAPPLE Bundle ID
> com.ourcompany.ourAppMobile Apple ID
> 395529813 Type iOS App
As you suspect there is no possibility to change the Bundle ID or better say App ID Suffix. Your only solution to make a new Bundle ID and upload the app with this ID.
This Bundle ID is which make your app unique on the AppStore and follows it thorough all its lifespan and based on this iTunes recognize it from upgrade to upgrade.
The Bundle Display Name is totally different, and you can change as you like in line with Apple guidance. The APP ID prefix could be the same for various apps but it's again not the Bundle ID you are asking for.
Actually I don't really understand why do you bother with the internal name of the app as this will be unseen for the users. It's just a string nothing else, nobody use it or read it. The APP ID suffix could be anything even different from the Apple recommendation of com.companyname etc., and the only limitation that it has to be different from another APP ID, this is why it's unique and you couldn't change it any more.
In your Info.plist for project add/modify value for CFBundleDisplayName (aka 'Bundle Display Name') to the desired app name. Then rebuild.
If your app name contains a space then you will need to take an extra step in the midst of validation process. Check this out.
From another forum....
"You can either go ahead with the original bundle Id (these are always your choice as long as they are unique or wildcard for your account) or abandon that effort and start over with a new ID and upload using it. However, you will have to change the app name too..."
In my case, I did not want to change the app name in iTunes Connect or so I'm keeping the bundle id I originally entered as suggested.

UUID is unique? iphone

Can i save an UUID in an external database in order to check if the user posts his message only one time from his iphone? I have searched and i have found that there is no way to save a NSString value after the app has been deleted. Am i right?
When an app is deleted, all of its data is deleted too. You could store the UUID on a remote server, however the iPhone's UUID will be the same regardless of how many times your app is deleted and reinstalled.
Note that this can be a security concern as your remote server may recognize a device which has been wiped and sold.
You can save an encrypted NSString in the keychain, and that string will survive the app being deleted. However the user can still securely wipe their phone to clear the keychain. Or log in from multiple iOS devices on their same iTunes account. Or exchange their device for another new device at an Apple store if there is some sort of warranty problem, etc.