0

EDIT

I just need to differentiate between the three types of devices. So that in my application I can send updates to the current user but on his other active devices, if he currently has an active session from any of these other devices!

possible solution
I could just ignore this, since it makes it harder. But that means I always send a push update, even though the user only accesses the application from one device! This does however give me the advantage that the push notifications history will always have a full history of push notifications. Instead of sometimes no push notification since he is only active on one device at the time of the possible push notification (when this notification is thus not needed)

ORIGINAL

So I have an application which has node.js as back-end. Now it's made so that the same server (meaning backend code) is used for:

  1. browser client
  2. Android app
  3. iOS app

Everything is JSON.

Now how do I get to know from which "device" a request originates.

The "type of device" is only checked at boot, after that the "type of device" is stored in the user's session.

Putting a "secret" inside the mobile app binary is not safe (I think).

xrDDDD
  • 583
  • 9
  • 23

2 Answers2

1

For iOS, you could use a unique identifier (like as what you can find detailed in this related question/answer). Keep in mind that the unique identifier will change if the user deletes and reinstalls your app.

For Browsers, you could use the IP address or some kind of "token" or cookie you give it when the browser first connects to your server.

For Android, you can use Settings.Secure#ANDROID_ID, as found in the answer to this question.

Community
  • 1
  • 1
Michael Dautermann
  • 88,797
  • 17
  • 166
  • 215
1

You could use the User-Agent header to pass the device and the os version just how the browser does right now.

Stepan Grigoryan
  • 3,062
  • 1
  • 17
  • 6