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 e0d3854
Show file tree
Hide file tree
Showing 14 changed files with 70 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.
72 changes: 70 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,57 @@ 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 [Service Accounts page](https://console.cloud.google.com/iam-admin/serviceaccounts) in the Google Cloud Console.

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

2. Add the following role to the service account you wish to use for FCM V1 notifications: `Firebase Messaging API Admin`.

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

3. Specify the JSON key file corresponding to this service account for use in FCM V1 notifications. If you've already uploaded the JSON file for this service account to EAS (e.g. for Play Store Submissions), use the `Select Existing Key` option in EAS CLI or in the web UI at [expo.dev](https://expo.dev). If you haven't yet uploaded the JSON file for this service account, upload the JSON file for this service account to EAS and configure it for sending Android notifications.
- 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 e0d3854

Please sign in to comment.