Restrict iCloud contact/calendar sync - iphone

I am working on an application in which we have provided option for remote contact, calendar, etc wiping. The functionality is working fine until we had discovered about iCloud.
Now when we send wipe command from web to device, it deletes all the contacts from the device as expected. But, if user has iCloud account set and is ON for contacts, when contacts are deleted because of our application's wipe command, contact application will inform iCloud about it which in term will delete all the contacts of user from iCloud.
When user sends wipe and he might have initially had setup iCloud account, he may not be aware about this side effect.
Is there any workaround we can restrict the iCloud deleting?

I'm not sure this make sense. Deleting the contacts without deleting them from iCloud would not work because the device would simply download them again from iCloud.
Are you trying to create a type of MDM app?

Related

How to detect Realm app user has been deleted?

app.currentUser.delete deletes the Realm app user from the server side. However, it seems on other logged-in devices, and the data upload is still working with no auth error.
On other logged-in devices, re-launching the app would detect that the user has been deleted. I also tried to use isLoggedIn but for authenticated devices, it seems always stays “true”.
RealmApp.shared.currentUser?.isLoggedIn
How to detect Realm app user has been deleted on other existing logged-in devices?
User presence is a challenge with Realm; it doesn’t have a baked in user presence system.
While you can monitor when a user is Online or Offline by setting a flag or var when they log in or log out (for example) - there’s no way to monitor in-between or unexpected changes of presence or deletion.
For example, a user logs in - the app can set a var (synched with the server) to ‘Online’ that other devices are observing so their UI can be updated. Whenever that flag changes, other devices or users of the app will know about it.
But what if the app crashes, the user d/c’s for whatever reason or the user force-quits the app. That var is now “Stuck” to the on position and other devices would never know they were offline.
For this use case, you can add an observer to a object in Realm that stores user status and sync's with the server. If the user logs out on one of the devices they are logged into for example, the other devices could be notified of that change. If the user is deleted, a "is deleted" flag could be set which notifies other devices or users of that change.
Expanding on that a bit - Deleting a user could trigger a server side function to then followup with perhaps removing all of their data, cleaning up references or notifying other devices of that event.

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.

Pressist CFUUIDRef After App Deleted

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)

Capturing the Application Delete or uninstall event in iPhone

I need to be able to delete a user account from a database on a server when a user deletes our iPhone application. What is the best way to capture the delete process. When the user holds down a finger on the application and the big "X" appears. The user presses it and the user is prompted to confirm the deletion of the application. I want to be able to capture the process and clean up the server database of users before the application is actually deleted.
What method is called when you delete an application? Any thoughts?
Apple does not let you do such a thing. It cannot be done.
I suggest you mark an account for inactivity instead, or use some other solution.

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.