I use runkeeper in my application to associate it with data and get data from them. When I click the button, it directs me to the browser, where I enter the runkeeper web application, hit the service after receiving the access token and user_Id, and return back to my application. Now again, if I click on a button in my application to connect, it directly asks me to redirect back to my application, but I want it to ask for a login every time I click to connect. I know that I need to clear my cache and cookies, but I donβt know how to do this.
@IBAction func btnRunKeeperClicked(sender: AnyObject) { MSYRunKeeper.shareInstance.loginWithRunKeeper { (result, success) in print(result) if success{ print(result) let accessToken = result["accessToken"] as? String ?? "" self.hitServiceToGetDataFromRunkeeper(accessToken) }else{ print("error...") } } }
func hitServiceToGetDataFromRunkeeper (accessToken: String) {
showActivityIndicator(true, inViewConroller: self, animated: true) let dict = HelperClass.userDefaultForAny("User_Detail") var userID = "" var serviceKey = "" if(dict != nil){ userID = (dict!["userID"] as? String)! serviceKey = (dict!["service_key"] as? String)! } var paramDictionary = NSMutableDictionary() paramDictionary = ["method":"runkeeperLogin","service_key":serviceKey,"userID":userID,"runkeeperAccessToken":accessToken,"isRunkeeperConnect":"1"] print_debug(paramDictionary) FSServicesClass.sharedInstance.postWithParamater(paramDictionary, sBlock: { (result) in if(NSDictionary(dictionary: result).valueForKey("success")?.integerValue == 1){ showActivityIndicator(false, inViewConroller: self, animated: true) self.btnRunKeeperConnected.setTitle("Connected", forState: .Normal) if self.btnFitBitConnected.titleLabel?.text == "Connected"{ self.btnFitBitConnected.setTitle("Disconnected", forState: .Normal) } print(result) let dict = HelperClass.userDefaultForAny("User_Detail") HelperClass.removeFromUserDefaultForKey("User_Detail") let dict2 = updateUserDetailForConnetectdAppsAndDevices(dict!, isfitbitConnected: "0", isRunkeeperConnected: "1") HelperClass.saveToUserDefault(dict2, key: "User_Detail") popAlertMessageController(self, title: "Alert", message: NSDictionary(dictionary: result).valueForKey("errstr") as? String ?? "") }else{ showActivityIndicator(false, inViewConroller: self, animated: true) popAlertMessageController(self, title: "Alert", message: NSDictionary(dictionary: result).valueForKey("errstr") as? String ?? "") } }, fBlock: {(ErrorResult) in showActivityIndicator(false, inViewConroller: self, animated: true) popAlertMessageController(self, title: "Please try again", message: NSDictionary(dictionary: ErrorResult).valueForKey("errstr") as? String ?? "")