Level up your Twilio API skills in TwilioQuest, an educational game for Mac, Windows, and Linux. Download Now


Rate this page:

Thanks for rating this page!

We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

Android プッシュ通知を設定する

このガイドでは、Twilio Notify用に構成されたAndroidのプッシュクレデンシャルを取得するために必要なすべての手順について説明しています。 最終的に、正しく構成されたAndroidアプリと、そのアプリへの通知の送信に使用できるTwilio Notifyプッシュクレデンシャルが得られます。 さぁ、はじめましょう!

Step 1 - Create a project on Firebase

Google has replaced Google Cloud Messaging (GCM) with Firebase Cloud Messaging (FCM). To use push notifications for your Android apps, you will need to create a project on the Firebase Console:

Create A Firebase Project

Step 2 - Create a Configuration File

The Firebase Cloud Messaging (FCM) library requires a file called google-services.json in your Android project's app directory to link your app with Firebase services. The Firebase console has an easy way to generate this file, but you could also use Android Studio's Firebase integration. We'll use the web based approach in this guide.

Firebaseプロジェクトを作成したら、あなたのAndroid AppにFirebaseを追加することができます:

Get Started With Firebase



Android Appのパッケージ名を入力したら、Appを追加ボタンをクリック知ることで生成されたgoogle-services.jsonファイルが自動的にダウンロードされます。

You will need to put that file into the app folder of your Android project, or Gradle won't be able to build your application after you add the Firebase libraries.

The next screen in the Firebase dialog will also explain where to put the file you just downloaded.

Step 3 - Set up your project's dependencies


We have already pre-configured the quickstart app so you can just skip ahead to creating a credential.

Android Studio uses Gradle to parse your credentials from the google-services.json file. Your app has 2 build.gradle files, a project-level one and an app-level one.

Add this line to your project-level build.gradle in the dependencies section:

compile "com.google.firebase:firebase-messaging:10.0.1"

Step 4 - Edit the Application Manifest


We have already pre-configured the quickstart app so you can just skip ahead to creating a credential.

開発中のAppをFirebase Cloud Messaging に完全に統合するには、2つのApp固有のAndroidサービスを作成し、それらをAndroidManifest.xmlファイルに追加することが必要です。 これらの各サービスの例については、クイックスタートAppを確認してください。

The first service to add is a messaging service that responds to Firebase messaging events. This service must extend com.google.firebase.messaging.FirebaseMessagingService from the Firebase Cloud Messaging library.

        <action android:name="com.google.firebase.MESSAGING_EVENT" />

Step 5 - Upload your API Key to Twilio

With our app configured to receive push notifications, we'll need to create a matching FCM Credential that our Notify Service can use. In Firebase the secret is called a Server Key, and you can find it in your Firebase console under your Project Settings and Cloud Messaging tab.

Notify Configuring Android Notifications - Firebase Server Key

Having that, you'll need to create a credential on the Add a Push Credential page on the Twilio Console:


From the drop down, choose FCM and paste in your server key as the FCM Secret.

Step 6 - Create a Notify Service

Twilio allows you to build multiple applications in a single account. To separate those applications you need to create Service instances that hold all the data and configuration for your application. On the Notify Services page of the Twilio Console, click the red plus button to create a new Notify Service:


After naming your Notify Service (for instance, with the same name as your app), you can configure the service to use one or more messaging credentials, such as the FCM Credential we created in Step 5:

Configure Notify Service

You're now configured for Firebase Cloud Messaging, ready to write some code and send some push notifications with Twilio. Visit the Android Quickstart guide for the next step!

Rate this page:


誰しもが一度は考える「コーディングって難しい」。そんな時は、お問い合わせフォームから質問してください。 または、Stack Overflow でTwilioタグのついた情報から欲しいものを探してみましょう。