Italiano

7. Push update

Level: procedure. How to ask the installed apps to check the published configuration right away, instead of waiting for their next check: the Firebase credential it needs, the button, Publish and notify in the editor, what the outcome says and what it cannot say. The previous page is Recipes.

When it is needed

An app with Squiddy's SDK checks the configuration by itself: at every start and every time it comes back to the foreground. While it stays in the foreground it checks at an interval only if the API block it is served has a refreshInterval (page 3): without the field there is no periodic check, and that is the default. It is so since SDK 0.3.0; up to 0.2.0 the interval was chosen by whoever develops the app, 5 minutes if they did not change it. For a normal publishing this is enough: whoever uses the app has the new version at the next start or the next return to the foreground, or within the block's interval.

The Push update is for when you cannot wait: a maintenance to show now, a mandatory update, an endpoint to move because the old one no longer answers. It does not start by itself when you publish, by choice: it is a button you press when needed, after publishing, or Publish and notify in the editor, which publishes and notifies in a single gesture (further down).

What happens when you press it:

  1. The Push update button tells Squiddy.
  2. Squiddy sends Firebase Cloud Messaging a message for every active API key.
  3. Firebase delivers it to the subscribed installations.
  4. Every installation, within a random delay, asks Squiddy for the configuration again.

Squiddy sends through Firebase Cloud Messaging a message without text, which nobody sees, to the installations of the app in that environment; each one, within a random delay (up to a minute with the SDK's default settings), asks for the configuration and receives the published version. The delay is there so that the installations do not all arrive in the same second with the same API key, which has a limit of calls per minute.

What the app must have. The push update reaches only the installations of an app that has Squiddy's SDK (from 0.1.0) and Firebase Messaging, and that subscribes to the topic the SDK gives it: it is work for whoever develops the app, described in the SDK guide on the documentation site (section Push update, for Android and for iOS). The installations that do not do it, or that cannot be reached, lose nothing: they find the new version at their next check.

Where it is

Configurations page of the environment → choose the app → Push update tab, next to Editor, Tester and History. The push update and the credential are per configuration, that is for that app in that environment.

The tab is used by Editor, Admin and Owner. A Viewer sees only the Editors only box: “You need to be an editor, admin or owner of this tenant to manage this app's Firebase credential.”

The tab has three parts: at the top the button, then the history of the push updates of the last 90 days, at the bottom the credential Squiddy sends them with. The first time, you start from the bottom.

The Firebase credential

Squiddy sends the push update with the service account of the app's Firebase project. Whoever develops the app provides it: it is a JSON file you get in the Firebase console, Project settings → Service accounts → Generate new private key (it is the hint the tab itself shows under the field).

In the Firebase credential card:

CommandWhat it does
Service account key (JSON) + Upload and checkSquiddy reads the file, checks that it is a Google service account key and tries it with Google, with a test send that Firebase checks and discards without notifying anyone. Squiddy keeps it only if Google accepts it
Check with GoogleRepeats the test on the stored credential: useful if in the meantime someone may have revoked it in the Firebase console
ReplaceUploads another file in place of the stored one, with the same test
RemoveDeletes the credential, after a confirmation: from then on the button stays disabled until another one is uploaded

After the upload the card shows Firebase project, Service account, Key ID, Uploaded and Last checked with Google. The private key is never shown again: Squiddy keeps it encrypted and uses it only to ask Google to deliver the push update.

The refusals, and what they mean:

MessageCauseWhat to do
“The chosen file is not a JSON key file. Choose the file downloaded from the Firebase console.” or “The chosen file is larger than any service account key (16 KiB at most).”It is not the right fileDownload the key from the Firebase console, as above
“This file is not a usable Firebase service account key:” followed by the detailThe JSON is a key, but something is missing (project, account, private key)Generate a new key
“Google refused this credential. Google's reason:”The key was deleted in the console, or the account is not allowed to send messagesGenerate a new key and upload it with Replace. A credential already stored that Google refuses at the check stays stored until it is replaced or removed
“Google could not be reached to check the credential, so nothing changed. Try again in a moment.”Google did not answerTry again in a moment

One credential per configuration means that testing and production can use different Firebase projects, as often happens, and that two apps of the same environment each have their own. If several configurations use the same Firebase project, you upload the same file in each one.

The button

The Push update card shows the published version (“Published version: v7”) and the button. The button is active only when the push update can be sent; otherwise it is disabled, and under it there is the reason:

Reason shownWhat is missing
“Upload this app's Firebase credential below first: Squiddy sends the push update with it.”The credential
“Publish this configuration first: installations only ever receive the published version.”A published version: notifying a draft would make no sense, nobody would receive it
“This app id has upper-case letters, so the data plane never serves it and no installation can be notified. Use a lowercase app id.”A lowercase appId: the data plane does not serve an appId with capitals, so there is no installation to notify

When you press it, the confirmation “Send the push update?” opens, which reminds you that every installation of that app in that environment will check the configuration now, and that the next push update can be sent in a minute. Send sends it.

Squiddy makes one more check the tab cannot see: the environment must have at least one active API key (and no more than a hundred), otherwise the push update is not sent and the message “This configuration cannot be notified yet:” says why.

One push update a minute per configuration. A second press within the minute is refused with “A push update was sent for this configuration less than a minute ago. Try again in N s.”. The limit is per configuration, not per person pressing: two colleagues pressing together produce a single push update. If Squiddy cannot check when the last push update was sent, it sends nothing, to be safe (“Squiddy could not check when this configuration was last notified, so nothing was sent. Try again in a moment.”).

How to read the outcome

The push update is sent once for every active API key of the environment: every installation is subscribed to a Firebase topic that depends on the key the app calls with and on the appId, and so the installations of a version of the app with an older key, not revoked yet, are reached too. Revoked keys are left out. The outcome appears in the card, with how many keys it was sent to and the version the installations will find, together with its configVersion (the one the app reads in every answer, and that publishing updates by itself: see page 3):

OutcomeMeaning
“Push update sent to 1 active API key of this environment: Firebase accepted it. The installations will find version 6 (configVersion 1.0.4).” — with more keys “Push update sent to 3 active API keys of this environment: Firebase accepted it for all of them…”Everything was sent
“Push update sent to 3 active API keys of this environment, but Firebase accepted it for only 2. The installations of the keys it accepted will find version 6 (configVersion 1.0.4) now, the others at their next check.”Some keys yes and others no; every key not accepted is listed with its name and prefix, and the reason (refused by Google, or no answer from Google; try again in a minute)
“Push update not sent: Firebase accepted it for none of the 3 active API keys of this environment. The installations will find version 6 (configVersion 1.0.4) at their next check.” — with a single key “…Firebase did not accept it for the only active API key of this environment…”Nothing was sent: usually the credential is no longer valid (see Check with Google). The version stays published: the apps find it anyway at their next check

“Accepted” does not mean “delivered”. Firebase only says it has taken charge of the message; how many installations receive it, and when, depends on Firebase, on Apple and on the devices (an iPhone does not wake an app the user has force-quit, a phone that is off receives it when it is switched on again). Squiddy has no way of counting them. Whoever develops the app can see it arrive in the SDK's logs.

Publish and notify

In the Editor tab, next to Publish, the Publish and notify button does both things in a single gesture: it publishes the saved version and, right after, sends the push update of the version just published. It is for when the new version must reach the apps now, without going through the tab.

When it is active. The conditions of Publish hold (a saved version, no unsaved changes, validation without problems, the Editor role or higher: see page 2), plus those of the push update, which the editor checks beforehand, instead of finding them out once the version is published. When something is missing the button is disabled, and under the buttons there is the reason, which starts with “Publish and notify” is off.:

Reason shownWhat is missing
“This app has no Firebase credential in this environment yet: upload it in the Push update tab.”The credential, as for the tab's button
“This environment has no active API key, and the push update reaches installations through their keys: create one on the API keys page.”At least one active API key in the environment. It is the check the tab leaves to the service: the editor makes it by itself, because otherwise it would find out only after publishing
“This app id has upper-case letters, so the data plane never serves it and no installation can be notified. Use a lowercase app id.”A lowercase appId, as for the tab's button
“The Firebase credential or the API keys of this environment could not be read: the Push update tab says more.”One of the two readings failed: the tab shows the error

Next to the reason, Open Push update takes you to the tab. Whoever has a role lower than Editor sees the button disabled without a reason, like Publish: the permissions are those of the two buttons.

A single confirmation, Publish and send the push update, which names the two actions: the publishing, which reaches every app of the environment, and the push update, which makes the installations check now; and it reminds you that the push update is sent only if the publishing succeeds.

The order. First the publishing, then the push update, and the push update only if the publishing succeeded. If the publishing is refused, for example by the strict validation, the confirmation stays open with the same message as Publish and no push update is sent.

The outcome, with the sentences of publishing and of the tab:

What happenedWhat you see
Published, and Firebase accepted the push update for every keyA notification that says both things: “Version 7 published: configVersion went up by itself to 1.0.5. Push update sent to 1 active API key of this environment: Firebase accepted it. The installations will find version 7 (configVersion 1.0.5).”
Published, but Firebase accepted it only for some keysIn the editor the warning “Published, but the push update reached only some keys”, with the publishing sentence, the partial outcome and every key not accepted with Google's reason
Published, but the push update was not sent: Firebase accepted it for no key, or Squiddy refused it (less than a minute since the previous one, a requirement that lapsed in the meantime, more than a hundred active keys)In the editor the warning “Published, but the push update was not sent”, with the publishing sentence and the reason, in the same words as the tab: for the limit, “A push update was sent for this configuration less than a minute ago. Try again in N s.”

In any case the publishing stays: the editor shows the new configVersion and the apps find the version at their next check. The warning stays until you close it. To try the push update again you use the tab's button, after the minute: pressing Publish and notify again would publish the same version again, which stays as it is, and then notify.

In the audit log two separate entries remain, the publishing and the push update, exactly as when pressing the two buttons one after the other, and the push update appears in the tab's history.

The history of push updates

Under the button, the Push updates of the last 90 days card lists every push update sent for that configuration, newest first, and refreshes by itself after every press of the button, and after every Publish and notify:

ColumnWhat it shows
SentDate and time of the send, in the local time of whoever is looking
VersionThe published version the push update announced (v7) and, under it, its configVersion (configVersion 1.0.4). The push updates sent before Squiddy recorded it show only the version
Sent byThe email address of whoever pressed the button
Outcomesucceeded, partial or failed, with how many active API keys Firebase accepted it for and, when there is one, Google's reason

Older push updates are loaded with Load older push updates. With no push update in the last 90 days the card says “No push update sent in the last 90 days.”

The history is seen by whoever can send the push update (Editor, Admin, Owner), and it holds only the push updates of that configuration: to see everything else you need the Audit log, which Admin and Owner see. Like the log, it lists every push update attempted, failed ones included, and none of those refused before being sent.

What stays in the audit log

In the Audit log (Dashboard → Audit log) these remain:

ActionWhenDetail
Firebase credential uploaded / replaced / removedUpload, replacement, removalProject, account and key ID, never the key
Push update sentEvery push update attempted, successful or notOutcome, published version and its configVersion, number of keys, how many accepted and Google's reasons. They are the same entries the tab's history shows for the configuration

The checks with Google and the push updates refused before being sent (a missing requirement, the one-minute limit) leave no trace.