在iOS5中,是否可以检测用户是否有应用设置为备份? [英] In iOS5, is it possible to detect if a user has an app set to back up?

查看:168
本文介绍了在iOS5中,是否可以检测用户是否有应用设置为备份?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户打开他们的设备时,我想显示一个弹出窗口,告诉他们为该应用停用iCloud备份。



可以检测是否用户已为我的应用启用了备份?



可以让用户进入设置 - > iCloud->存储&

解决方案

这里有一个例子:



http://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/iCloud/iCloud.html#//apple_ref/ doc / uid / TP40007072-CH5-SW17


每个使用Apple ID的用户都会收到免费的iCloud帐户,选择不为给定设备启用iCloud。在尝试使用任何其他iCloud界面之前,您必须调用URLForUbiquityContainerIdentifier:方法来确定是否启用iCloud。此方法在启用iCloud(并且指定的容器目录可用时)时返回有效的URL或在禁用iCloud时返回nil。



第一次调用URLForUbiquityContainerIdentifier:method对于给定的容器目录,iOS扩展您的应用程序沙箱以包括该容器目录。因此,重要的是,您至少调用此方法一次,以确保iCloud已启用,并且您的主容器目录可访问。如果你的应用程序访问多个容器目录,你应该为每个目录调用一次方法。


这意味着它应该返回<$ c



com / library / mac /#documentation / Cocoa / Reference / Foundation / Classes / NSFileManager_Class / Reference / Reference.htmlrel =nofollow> NSFileManager doc也有这样:


containerID [...]如果指定nil,此方法将返回com.apple中列出的第一个容器。 developer.ubiquity-container-identifiers授权。



返回值



指向指定容器目录的网址,如果无法找到该容器,则为nil如果iCloud存储对当前用户或设备不可用。


权利设置可能包括默认的第一个路径。

When a user turns on their device, I would like to show a popup to tell them to disable iCloud backup for the app.

Is it possible to detect if the user has backup enabled for my app?

And is it possible to take the user to Settings->iCloud->Storage & Backup->Manage Storage->iPad, which is where the switch to disable the backup resides?

解决方案

There's an example here:

http://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/iCloud/iCloud.html#//apple_ref/doc/uid/TP40007072-CH5-SW17

Every user with an Apple ID receives a free iCloud account but some users might choose not to enable iCloud for a given device. Before you try to use any other iCloud interfaces, you must call the URLForUbiquityContainerIdentifier: method to determine if iCloud is enabled. This method returns a valid URL when iCloud is enabled (and the specified container directory is available) or nil when iCloud is disabled.

The first time you call the URLForUbiquityContainerIdentifier: method for a given container directory, iOS extends your application sandbox to include that container directory. Thus, it is important that you call this method at least once to ensure that iCloud is enabled and that your main container directory is accessible. And if your application accesses multiple container directories, you should call the method once for each directory.

It implies it should return nil if the directory isn't available in iCloud.

The NSFileManager doc also has this:

containerID [...] If you specify nil, this method returns the first container listed in the com.apple.developer.ubiquity-container-identifiers entitlement.

Return Value

A URL pointing to the specified container directory or nil if the container could not be located or if iCloud storage is unavailable for the current user or device.

The entitlement setting may include the first path by default.

这篇关于在iOS5中,是否可以检测用户是否有应用设置为备份?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆