Multi-Device Login and Synchronization

As more and more users use multiple devices, it is an absolute necessity for all apps to support multi-device login and synchronization to maintain a consistent and smooth user experience across all their devices.

mesibo offers the capability for users to sign in from multiple devices. Users have the option to log in from up to eight devices simultaneously. All their data, including messages, calls, profiles, images, files, etc. will be automatically synchronized across all their devices.

For instance, when a user receives a message or a call, they will receive it on all the devices they are logged into. Similarly, when a user sends a message, it will be synchronized across all of their devices.

To enable multi-device, your apps do not need to do anything extra or use any additional APIS. You only need to generate a separate user token for each device the user will log in from using mesibo backend APIs using an extra parameter as explained below. That's it.

It is important to note that, for each additional device, mesibo will create a new linked user, which will automatically sync and replicate the primary user. This is required because each user maintains their own real-time connection. For practical purposes, this process is transparent to your application.

There are two ways you can generate tokens for multi-device login as explained below. It is assumed that you are familiar with creating user and user tokens. If not, refer to the Get Started Tutorial.

In both examples, the main user is xyz@example.com. Any messages or calls to xyz@example.com will be received by all the linked users. Similarly, any messages or calls sent by any linked users will go as send from`xyz@example.com`.

Specifying a Login Device

You can specify a device or installation ID when generating a token using backend APIs. The device or installation ID is your application dependent and should uniquely identify your app installation on a particular device or web. For example, Android-123, ios-456, etc. mesibo will check existing tokens and devices to check if it can use an existing user for a linked device or create a new user.

{
  "op":"useradd",
  "token": "ptlk9hdel1gqxf3p0s15f5f5gtusldej18tl794suzit",
  "user": {
	"address":"xyz@example.com",
	"name":"User Name",

  	"token": {
		"appid": "com.example.mesiboapp",
		"expiry": 525600
		"device": "myphone-123"
  	}
  }
}

The response could be like the following if there were no existing tokens

{ 
  "user": {
	"uid":123,
	"address":"xyz@example.com",
	"token":"79a818d76fe45fb5a3ac395a0a98251c3db2eetb7b0d4aa0"
  },
  "op":"useradd",
  "result":true
}

Or, the response could be like the following if mesibo needs to create or use an additional user

{ 
  "user": {
	"uid":456,
	"address":"xyz@example.com-linked-123456",
	"token":"79a818d76fe45fb5a3ac395a0a98251c3db2eetb7b0d4aa0"
  },
  "op":"useradd",
  "linked":"true",
  "linkto": 123,
  "result":true
}

Manually Specifying Linked User

If you prefer to have more control over user creation and linking for multi-device login, you can use linkto parameter in the token request instead of device parameter. If both parameters are specified, linkto has higher priority.

In the following request, the new user abc@example.com will be created and linked to the existing user xyz@example.com

{
  "op":"useradd",
  "token": "ptlk9hdel1gqxf3p0s15f5f5gtusldej18tl794suzit",
  "user": {
	"address":"abc@example.com",

  	"token": {
		"appid": "com.example.mesiboapp",
		"expiry": 525600
		"linkto":"xyz@example.com",
  	}
  }
}

The response could be like the following,

{ 
  "user": {
	"uid":567,
	"address":"abc@example.com",
	"token":"79a818d76fe45fb5a3ac395a0a98251c3db2eetb7b0d4aa0"
  },
  "op":"useradd",
  "linked":"true",
  "linkto": 123,
  "result":true
}