How to detect if iCloud account on a device changed?

吃可爱长大的小学妹 提交于 2019-12-21 07:56:16

问题


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

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?


回答1:


Just add an observer for the notification with name NSUbiquityIdentityDidChangeNotification

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

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



来源:https://stackoverflow.com/questions/15022073/how-to-detect-if-icloud-account-on-a-device-changed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!