Skip to content

Encapsulated User ID

There are two classes to represent User Identifier in GetSocial: UserId and UserIdList for single and multiple users respectively.

Both those classes supports two ways of representing the user: by User ID in GetSocial system and by id in your system based on identity details.

All methods that accept UserId or UserIdList work with both approaches.

GetSocial User ID

You can get the GetSocial User ID for any user in GetSocial system.

val user: User = GetSocial.getCurrentUser()!!
val userId = UserId.create(user.id)

// multiple users
val userIds = UserIdList.create(user.id, anotherUser.id)
let user: User = GetSocial.getCurrentUser()!
let userId = UserId.create(user.userId)

// multiple users
let userIds = UserIdList.create(user.userId, anotherUser.userId)
var user: User = GetSocial.GetCurrentUser();
var userId = UserId.Create(user.id);

// multiple users
var userIds = UserIdList.Create(user.id, anotherUser.id);
var user = await GetSocial.currentUser();
var userId = UserId.create(user.userId);

// multiple users
var userIds = UserIdList.create(user.userId, anotherUser.userId);
const userId = UserId.create(user.userId);

// multiple users
const userIds = UserIdList.create(user.userId, anotherUser.userId);
const userId = GetSocialSDK.UserId.create(user.userId);

// multiple users
const userIds = GetSocialSDK.UserIdList.create([user.userId], [anotherUser.userId]);

Identity User ID

If you’ve added the custom identity to you users, you can then use this identity as user identifier:

// that's how you created identity
val identity = Identity.custom("my-custom-identity", "user-id", "*****")

val userId = UserId.createWithProvider("my-custom-identity", "user-id")

// multiple users
val userIds = UserIdList.createWithProvider("my-custom-identity", "user-id", "another-user-id")
// that's how you created identity
let identity = Identity.custom("my-custom-identity", "user-id", "*****")

let userId = UserId.createWithProvider("my-custom-identity", "user-id")

// multiple users
let userIds = UserIdList.createWithProvider("my-custom-identity", "user-id", "another-user-id")
// that's how you created identity
var identity = Identity.Custom("my-custom-identity", "user-id", "*****");

var userId = UserId.CreateWithProvider("my-custom-identity", "user-id");

// multiple users
val userIds = UserIdList.CreateWithProvider("my-custom-identity", "user-id", "another-user-id");
// that's how you created identity
var identity = Identity.custom('my-custom-identity', 'user-id', '*****');

var userId = UserId.createWithProvider('user-id', 'my-custom-identity');

// multiple users
val userIds = UserIdList.createWithProvider(['user-id', 'another-user-id'], 'my-custom-identity');
// that's how you created identity
const identity = Identity.createCustomIdentity('my-custom-identity', 'user-id', '*****');

const userId = UserId.createWithProvider('my-custom-identity', 'user-id');

// multiple users
const userIds = UserIdList.createWithProvider('my-custom-identity', ['user-id', 'another-user-id']);
// that's how you created identity
const identity = GetSocialSDK.Identity.createCustomIdentity('my-custom-identity', 'user-id', '*****');

const userId = GetSocialSDK.UserId.createWithProvider('my-custom-identity', 'user-id');

// multiple users
const userIds = GetSocialSDK.UserIdList.createWithProvider('my-custom-identity', ['user-id', 'another-user-id']);

Give us your feedback! Was this article helpful?

😀 🙁