Skip to content

Commit

Permalink
[1/1][docs] Add FCM V1 instructions to Google Service Account Key docs
Browse files Browse the repository at this point in the history
# Why
We need to amend these docs to support using a Google Service Account Key for sending Android notifications via FCM V1. These docs are linked in the CLI when users are configuring Google Service Account Keys for submissions and notifications. (See @quinlanj's comment on this PR in eas-cli: expo/eas-cli#2197 (comment)).

# How
1. Update the top-level intro with an explanation of the two use cases for uploading a Google Service Account Key to EAS.
2. Move existing instructions for `eas submit` into a new subsection
3. Add a subsection for instructions for uploading GSAK for FCM V1

# Test Plan
Get feedback on copy, check that preview markdown looks good
  • Loading branch information
christopherwalter committed Feb 8, 2024
1 parent 08b7d82 commit 6302597
Show file tree
Hide file tree
Showing 16 changed files with 72 additions and 2 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
74 changes: 72 additions & 2 deletions creating-google-service-account.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
# Creating a Google Service Account
# Using a Google Service Account Key with EAS

If you’d like to submit your Android app to Google Play Store with `eas submit` you need to create a Google Service Account key. To do this, the following steps are required:
A Google Service Account Key is a credential in the form of a JSON file that you can obtain via Google Cloud for a particular Google Service Account.

EAS requires a Google Service Account Key to be uploaded and configured for the following use cases:

1. submitting your Android app to Google Play Store with `eas submit`
2. sending Android notifications via `api.expo.dev/push/send` using the FCM V1 protocol
- note: beginning in June 2024, all Android notifications must be sent using the FCM V1 protocol

You can configure separate Google Service Account Keys for each of these use cases, or upload a single Google Service Account Key and use it for both use cases (provided that the correct authorizations are in place for that Service Account in Google Cloud Console).

The steps for each use case are detailed below.

## Uploading a Google Service Account Key for Play Store Submissions

To set up a Google Service Account Key for Play Store Submissions via `eas submit`, the following steps are required:

- Create a Google Cloud project (optional if you already have one)
- Create a Google Service Account and create and download the JSON key file
Expand Down Expand Up @@ -43,3 +57,59 @@ If you’d like to submit your Android app to Google Play Store with `eas submit
[<img src="./assets/creating-google-service-account/11-set-permissions.png" width="800" />](./assets/creating-google-service-account/11-account-permissions.png)

9. That's all! From now on, you can use the generated Google Service Account key to upload your app with `eas submit`.

## Using a Google Service Account Key for Sending Android Notifications via FCM V1

Here are the steps to set up a Google Service Account Key for sending Android Notifications via FCM V1.

### Configuring a new Google Service Account Key for Android Notifications using FCM V1

Here are the steps to configure a new Google Service Account Key in EAS for sending Android Notifications using FCM V1.

1. (If you already have a Firebase project for your app, continue to the next step.) Create a new Firebase project for your app in the [Firebase Console](https://console.firebase.google.com)

[<img src="./assets/creating-google-service-account/fcm-v1/new-service-account/01-new-firebase-project.png" width="800" />](./assets/creating-google-service-account/fcm-v1/new-service-account/01-new-firebase-project.png)

2. In the Firebase console, open Settings > [Service Accounts](https://console.firebase.google.com/project/_/settings/serviceaccounts/adminsdk) for your project

[<img src="./assets/creating-google-service-account/fcm-v1/new-service-account/02-manage-service-accounts.png" width="800" />](./assets/creating-google-service-account/fcm-v1/new-service-account/02-manage-service-accounts.png)

3. Click **Generate New Private Key**, then confirm by clicking **Generate Key**. Securely store the JSON file containing the private key.

[<img src="./assets/creating-google-service-account/fcm-v1/new-service-account/03-generate-key.png" width="800" />](./assets/creating-google-service-account/fcm-v1/new-service-account/03-generate-key.png)

4. Upload the JSON file to EAS and configure it for sending Android notifications. This can be done in EAS CLI or via [expo.dev](https://expo.dev).
- using EAS CLI: run `eas credentials` > `Android` > `production` > `Google Service Accounts` > `FCM V1`
- using [expo.dev](https://expo.dev): navigate to credentials page for your project (`expo.dev/accounts/<my_account>/projects/<my_project>/credentials`) > click on the Android application identifier > find the section entitled "FCM V1 service account key" > click **Add a service account key** > upload your JSON credential and click **Save**

[<img src="./assets/creating-google-service-account/fcm-v1/new-service-account/04-upload-credential-1.png" width="800" />](./assets/creating-google-service-account/fcm-v1/new-service-account/04-upload-credential-1.png)
[<img src="./assets/creating-google-service-account/fcm-v1/new-service-account/04-upload-credential-2.png" width="800" />](./assets/creating-google-service-account/fcm-v1/new-service-account/04-upload-credential-2.png)
[<img src="./assets/creating-google-service-account/fcm-v1/new-service-account/04-upload-credential-3.png" width="800" />](./assets/creating-google-service-account/fcm-v1/new-service-account/04-upload-credential-3.png)

5. You're all set! You can now send notifications to Android devices via Expo Push Notifications using the FCM V1 protocol.
[<img src="./assets/creating-google-service-account/fcm-v1/new-service-account/05-upload-credential-complete.png" width="800" />](./assets/creating-google-service-account/fcm-v1/new-service-account/05-upload-credential-complete.png)


### Using an existing Google Service Account Key to Send Android Notifications using FCM V1

1. Open the [IAM Admin page](https://console.cloud.google.com/iam-admin/iam?authuser=0) in Google Cloud Console. In the Permissions tab, locate the Principal you intend to modify and click the pencil icon for **Edit Principal**.

[<img src="./assets/creating-google-service-account/fcm-v1/existing-service-account/01-iam-admin-page.png" width="800" />](./assets/creating-google-service-account/fcm-v1/existing-service-account/01-iam-admin-page.png)

2. Click **Add Role** and select the `Firebase Messaging API Admin` role from the dropdown. Click **Save**.

[<img src="./assets/creating-google-service-account/fcm-v1/existing-service-account/02-add-role-1.png" width="800" />](./assets/creating-google-service-account/fcm-v1/existing-service-account/02-add-role-1.png)
[<img src="./assets/creating-google-service-account/fcm-v1/existing-service-account/02-add-role-2.png" width="800" />](./assets/creating-google-service-account/fcm-v1/existing-service-account/02-add-role-2.png)
[<img src="./assets/creating-google-service-account/fcm-v1/existing-service-account/02-add-role-3.png" width="800" />](./assets/creating-google-service-account/fcm-v1/existing-service-account/02-add-role-3.png)

3. Tell EAS which JSON credential file to use for sending FCM V1 notifications, either via EAS CLI or the [expo.dev](https://expo.dev) website. You can upload a new JSON file or select a previously uploaded file.
- using EAS CLI: run `eas credentials` > `Android` > `production` > `Google Service Accounts` > `FCM V1`
- using [expo.dev](https://expo.dev): navigate to credentials page for your project (`expo.dev/accounts/<my_account>/projects/<my_project>/credentials`) > click on the Android application identifier > find the section entitled "FCM V1 service account key" > click **Add a service account key** > upload your JSON credential and click **Save**

[<img src="./assets/creating-google-service-account/fcm-v1/existing-service-account/03-upload-credential-1.png" width="800" />](./assets/creating-google-service-account/fcm-v1/existing-service-account/03-upload-credential-1.png)
[<img src="./assets/creating-google-service-account/fcm-v1/existing-service-account/03-upload-credential-2.png" width="800" />](./assets/creating-google-service-account/fcm-v1/existing-service-account/03-upload-credential-2.png)
[<img src="./assets/creating-google-service-account/fcm-v1/existing-service-account/03-upload-credential-3.png" width="800" />](./assets/creating-google-service-account/fcm-v1/existing-service-account/03-upload-credential-3.png)

4. You're all set! You can now send notifications to Android devices via Expo Push Notifications using the FCM V1 protocol.
[<img src="./assets/creating-google-service-account/fcm-v1/existing-service-account/04-upload-credential-complete.png" width="800" />](./assets/creating-google-service-account/fcm-v1/existing-service-account/04-upload-credential-complete.png)

0 comments on commit 6302597

Please sign in to comment.