Custom Service does not have a logged in user

I built a custom service on backendless in javascript. It is currently running in production and I am able to test all the methods in the browser when on the backendless site.

I downloaded the client sdk (in objective-c) and added the code to my project.

When I execute the code though I receive a fault saying I have no logged in user. I am wondering how I log in a user before making a request.

Thanks

Server Code:

'use strict';
const Games = require('../models/games');
class GamesService {
 /**
 * @param {String} opponent
 * @param {String} word
 * @returns {Promise<Game>}
 */
 createGame(opponent, word) {
 if (!this.request.context.userId) {
 throw new Error("No logged in user");
 }
 ...
 return game;
 }
}
Backendless.ServerCode.addService(GamesService);

Client Code:

[[GamesService sharedInstance] createGame:friendName word:word]

I have already logged in a user using backendless.UserService
and [backendless.UserService currentUser] returns a valid user.

Hi Asher,

I assume you’re using the version 4 of Backendless, please correct me if it is 3.x

It appears the iOS library does not pass the user token to the server when making an invocation. I will open an internal ticket to investigate this further.

Regards,
Mark

Awesome thanks Mark that makes sense.

Does this same issue occur for the REST API or can I make a quick work-around while you investigate?

No, the issue will not occur with the REST API as long as the user-token header is sent by the client to the server-side.

Regards,
Mark

Hello,

This issue has been fixed in the new version 4.0.4 of iOS-SDK. Please update the SDK and verify wether everything works fine.

Regards, Olga

Hi Olga, I have verified everything is working with version 4.0.4. Thank you!

Sorry to re-open this but I realized it is still not fixed.

The access token is not set for my BackendlessUser.

When I finish a login the object has the property ‘user-token’ and it is set.

But when I try to access to it using [backendless.userService currentUser] the property is no longer there.

When I store the ‘user-token’ locally and make rest calls everything works fine, but when I try to call any of the backendless sdks they fail because they say there is no logged in user.

The discussion has been moved to http://support.backendless.com/t/custom-service-does-not-have-a-user-token