btkelly/gandalf

Blocking alert not shown when user skips optional update

Closed this issue · 5 comments

If there is a blocking alert and an optional version set, the user is presented with the optional update but can skip and continue using the app without ever seeing the alert.

That sounds bad! Can you please give an example of a JSON response that causes the reported issue? Thanks :)

If you set the versionCode to 1, you should see the optional update dialog and be able to skip it without seeing the blocking alert.

{
  "android": {
    "alert": {
      "message": "This is a blocking alert test.",
      "blocking": true
    },
    "requiredUpdate": {
      "minimumVersion": "1",
      "message": "An update is required to continue using this app."
    },
    "optionalUpdate": {
      "optionalVersion": "2",
      "message": "An update is optional to continue using this app."
    }
  }
}

Not sure what the solution would be to this. My only thoughts is that maybe the alert condition check should be checked before optional version so the business logic would be any condition that could be blocking would be presented before anything optional?

this is the logic it's in the Gandalf class

if (gateKeeper.updateIsRequired(bootstrap)) {
  LoggerUtil.logD("Update is required");
  gandalfCallback.onRequiredUpdate(bootstrap.getRequiredUpdate());
} else if (gateKeeper.updateIsOptional(bootstrap)) {
  LoggerUtil.logD("Update is optional");
  gandalfCallback.onOptionalUpdate(bootstrap.getOptionalUpdate());
} else if (gateKeeper.showAlert(bootstrap)) {
  LoggerUtil.logD("Alert");
  gandalfCallback.onAlert(bootstrap.getAlert());
} else {
  LoggerUtil.logD("No action is required");
  gandalfCallback.onNoActionRequired();
}

We should be able to change that ordering around, you make a good point.

I can submit a PR if you guys agree this should be changed. Let me know.