Check if User is Logged into iCloud? Swift/iOS

后端 未结 4 1864
后悔当初
后悔当初 2020-12-24 06:10

Is there a way for me to check and see if a user is logged into iCloud when they open the app up? I want to be able to direct them to the settings page if they are not logg

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-24 06:29

    I think this async method is preferred so that you don't block while you are checking.

            CKContainer.defaultContainer().accountStatusWithCompletionHandler { (accountStat, error) in
              if (accountStat == .Available) {
                  print("iCloud is available")
              }
              else {
                  print("iCloud is not available")
              }
            }
    

提交回复
热议问题