1

I am using the below code to save the currently logged in user with custom field. I allow the user to fill in information and then save. I used both the save methods on my own threading using GCM and used the saveInBackgrounWithBlock. On iOS8, this works ok but on iOS7 saving never happens and the completion block is never called. Any ideas? Thanks

       if PFUser.currentUser() != nil {
            PFUser.currentUser().setObject(installation, forKey: "installation")
            PFUser.currentUser().saveInBackgroundWithBlock({ (bool: Bool, error: NSError?) -> Void in
                if(error != nil) {
                    let alert = UIAlertView(title: "Problem Saving", message: "Make sure you are connecte to the internet and try again", delegate: nil, cancelButtonTitle: "OK")
                    alert.show();
                }
            })
        }

Update 1: I noticed that deleting the app resolves the issue temporarily. However, after signing out and signing in with other user (i.e. changing the current user), the issue will pop up again.

Update 2: The issue seems to be coming from PFInstallation somehow. Using addUniqueObject causes issues. After calling this method, any saves stops working iOS7. Even on the PFUser. The PFUser has the installation setup and vice versa. An array of them.

Update 3: Seems like it's not just the addUniqueObject, but any setObject on the PFInstallation.currentInstallation. Help!

ChrisBorg
  • 1,418
  • 17
  • 27

2 Answers2

0

you should check your first param (isSuccess) as well:

if (bool == YES && error != nil) -> success
else -> failure
yonivav
  • 994
  • 11
  • 18
  • the app doesn't even make it to the first if statement to make checks. it gets stuck right at saving. just noticed that deleting the app solves the issue temporarily. it seems that this happens after signing out and signing in with another user. i.e. the PFUser currentUser changes. Updating the question – ChrisBorg May 10 '15 at 08:24
0

It took me a long while to realise, and even though I never actually found a solution to the problem itself, I found a workaround. I was saving the currentUser in the currentInstallation and the currentInstallation in the currentUser. This was causing issues when saving. I also saved channels on the currentInstallation by sending an array of channels directly instead of using addUniqueObject.

    let installation = PFInstallation.currentInstallation()
    installation.channels = channels;
    installation.saveInBackground()
ChrisBorg
  • 1,418
  • 17
  • 27