如何检测设备上的iCloud帐户是否已更改? [英] How to detect if iCloud account on a device changed?

查看:175
本文介绍了如何检测设备上的iCloud帐户是否已更改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何检测设备上使用的iCloud帐户是否已更改?

How to detect if iCloud account being used on a device changed?

用户从设置> iCloud 注销并且其他用户签名在他/她的帐户中。

A user signs out from Settings > iCloud and another user signs in his/her account.

如何在应用程序打开时检测到此更改?

How to detect this change when the app is opened?

推荐答案

只需添加一个名为 NSUbiquityIdentityDidChangeNotification的通知的观察者

[[NSNotificationCenter defaultCenter]
    addObserver: self
       selector: @selector (iCloudAccountAvailabilityChanged:)
           name: NSUbiquityIdentityDidChangeNotification
         object: nil];




如果用户退出iCloud,例如关闭Documents &安培;设置中的数据
,ubiquityIdentityToken方法返回nil。要启用
您的应用以检测​​用户何时退出并重新登录,请注册
以了解iCloud帐户可用性的变化。 - Apple文档

If a user signs out of iCloud, such as by turning off Documents & Data in Settings, the ubiquityIdentityToken method returns nil. To enable your app to detect when a user signs out and signs back in, register for changes in iCloud account availability. - Apple Documentation

http://developer.apple.com/library/mac/#documentation/General/Conceptual /iCloudDesignGuide/Chapters/iCloudFundametals.html

这篇关于如何检测设备上的iCloud帐户是否已更改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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