I am trying to download a few strings from parse.com inside of a Notification Center widget.
Therefore I first need to sign the user in to parse. First I am loading the credentials, which are saved from the app itself in the NSUserDefaults
(I know about the safety aspect.). This step works fine, but when I am performing the following code, the widget says, that the loading of data is not possible.
func signUserIn(username: String, password: String) {
PFUser.logInWithUsernameInBackground(username, password:password) {
(user: PFUser!, error: NSError!) -> Void in
if (user != nil) {
SMKeychainService.saveToken(password)
var defaults = NSUserDefaults(suiteName: "group.xxx.xxx")
defaults.setObject(username, forKey: "UsernameKey")
defaults.synchronize()
self.delegate?.signedIn!(true)
} else {
self.delegate?.signedIn!(false)
}
}
}
Has anyone of you tried to load data from parse.com inside of an widget and how did you do it. I can´t even load the data, because like I mentioned the widget crashes at the sign in of the user.
The app itself has no problems with signing in to parse and loading the data.
I solved the problem
I did not implemented Parse.setApplicationId("xxx", clientKey: "xxx")
, now I implemented it in viewDidLoad
and the code works!