<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Push providers on back(d)</title><link>https://fernandezvara.github.io/backd/docs/operate/providers/push/</link><description>Recent content in Push providers on back(d)</description><generator>Hugo</generator><language>en-us</language><atom:link href="https://fernandezvara.github.io/backd/docs/operate/providers/push/index.xml" rel="self" type="application/rss+xml"/><item><title>Local development</title><link>https://fernandezvara.github.io/backd/docs/operate/providers/push/local/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://fernandezvara.github.io/backd/docs/operate/providers/push/local/</guid><description>&lt;p&gt;You don&amp;rsquo;t need a device or a provider key to develop with push.&lt;/p&gt;
&lt;h2 id="the-capture-provider"&gt;The capture provider&lt;a class="hd-anchor" href="#the-capture-provider" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Give a platform &lt;code&gt;provider: capture&lt;/code&gt;: the worker then &lt;strong&gt;stores each delivery&lt;/strong&gt; in a &lt;code&gt;push_outbox&lt;/code&gt; collection of the realm&amp;rsquo;s system database instead of calling a provider, with the message as it would have gone out and the outcome the device was given.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-yaml" data-lang="yaml"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nt"&gt;push&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;android&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;{&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;provider&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l"&gt;capture }&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;web&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;provider&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l"&gt;capture&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It needs no credentials and no secrets, but it stores message content, so &lt;strong&gt;startup refuses it unless &lt;code&gt;BACKD_DEV=true&lt;/code&gt;&lt;/strong&gt;. Captured deliveries are kept for 24 hours.&lt;/p&gt;</description></item><item><title>FCM: Android, and iOS apps on the FCM SDK</title><link>https://fernandezvara.github.io/backd/docs/operate/providers/push/fcm/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://fernandezvara.github.io/backd/docs/operate/providers/push/fcm/</guid><description>&lt;p&gt;FCM is the provider for &lt;strong&gt;Android&lt;/strong&gt;, and for &lt;strong&gt;iOS apps that use the FCM SDK&lt;/strong&gt; (&lt;code&gt;ios.provider: fcm&lt;/code&gt;). backd sends through FCM&amp;rsquo;s HTTP v1 API from the worker, with an OAuth2 access token it mints from a &lt;strong&gt;service account&lt;/strong&gt;.&lt;/p&gt;
&lt;h2 id="1-a-firebase-project"&gt;1. A Firebase project&lt;a class="hd-anchor" href="#1-a-firebase-project" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Open the &lt;a href="https://console.firebase.google.com"&gt;Firebase console&lt;/a&gt; and create a project, or pick the one your app uses.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Android:&lt;/strong&gt; add an Android app with your application id (the package name). Download &lt;code&gt;google-services.json&lt;/code&gt; for the app&amp;rsquo;s build.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;iOS over FCM:&lt;/strong&gt; add an iOS app with the bundle id, download &lt;code&gt;GoogleService-Info.plist&lt;/code&gt;, and upload an &lt;strong&gt;APNs authentication key&lt;/strong&gt; under &lt;em&gt;Project settings → Cloud Messaging → Apple app configuration&lt;/em&gt; (see &lt;a href="../apns/#1-the-key"&gt;APNs&lt;/a&gt; for where it comes from). That key lives in Firebase: backd never sees it.&lt;/li&gt;
&lt;li&gt;In the linked Google Cloud project, enable the &lt;strong&gt;Firebase Cloud Messaging API (V1)&lt;/strong&gt; (&lt;em&gt;APIs &amp;amp; Services → Library&lt;/em&gt;). The legacy API is not used.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id="2-a-service-account"&gt;2. A service account&lt;a class="hd-anchor" href="#2-a-service-account" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;&lt;em&gt;Project settings → Service accounts → Generate new private key.&lt;/em&gt; A JSON file downloads: it holds &lt;code&gt;project_id&lt;/code&gt;, &lt;code&gt;client_email&lt;/code&gt; and &lt;code&gt;private_key&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Store it as a realm secret, from the file:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;backd secret &lt;span class="nb"&gt;set&lt;/span&gt; --realm acme --name FCM_SERVICE_ACCOUNT &amp;lt; service-account.json
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The value is read from standard input, newlines included, and encrypted with the instance&amp;rsquo;s &lt;code&gt;BACKD_SECRETS_KEY&lt;/code&gt;. Delete the downloaded file afterwards.&lt;/p&gt;</description></item><item><title>APNs: iOS</title><link>https://fernandezvara.github.io/backd/docs/operate/providers/push/apns/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://fernandezvara.github.io/backd/docs/operate/providers/push/apns/</guid><description>&lt;p&gt;&lt;code&gt;ios.provider: apns&lt;/code&gt; sends to iPhones and iPads directly through Apple&amp;rsquo;s push service: HTTP/2, authenticated with a &lt;strong&gt;token&lt;/strong&gt; signed by a key you create in your Apple Developer account. (Apps on the FCM SDK use &lt;a href="../fcm/"&gt;FCM&lt;/a&gt; instead.)&lt;/p&gt;
&lt;h2 id="1-the-key"&gt;1. The key&lt;a class="hd-anchor" href="#1-the-key" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;In the &lt;a href="https://developer.apple.com/account"&gt;Apple Developer account&lt;/a&gt;: &lt;em&gt;Certificates, Identifiers &amp;amp; Profiles → Keys → +&lt;/em&gt;. Name it, tick &lt;strong&gt;Apple Push Notifications service (APNs)&lt;/strong&gt;, and continue.&lt;/li&gt;
&lt;li&gt;Download the &lt;code&gt;.p8&lt;/code&gt; file: &lt;strong&gt;it can be downloaded once&lt;/strong&gt;. Note the 10-character &lt;strong&gt;Key ID&lt;/strong&gt; shown.&lt;/li&gt;
&lt;li&gt;Note your &lt;strong&gt;Team ID&lt;/strong&gt;: the 10 characters at the top right of the account&amp;rsquo;s &lt;em&gt;Membership details&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;topic&lt;/strong&gt; is your app&amp;rsquo;s bundle id (for example &lt;code&gt;com.acme.app&lt;/code&gt;). The app&amp;rsquo;s &lt;em&gt;App ID&lt;/em&gt; must have the &lt;strong&gt;Push Notifications&lt;/strong&gt; capability enabled.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id="2-the-secret"&gt;2. The secret&lt;a class="hd-anchor" href="#2-the-secret" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;backd secret &lt;span class="nb"&gt;set&lt;/span&gt; --realm acme --name APNS_KEY &amp;lt; AuthKey_AB12CD34EF.p8
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The file is read as it is, newlines included.&lt;/p&gt;</description></item><item><title>Web Push: browsers</title><link>https://fernandezvara.github.io/backd/docs/operate/providers/push/web-push/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://fernandezvara.github.io/backd/docs/operate/providers/push/web-push/</guid><description>&lt;p&gt;&lt;code&gt;web.provider: webpush&lt;/code&gt; sends to browsers with the standard Web Push protocol: no account with a vendor, only a &lt;strong&gt;VAPID key pair&lt;/strong&gt; that identifies your realm to the browsers&amp;rsquo; push services (Google, Mozilla, Apple, Microsoft).&lt;/p&gt;
&lt;h2 id="1-the-key-pair"&gt;1. The key pair&lt;a class="hd-anchor" href="#1-the-key-pair" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;backd push web-keys --realm acme
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It generates a P-256 key pair, stores the &lt;strong&gt;private&lt;/strong&gt; half as the realm secret &lt;code&gt;VAPID_PRIVATE_KEY&lt;/code&gt;, and prints the &lt;strong&gt;public&lt;/strong&gt; half with the &lt;code&gt;realm.yaml&lt;/code&gt; snippet:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;push:
 web:
 provider: webpush
 public_key: BEl62iUYgUivxIkv69yViEuiBIa-Ib9-SkvMeAtA3LFgDzkrxZJjSgSnfckjBJuBkr3qBUYIHBQFLXYp5Nksh8U
 private_key: secret:VAPID_PRIVATE_KEY
 subject: secret:VAPID_SUBJECT
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id="2-the-subject"&gt;2. The subject&lt;a class="hd-anchor" href="#2-the-subject" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Browsers&amp;rsquo; push services use a contact URI to reach you when something goes wrong with your pushes:&lt;/p&gt;</description></item></channel></rss>