Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 无法在swift的pinterest中注销_Ios_Arrays_Pinterest - Fatal编程技术网

Ios 无法在swift的pinterest中注销

Ios 无法在swift的pinterest中注销,ios,arrays,pinterest,Ios,Arrays,Pinterest,我正在我的swift应用程序中集成Pinterest登录,但问题是我登录成功,但当我单击“注销”按钮时,我无法注销。这是我的代码 代码 @IBAction func btnLogin(_ sender: UIButton) { PDKClient.sharedInstance().authenticate(withPermissions: [PDKClientReadPublicPermissions,PDKClientWritePublicPermissions

我正在我的swift应用程序中集成Pinterest登录,但问题是我登录成功,但当我单击“注销”按钮时,我无法注销。这是我的代码

代码

    @IBAction func btnLogin(_ sender: UIButton) {
            PDKClient.sharedInstance().authenticate(withPermissions: [PDKClientReadPublicPermissions,PDKClientWritePublicPermissions,PDKClientReadRelationshipsPermissions,PDKClientWriteRelationshipsPermissions], withSuccess: { (PDKResponseObject) in


                self.accessToken = PDKClient.sharedInstance().oauthToken


                //MARK: - Getting User Profile, use "/v1/me" to get user data in the Response object -

                let parameters : [String:String] =
                    [

                        "fields":  "first_name,id,last_name,url,image,username,bio,counts,created_at,account_type" //these fields will be fetched for the loggd in user
                ]

                PDKClient.sharedInstance().getPath("/v1/me/", parameters: parameters, withSuccess: {

                    (PDKResponseObject) in
                    self.view.isUserInteractionEnabled = true

                     self.user = (PDKResponseObject?.user())!
                    print(PDKResponseObject!)
                    self.lblUserName.text = PDKResponseObject?.user().username
                    if let url = JSON(PDKResponseObject?.user().images["60x60"] as Any)["url"].string
                    {
                        self.imgProPic.sd_setImage(with: URL(string: url))
                    }

                }) {
                    (Error) in
                    if let error = Error
                    {
                        print("\(Error)")
                    }
                    self.view.isUserInteractionEnabled = true
                    PDKPinError.unknown
                }

            }) {
                (Error) in
                self.view.isUserInteractionEnabled = true

            }
        }
        @IBAction func btnLogout(_ sender: UIButton) {
       /*
            let cookieJar : HTTPCookieStorage = HTTPCookieStorage.shared
            for cookie in cookieJar.cookies! as [HTTPCookie]{
            NSLog("cookie.domain = %@", cookie.domain)

            if cookie.domain == "www.pinterest.com" ||
                cookie.domain == "api.pinterest.com"{

                cookieJar.deleteCookie(cookie)
            }
        }
       */
            PDKClient.clearAuthorizedUser()
        }

这里我已经完成了clearAuthorizedUser(),但没有注销,我还完成了cookie clear代码,但这不起作用。请帮助我解决这个问题。我遇到了一个非常类似的问题,我想我可以通过在这里发布我的解决方案来帮助别人。我正在维护的应用程序通过在UIWebView中加载带有适当参数的“”来验证Pinterest。此身份验证方法不需要Pinterest SDK,此处对此进行了详细说明:。我能够添加一个按钮,用户可以点击该按钮将他们从已验证的Pinterest帐户中注销。为了注销用户,我删除了与Pinterest身份验证相关的所有cookie,并删除了所有存储的身份验证令牌。下面是我用来删除cookie的代码:

let cookieJar: HTTPCookieStorage = HTTPCookieStorage.shared
 if let cookies: [HTTPCookie] = cookieJar.cookies {
     for cookie in cookies {
         let domain = cookie.domain
         if domain == "accounts-oauth.pinterest.com"
                    || domain == ".pinterest.com"
                    || domain == ".facebook.com"
                    || domain == "accounts.google.com" {
             cookieJar.deleteCookie(cookie)
         }
     }
 }
之后,您很可能需要调用PDKClient.clearAuthorizedUser()来删除任何存储的身份验证令牌