Support Topics Documentation Slack YouTube Blog

Find out if user signed up on certain platform

Hi,

We currently allow our users to login both through the website (JS SDK), as well as on our mobile app (iOS SDK). I wonder if there is any way to determine if a specific customer has ever signed in through the iOS SDK (i.e. using our mobile app)? So far, I am not tracking this information myself.

Thanks,
Justinas

Hello @Justinas_Grazulis

Yes, you can determine if the user is logged in from IOS or JS.
To do this, you need to create EVENT HANDLER (Developing Backendless Server Code):
Business Logic - EVENT HANDLERS - New Event Handler

For JS:

* @param {Object} req The request object contains information about the request
* @param {Object} req.context The execution context contains an information about application, current user and event
* @param {string} req.login 
* @param {string} req.password 
*
* @returns {Object|Promise.<Object>|void} By returning a value you can stop further event propagation and return
*          a specific result to the caller
*/
Backendless.ServerCode.User.beforeLogin(function(req) {
  //add your code here
});

The req.context contains all the information that you need, here you can use this information as you want, for example, make entries in your table about the time when the user logged in, from which SDK, or simply increase the login counter for IOS …

Thanks @Vladimir_Yalovy, that seems to be the way to go, should be perfect for me. Thanks!