registerDevice method

dynamic registerDevice(
  1. SharedPreferences prefs, {
  2. String? userId,
})

Implementation

registerDevice(SharedPreferences prefs, {String? userId}) {
  var params = {
    'device': DbPlatform.operatingSystem,
    'device_token': DbPlatform.getDeviceId(prefs),
    'user_id': userId ??= '' // user uuid
  };

  post('/api/device/register', body: params).then((response) {
    if (response.statusCode == 200) {
      prefs.setString(Application.uuidKey, params["device_token"]!);
    }
  });
}