@classmethod
  @gen.coroutine
  def Register(cls, client, user_id, device_dict, is_first=True):
    assert 'device_id' in device_dict, device_dict

    device = yield gen.Task(Device.Query,
                            client,
                            user_id,
                            device_dict['device_id'],
                            None,
                            must_exist=False)
    if device is None:
      device = Device.Create(user_id=user_id, timestamp=util.GetCurrentTimestamp(), **device_dict)
    else:
      device.UpdateFields(**device_dict)

    yield gen.Task(device.Update, client)

    # If this is the first mobile device to be registered, then turn turn off email alerting
    # and turn on full push alerting to mobile devices.
    if is_first:
      settings = AccountSettings.CreateForUser(user_id,
                                               email_alerts=AccountSettings.EMAIL_NONE,
                                               sms_alerts=AccountSettings.SMS_NONE,
                                               push_alerts=AccountSettings.PUSH_ALL)
      yield gen.Task(settings.Update, client)

    raise gen.Return(device)
Registers a new device or update an existing device, using the fields in "device_dict".
dataset/ETHPy150Open viewfinderco/viewfinder/backend/db/device.py/Device.Register