Parse-SDK-iOS-OSX icon indicating copy to clipboard operation
Parse-SDK-iOS-OSX copied to clipboard

[PFInstallation currentInstallation]'s objectId is nil

Open bmueller opened this issue 5 years ago • 8 comments

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.

bmueller avatar Oct 29 '20 03:10 bmueller

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().

cbaker6 avatar Nov 09 '20 02:11 cbaker6

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.

bmueller avatar Nov 09 '20 03:11 bmueller

I wonder if the save was successful or returned an error. Do you see their installation in Installation table on Parse Dashboard?

cbaker6 avatar Nov 09 '20 04:11 cbaker6

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.

bmueller avatar Nov 09 '20 19:11 bmueller

@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 avatar Dec 01 '20 05:12 bmueller

@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.

cbaker6 avatar Dec 19 '20 15:12 cbaker6

I'll give that a try!

bmueller avatar Dec 19 '20 20:12 bmueller

Same issue

jesusmateos1234 avatar Dec 19 '20 21:12 jesusmateos1234