Parse-SDK-iOS-OSX
Parse-SDK-iOS-OSX copied to clipboard
[PFInstallation currentInstallation]'s objectId is nil
In the past few weeks, I've had multiple users reporting problems with my app related to the Parse SDK. After some troubleshooting, it looks like the issue is that the objectId on their [PFInstallation currentInstallation] is nil.
I've never seen this happen before and have been using the Parse SDK for years now. What could be causing this? Is there a way to force the currentInstallation to get a new objectId? I tried saving the installation and calling [PFInstallation getCurrentInstallationInBackground], but neither of those created a new objectId.
I'm running the latest version of the Parse iOS SDK - not sure if there were any recent changes that could be causing this.
Do you ever specifically call PFInstallation.current()?.saveInBackground() after the user is logged in? If not, your Installation table is never populated to Parse as it doesn't save by default. You can check your Installation table in Parse Dashboard to see if new entries are there. If there are non or there's no Installation table at all, any find on PFInstallation will return nothing as there is nothing to be queried.
The PFInstallation is however created locally on a users device when they login, but it will never have an objectId unless you use PFInstallation.current()?.saveInBackground().
Yes, I specifically had the user who was experiencing this issue run a command that called [[PFInstallation currentInstallation] saveInBackground]. Still no objectId. Note that this is only happening for a small handful of users - I have hundreds of thousands of other users where this is working just fine.
I wonder if the save was successful or returned an error. Do you see their installation in Installation table on Parse Dashboard?
The saveInBackground block does say that it was successful (despite there still not being an objectId), but I'm not sure how I'd find their installation in the Installation table - there's 100k+ records in there.
@cbaker6 to follow up on this, it looks like the data is being saved to Parse correctly and the object on Parse does have an objectId. The Parse SDK on-device is just returning null for the objectId on the currentInstallation.
@bmueller Can you try to always dispatch to the main when saving the Installation as it uses some UIApplication (badges) which requires the main queue. This can be the reason for the sporadic behavior. Let me know if you have any luck with this.
I'll give that a try!
Same issue