Multi-Device Login and Synchronization

Estimated reading time: 4 minutes

As more and more users use multiple devices, it is an absolute necessity for all apps to support multi-device operations to have their user experience consistent and seamless across all devices.

mesibo now allows your users to log in from multiple devices. Your user can log in from as many as 8 devices simultaneously and all their data including messages, calls, profiles, pictures, files, etc will be synced automatically across all devices.

For example, when your user will receive a message or a call, he will receive it on all the devices, that he has logged in from. Similarly, when the user sends a message, it will be synced to all the 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.

Note that, for each additional device, mesibo will create a new linked user which will automatically sync and clone the main user. This is required since each user maintains his own real-time connection. For all practical cases, you only need to use a token and hence this is transparent to your app.

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 fromxyz@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
}
multi-device, login