Why same iCloud account but got different ubiquityIdentityToken - ios

i am trying to implement an App with iCloud Key-value storage feature.
Currently, I'm testing it from two devices iPhone5s with iOS7.0.4 and iPhone4 with iOS6.1.1.
Do you guys have any idea why the same iCloud account (checked from Settings -> iCloud -> Account) gets two different ubiquityIdentityToken? i guess this is the reason the data didn't sync between this two devices (network accessed).
And on iOS6, NSUbiquitousKeyValueStoreDidChangeExternallyNotification is not trigging.
Thanks in advance!

The ubiquityIdentityToken is only intended to be used to:
Determine if iCloud is available to your app
Determine if the iCloud account has changed (by comparing to a previously saved value).
It's opaque but conforms to a few protocols. You can save it locally and compare the current value with a previous value, but that's about all it's good for. It's not guaranteed to be useful in any other situation.
It's not guaranteed to be the same on different devices, even if those devices use the same iCloud account. Why it might be different is not documented-- it might encode a device-specific value somehow. Regardless, it's not something that you can transfer from one device to another and expect to still be useful. That's not how it's designed to work.

It does encode a device-specific value in the token. The 8-digit hexadecimal number groups between positions 17 and 22 change on a different device OR with a different iCloud account.
The rest of the groups usually remain the same, across different apps, devices, OR iCloud accounts.

This is strange behaviour. In these cases Apple usually recommends signing out and logging again (using the same Apple ID) on both devices. Try that and see if it helps. Also, make sure to install the latest version of your app (with enabled iCloud) on every device.

Related

How can I tell if my user upgraded to a new phone, or restored from a backup in iOS?

I want to make getting a new device as easy as possible in my iOS app.
However, I want to ensure that the old instance of the app (and more importantly the data) is no longer accessible on the old phone.
How can I track the uniqueness of a phone, and if the app has been installed on more than one device?
My goal isn't to control licensing, but rather to make sure the user knows what is "out there".
(My app stores private keys in the app container, and I want to ensure these keys don't fall into the wrong hands... hence the reason for my question)
UIDevice offers identifierForVendor
The value of this property is the same for apps that come from the same vendor running on the same device. A different value is returned for apps on the same device that come from different vendors, and for apps on different devices regardless of vendor.

iOS 8 How to get Serialnumber

In our applications the user autentications is based on the serial number.It seems that in ios 8 it is not possible to get the serialnumber.Is any other way?
Thanks in advance.
Apple deprecated access to a unique-per-device UUID (known as uniqueIdentifier as of iOS 6. As of iOS 7, they also blocked access to MAC querying the address, and other sorts of unique identifiers. Sometime between iOS 6 and today, they started rejecting any application that accesses this property.
There are two replacement APIs that might help: on UIDevice, there is identifierForVendor, that is consistent across your apps. And there is also an entire framework, AdSupport, who's job is to provide an identifier that can be used for advertising networks. This identifier has the limitation of people can change it whenever they want, so you cannot rely on it being consistent across multiple launches.
The hint Apple is trying to pass on here is "you cannot consistently, uniquely identify people per device across multiple apps that are not your own".
In addition to zadr excellent explanation I would like to not iCloud as another possible solution:
Simply store a value (as file or key-value) in iCloud. Only disadvantage of this approach is, that you will have to add the iCloud entitlement to your app if your app does not use iCloud yet. On the other hand there are some advantages
Very little / none additional effort necessary if your app already uses iCloud
No additional Frameworsk like AdSupport necessary
The saved value will be consistent between devices and app re-install
More than one app can share the ID by using the same iCloud (ubiquity container)
Of course in some cases this might be a little overdone but in other this can be a handy solution.
I would recommend using uniqueIdentifier as suggested above but saving in keychain. This way its reliably available to you all the time, and can be used to track the user.

Alternative to [UIDevice currentDevice].identifierForVendor

I have one product that has two different applications. and both the applications it gives me different Identifiers for the same device (you would assume that apple would associate this to maybe your developer account so that you can reuse the information across your applications), but I was wondering is their anything that would give me the same identifier for a device on both the applications?
identifierForVendor is really what you want. UDID is a big NO on the AppStore. A user can opt out to advertisingIdentifier. Other ways (by MAC address, like ODIN1, and solutions that rely on UIPasteboard, as OpenUDID) will break on the future (hint: 7).
According to the docs, you should have the same identifier if both apps are from the same developer:
The value of this property is the same for apps that come from the same vendor running on the same device. A different value is returned for apps on the same device that come from different vendors, and for apps on different devices regardless of vendor.
The value of this property may be nil if the app is running in the background, before the user has unlocked the device the first time after the device has been restarted. If the value is nil, wait and get the value again later.
The value in this property remains the same while the app (or another app from the same vendor) is installed on the iOS device. The value changes when the user deletes all of that vendor’s apps from the device and subsequently reinstalls one or more of them. Therefore, if your app stores the value of this property anywhere, you should gracefully handle situations where the identifier changes.
OpenUDID is the best solution until now, even if it also may be changed if the device is reset.

Pasteboard not accessible when locked with passcode on iOS

I have noticed I cannot access the Pasteboard in iOS whenever my device is locked with passcode. I know there was a restriction regarding keychain, but not sure why its affecting pasteboard as well. Is this a known issue or purposeful restriction?
I'm assuming this is desired function.
Imagine an app like 1Password. That app supports copying a password to the paste/clip board.
If I have a passcode set on my device, it's probably because I don't want people to be able to see the data on that device - it could contain stuff like, say, all the specs and launch date for the next iPad.
As a user, I probably shouldn't be copying such information to the pasteboard, but, hey - my device is locked with a passcode, right? No one can see my info, right?
Apple knows that users often use this line of reasoning, and, however flawed it may be, you build your OS for the user - not the user for your OS.*
* Unless you're Microsoft building Windows 8. Then you can break all the rules and make a strange OS.

Store settings ios5

My iOS app has a need to uniquely identify each device so it can retrieve files that it has uploaded to the server with as little user interaction as possible (IE we don't want the user to have to have a username and password). With the release of iOS5, apple has deprecated the UDIDs which would have been the easiest way to go about this. The other way would be to generate and store an identifier on the device and read it from there every time. However, apple could at any time delete the files because they feel there isn't enough free space on the device.
Is there a way to store a device identifier on the local filesystem without worrying about apple "cleaning" it for me?
Or if there's not, how would I go about generating a device identifier that would be the same for one device no matter how many times I generated it but still different from all other identifiers?
You can use the Wireless NIC's MAC Address as the unique identifier.
Also, any files in the Documents directory will not be wiped by apple and will be sync'ed via iCloud. Apple says all generated content should NOT go in the Documents directory (at least if it can be regenerated).
To get the MAC Address I used code from this post: How can I programmatically get the MAC address of an iphone.

Resources