Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URLForUbiquityContainerIdentifier in main thread? #17

Closed
JackJackBauer opened this issue Nov 11, 2013 · 2 comments
Closed

URLForUbiquityContainerIdentifier in main thread? #17

JackJackBauer opened this issue Nov 11, 2013 · 2 comments

Comments

@JackJackBauer
Copy link
Contributor

Hi,

I maybe missing something, but the way I see it, the call to

+ (BOOL)checkCloudAvailability {
    // Check for iCloud Availability by finsing the Ubiquity URl of the app
    NSURL *returnedURL = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil]; 
}

in iCloud.m line 88 ff. is running on the main thread, isn't it? But it really should not:

In the Apple developer documentation, Apple said:

Always call the URLForUbiquityContainerIdentifier: method from a background thread—not from your app’s main thread. This method depends on local and remote services and, for this reason, does not always return immediately.

And should this not be called only once, when initializing the iCloud? When checking for iCloud availability the method ubiquityIdentityToken is pointed out by Apple.

While your fantastic library runs much more stable now, the only issue I have are crash logs coming in based upon some mysterious thread-thing. Maybe this is related?

Thank you once again so much for your work!!!!

@Sam-Spencer
Copy link
Member

Thanks for pointing this out! There are definitely some issues with threads in the current version (I'm working on an update available soon - probably first on an experimental branch). I'll move that process to the background thread.

I'm not familiar with the ubiquityIdentityToken, is this something new in iOS 7? I'll take a look at it and ensure that iCloud Document Sync is properly checking for iCloud availability.

There are known bugs (check the releases) in version 6.4 that will be fixed in v7.0.

@JackJackBauer
Copy link
Contributor Author

It's available in iOS 6 and later:

ubiquityIdentityToken
Returns an opaque token that represents the current iCloud (“ubiquity”) identity.

  • (id < NSObject, NSCopying, NSCoding >)ubiquityIdentityToken
    Return Value
    An opaque object that identifies the current iCloud user. If iCloud is unavailable for any reason or there is no logged->in user, this method returns nil.

Discussion
Use this method to determine if iCloud is currently available. Because this method returns relatively quickly, you can >call it at launch time and you can call it from your app’s main thread.

You can use the token returned by this method, together with the NSUbiquityIdentityDidChangeNotification >notification, to detect when the user logs in or out of iCloud and to detect changes to the active iCloud account. >When the user logs in with a different iCloud account, the returned identity token changes and the system posts the >notification. If you stored or archived the previous token, you compare that token to the newly obtained one using >the isEqual: method to determine if the users are the same or different.

Calling this method does not establish access to your app’s ubiquity containers. To establish access to a ubiquity >container, call the URLForUbiquityContainerIdentifier: method. In OS X, you can instead use an NSDocument >object, which establishes access automatically.

Availability
Available in iOS 6.0 and later.
See Also
– URLForUbiquityContainerIdentifier:
Declared In
NSFileManager.h

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants