Problem with ownerId field

I really don’t know when it occurs but sometimes, when I save a new object, “ownerId” field is empty while all other fields are ok.
Sometimes it works and sometimes it doesn’t. I solved this setting manually the ownerId with
[object setOwnerId:back endless.userService.currentUser.objectId]
and all works well.

But I would to report this to get how this happens.

ownerId will be empty when you do not have logged in user at the time when object is saved.

But it happened just after logged in my app…

…and another consideration: if user is not logged in, backendless.userService.currentUser.objectId would be nil, right?

Ok, I received this fault message
“FAULT = Unable to logout user due to error: user must be logged in. <Unable to logout user due to error: user must be logged in.>”
I see it when I do these steps:
1 - login
2 - “deep” exit from app (no background mode)
3 - re-open the app
4 - Logout (and the app shows me the message)

setStayLoggeIn is set to YES so when i open again the app, I don’t need to login again.But i receive that error when try to logout…

If user is not logged backendless.userService.currentUser will be null, so you will not be able to get further to get the obectId.

Do you use classic Backendless login or login with facebook/twitter?

I use backendless api to log in

Thanks, we will try to reproduce it

Can you add here some screenshots?

Hi Francesco,

I checked your scenario with our UserService sample - it works fine for me. this is a log:

http://support.backendless.com/public/attachments/00fe70f2dc1cbc3983533314e4c0a74d.png&lt;/img&gt;
Please try your scenario with our sample, and let we know how it goes.

Slava

Thank you Slava. I will let you know how it goes but the problem isn’t with login because I can login normally. The problem is when I save an object: ownerId is empty. It occurs just few times but for now I solved this situation setting ownerId by code, before saving it.
It seems to me like if user is logged in but there is a kind of internal conflict. I can reproduce it with these steps:
1- login
2- close the app (no background mode)
3- open again the app: user is logged in but if now I try to save an object, ownerId is empty and if log out, my app crashes with a fault message FAULT = Unable to logout user due to error: user must be logged in. <Unable to logout user due to error: user must be logged in.>"

I checked in console of Xcode the info of the user and I can see that is logged in correctly.

Hi Francesco,

“2- close the app (no background mode)” - how you do it?
Please describe in detail.

Now I cannot reproduce your scenario: if backendless.userService.setStayLoggedIn(true), app is opened without login, then data is saved with ownerId and logout works fine.

Can you try your app with my backendless app:

let APP_ID = “25C2E37D-8EB6-8CDA-FF37-D6F05AE7EE00”

let SECRET_KEY = “675002F9-A2F8-567F-FFB2-3E348B887900”

Another way is to send your project (without ‘lib’ folder), which demonstrates this problem, on my email: support@backendless.com - I’ll investigate it.

Regards,
Slava

Hi Francesco,

Does it still reproduce in your code?