Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1/1][docs] Add FCM V1 instructions to Google Service Account Key docs #146

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
75 changes: 73 additions & 2 deletions creating-google-service-account.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
# 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 +58,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)