简体   繁体   English

使用iCloud身份验证方法验证用户是否在我的应用程序中拥有帐户

[英]Verify if user has account in my app with iCloud auth approach

I have just read an article where it was explained how to get the token from iCloud in order to execute authentication with the iOS platform. 我刚刚读了一篇文章,其中解释了如何从iCloud获取令牌以执行iOS平台的身份验证。

How can we combine Android and iOS with such an approach? 我们如何将Android和iOS与这种方法结合起来?

How Android will know that user has iOS account? Android如何知道该用户拥有iOS帐户?

Which kind of credentials do I need to ask users to verify if they already have an account on the iOS platform? 我需要问哪种凭证来验证用户是否已在iOS平台上拥有帐户?

Aleksey, 阿列克西

This code, confirms somebody is logged into iCloud by trying to access an iCloudKit container. 此代码通过尝试访问iCloudKit容器来确认有人登录到iCloud。 The first method checks and sends a notification if it if it fails, the second method trigger by said failure shunts the user to the control panel so they can sign into iCloud. 第一种方法检查并发送通知(如果失败),第二种方法由所述失败触发,将用户转移到控制面板,以便他们可以登录iCloud。

 func isAuthorized4Cloud() {
    container = CKContainer(identifier: "iCloud.X")
    publicDB = container.publicCloudDatabase
    privateDB = container.privateCloudDatabase
    var userID: CKRecordID!
    container.fetchUserRecordID( completionHandler: { recordID, error in
        if error == nil {
            userID = recordID
            print("files_setup userID \(userID.recordName)")
            NotificationCenter.default.post(name: Notification.Name("cloudConnected"), object: nil, userInfo: nil)
        } else {
            NotificationCenter.default.post(name: Notification.Name("noCloud"), object: nil, userInfo: nil)
            print("files_setup \(error?.localizedDescription)")
        }
    })
}

In your view Controller... 在您看来控制器...

  NotificationCenter.default.addObserver(self, selector: #selector(noCloud), name: Notification.Name("noCloud"), object: nil)

  func noCloud(notification:NSNotification) {
    DispatchQueue.main.async {
        self.navigation.isHidden = true
        let alert = UIAlertController(title: "Stop", message: "Sorry, you need to log into iCloud ...", preferredStyle: UIAlertControllerStyle.alert)
        let settingsAction = UIAlertAction(title: "Settings", style: .default) { (_) -> Void in
            guard let settingsUrl = URL(string: UIApplicationOpenSettingsURLString) else {
                return
            }

            if UIApplication.shared.canOpenURL(settingsUrl) {
                UIApplication.shared.open(settingsUrl, completionHandler: { (success) in
                    print("Settings opened: \(success)") // Prints true
                })
            }
        }
        alert.addAction(settingsAction)
        let cancelAction = UIAlertAction(title: "Cancel", style: .default, handler: nil)
        alert.addAction(cancelAction)
        self.present(alert, animated: true, completion: nil)
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在未打开“购买”对话框的情况下验证用户是否已在我的Android应用中完成购买? - How can I verify user has already done in purchase In my Android App without open Purchase Dialog? 适用于 Android 的 Firebase 电话身份验证,我们可以在不创建用户帐户的情况下仅验证电话号码吗 - Firebase phone Auth for Android , Can we just verify phone number without creating a user account 如何找到用户用来登录我的基于google-fit的Android应用程序的帐户(电子邮件)? - How to find which account (email) has user used to log into my google-fit based android app? 如果用户删除了应用程序或更换了手机,如何恢复用户帐户? - How to recover user account if user has deleted the app or changed phone? 检测用户是否在应用程序上从唯一设备创建了帐户 - Detecting whether or not user has created an account from a unique device on an app 如何在Google动作,移动应用,后端服务器和Firebase身份验证之间链接用户帐户? - How to link user account among google actions, mobile app, backend server and firebase auth? 我可以验证用户是否具有用于在线功能的Android应用程序的合法副本吗? - Can I verify that a user has a legitimate copy of an android app for online features? 发送电子邮件确认或使用Play商店帐户来验证我的应用程序的用户帐户? - Sending email confirmation or using play store account to authenticate the user's account for my app? 如何检查用户是否验证了 email? - How to check whether user has verify the email? 当用户访问我的应用程序中的特定部分时,最好的方法是什么? - What is the best approach to know when a user visit an specific section in my app?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM