Living life and Make it Better

life, learn, contribute

Endy Muhardin

Software Developer berdomisili di Jabodetabek, berkutat di lingkungan open source, terutama Java dan Linux.

Setup Firebase Cloud Messaging

Setup Firebase Cloud Messaging

Firebase Cloud Messaging (FCM) adalah solusi server push untuk aplikasi Android. Server push maksudnya adalah fitur yang kita gunakan apabila aplikasi server kita ingin mentrigger aplikasi mobile.

Google menyediakan fasilitas FCM yang bisa digunakan untuk aplikasi Android maupun iOS. Contoh skema penggunaannya dapat dilihat pada gambar berikut

[Skema Update Tagihan](https://lh3.googleusercontent.com/N4768qRMt0y9aA-21zJmXRUPc3YbF0SbAPLnOR0t0W6Xw293GxOTN9htFiyFRm6MjEGLVZqG-gKM5hXarme3nvU2MGPrtlERS2TNqARYCt1aBzm70KBtwp3DCpw5ZDqoRQcQoa_EsC-5RKGlVW4_hfUPxA71iFpQ_yFCTejep13-B64KOkO-ELbwQHSSOPa7viCy4u3OjxrBPWM1Uk1vWDd0HN310uQSGlpZDLK1_cnRPkSquHzz39pg1y1H59cwCzw5kV_Ob4G_XEiBL689kLbJIvnmXpMAddxX-eKJ8uHuRdDwxZTx79-RIDzgaHWXCwoWrYE7ARebw-n81djjjzzb5yjlpgEtLZuYJzVE22Kqvox-w7vT-DsQzDScGer4UR0PqoAeuwaByNaFydake90XyOS9Rg0jrD3qg_UX8XltBAjFBRd5I8jVyLL0iuzxGzzH5ETC5rYzI1XdGYFI0XXnVNz9VQPIbUCmyCBF-_BzNNBc0Vp4fbPKOCczaMZowjTIzS4WF5bhFjdTHHO1paBNmJh0yRdWJIhVSg9wqGItNKN7UbpAPuRbU6aasgbSJRrsuGaJ542PUeJdgTDC8JvAErp4NWrR8rznIgGpcSjR4tL6-4esarw9ZwkcQrJ-wApAEVAhprIjNVy5wHNMDBirgJPx57Q0NycTi08vpQ=w1361-h538-no)

Untuk bisa menggunakan FCM, ada beberapa langkah yang harus dilakukan:

  1. Login dengan Google account di browser
  2. Masuk ke Firebase Console
  3. Membuat project
  4. Menyambungkan project android kita ke project di Firebase Console
  5. Membuat kode program di aplikasi Android untuk mendapatkan FCM token. FCM Token ini adalah identifier untuk perangkat dimana aplikasi kita berjalan.
  6. Membuat kode program di aplikasi Android untuk menerima dan menangani message yang datang.
  7. Mencatat Server Key (yang nantinya akan digunakan untuk mengirim message)
  8. Membuat kode program di aplikasi server untuk mengirim message

Setup FCM di Aplikasi Android

Bila kita menggunakan Android Studio Versi 2.2 ke atas, langkah 1 - 4 sudah disediakan alat bantunya. Kita bisa akses di menu Tools > Firebase

[Menu Tools Firebase](https://lh3.googleusercontent.com/yUesvalbWIJcihQ3mLRxJBg20EhlWYxsZ_cVDibocaWJAPGEJzh70WmsCEnVj_nfCC8gZTW_w5Kjwq6Ou96lvThH-DhsQKTbtQkIQLuUkNHByNZigZFAjKYKu3sz4J2JSu0_sA6racdGe3SknNPyP5ppJXG4usPvSCrK9MCrjy4Mny3RIeayoNuWcBrq5uw6FD7YBK6rZrg4zX8CrwIss4BhO5vzMddsyeTkt2HUDE8QyUc2JfvIuyAkKPNEOB3hvpbv8PJXjKmKHUe0BqUm12dpDUUBYh1aViyMSFs56yn6wTnan8m47UiptK7UfSKV2Z5mUTGR54Ke_TFJYaTlm11DcJWmAn0nzN2P1YQ7ugL6yybzqdIbwQTIKg94UqAVTfrp6sJhMH5KQaDDNyMSEr_QpMbglTeH6wYXm7JS5au_WO6LtpN_ohnLQWGa4e_k_ozU3XBsaC5EfXf6sZoKjTDjTVj9D66Tf8SlMrGueOMgwzAnCBgNjYjd-7smLS0IMgb2ujboEKIxABBQmNBJMdW8nhP5c2W6ogDXppFDjhI8UfY2jtdY6hC77UNe9SyCKCV2NMQewUdYKoMyxKjTuvU6UjmU39jwATltehIWGqjsP4t_e8xQul_E2-LqxvueDu1-AEwck7sqCFnV2i0nm4Ayzf9kpcUdyH2AQaTkQQ=w1235-h694-no)

Begitu diklik, maka akan muncul Firebase Assistant. Selanjutnya kita buka menu Cloud Messaging.

[Cloud Messaging](https://lh3.googleusercontent.com/XKlOb6-mR0y0ZKUswKF0lq2fhge3_I9JbrOIKIhNW7Vj-H6HtEbQo0bvUUdBLah20XiHAXpY1olFvlFF_DNWNewvKp2L3_GFmoz5_WWKApJQZ1orx4nx5gK4z_v3jwIAWGEmwPT2fJ84StaAdaA7BxgEDdIpGzuXsh_IqzZN38vIgCgZnQBrfU1xz5oKsNjxt0NtsUl4qrgkMgEAwfKNHuIGmpLNhcw17FMCUJL9cJeYaUXzj03gQKpd3a9iaNzmruPOOJE7srTSvMrq4Ovl8e-VgqZ9DE8Pj2dNaFGkaJncOIaJI6-3MNeyQeNWbpILYDbpdYBZxBomYasTIVvyNX9ZgMdYhZdTrt15ooGuZc3NU1-xE-Naf6OVChYryYa26hltqfbJuMM6PcRRQ5cqDH1ZuzXEK-XAbPtpnV_ziDB3pDX5By-TGT4iqIYG7GW4nnkrlVlhXs0oLpOMPuUprpRMyAscU1nKuD9jN9coGLycyYYSFZ1uNmKD8WUACq3cS_dIje4SF30rFwQzgsaWWaoMsSPPMYKWOu3kEM0CMfgcXfSERilptU-9Zrnq6-_fDdyTbs9LdcxTnJLGbHvLnBW2a6coSDe9B9NaB0iDMbFSqQFnEzOZx9z_EcYJhZjMIUR8dS5vdzS3UPYTh4g5chzvzmfKK2KdWQjtmOPP-w=w1235-h694-no)

Kita akan mendapati langkah-langkah setupnya.

[Langkah-langkah setup](https://lh3.googleusercontent.com/ISZuQJSHxMmXOOcDnTdrz-RYODzt1SpsQ-8aT7r4bUXpuE-sn0yV51nQFzktr6R10sftZgtMtR9KBRPk_GsU1vN9DHtsdyTL2LiK-C94ZpSEv1EtsxzXm47LYHQ5WnQEbR_kHagFPZFskzjwSINY3K8oP817JRRP3DPFNvG9QGFBgjmAoEGW64rgU9U6nBnJwJGEDNMk56FWDTz7xSb8V0mxtSs5h6omvbHSCOAqk4SF1g7-0RZYkKQlJ9_RLA6t-uq5uEylJRuoo8rSAVD4-sntfRhVhCAqckCL8MvKpA2VeAZPGMbJ0iLZwNWspHQbAzF-7yba5P8hKHOFNpzgJjfuR9Tjp4rQgvs4uVk5McDoClyXqNHJWJulx5u0RJQlxxGk6uRrBHlh22mrfuSlS-GSc3TqXMQ3Es4X7dwd40KtR8HAJExIE-9OBMY29i6WQCbjV90vF-vFN4YN6IvKIJ_4hHc_uWRbm_90IpmSq7aPjKekKCdCjIQ50W1Y3n0zBhAOBcbQGcYYAQiA7NFQ_Ej9y-VL-Tdv4IEPeK80k48_BLtz8xwNUXsAHcWOb3CsGlu0gvGtGuiiE-kuVwq573lxyD_ODQvv0lmtgQyLO8B6qQO9xCGpDBQkVlU_4coxmqzBRQgeTmGzTBNS5vSSHsMHIiGgb8D0OfBbevOMNg=w1235-h694-no)

Mulai dari langkah pertama, klik Connect your app to firebase. Browser akan dibukakan untuk kita dan kita disuruh login dengan Google Account. Apabila kita punya beberapa Google account, maka kita akan disuruh memilih akun mana yang ingin digunakan.

[Pilih akun google](https://lh3.googleusercontent.com/_9KN62cj4OX8E6MbNma7_38RCEpPfPw3f9fa2e-F0I9e6PsVljuVLxIJ3dOU501IYNb8GtPTxHkhH4r0ey8_CeWZ8XyM7sl8XbAL3AN7AycJLeKmjJ1wRtP1MD6rmwGXXI_tTyPH90OUddFIujh-t7ePaoaMzZ5ABiDNCRF0kX2qb5JevWzKTk45hmYVhz-5m21HBmUsQHQ70Tj81uImCmDfdZxm2UX4C_BvGJe9NNE91VgOX6eCqWhx6mVQDY6XDky7AAz5qjU7tzLraTYowYR3_74qcql4_O1D9ZOXRaxlov4vI01l69Mp2ZVAMMQfWE-ckhPLkmHRwv8FAAXrJlGH7G-WFv8_cF8UIbiwTqDBSHIUZ0gah82FVRHajoLT0POfhptWqrr9fm9zcH6eZLNh2xDl0228qlAcrI2T4FyJdZGek9g-j-ppsSyActOFlSYBjDLN3EV7VA2iV4mBvUoNAQgJCl-z04NiuvwypToDrB9KI5LvJaN5aZviCYHBelnu3QsoWfZRfpwhzes6DszI_3ytkAY4ZK5TIeL5yXX0eGTkQjMWC8KhDU1iT5-Sy1pZI4C6ooFScZD_anoZ8339JldMKjejvZI-b9RWtYdJL3vR14PQ6M4l85p-8kSStDDu5QJNmbglExomItjJFNCZIeDb9jSwszbAEUE8RA=w518-h416-no)

Setelah kita pilih, maka akan ada konfirmasi ijin akses buat Android Studio. Klik saja Accept.

[Konfirmasi Ijin Akses](https://lh3.googleusercontent.com/h_RqmqbOLX-8Ar8lVRg71iJJ-1AC2HNVObLonu8Tbhl_2khalRSY9jdcFCu1ytewRV-Tw0dfSL1fj49Y7JCxC8HXDMrlR4NFvwwZEVlhUhpXPlX-6YmTzmZULtg82NxLKZ36PmYqK2918bpGkfCgPeBGUOYXd_bZf3hNmSDIuYubjcKqLYQJ_w58MWP97rgJRcBbyJfY6zx49ieYJxo3bBsMQaDTZl3ugcpZyx-al3O99an-_zJ-c0KJTRMuxYiscF4StJEEAK1-vdCO2qOp2mDIBWJO5H-jcUdnHYrD5-eYJH88AxluWAnU7I2ei2ncrAg0gkCQHe7kC-L4khH6-6CTUJn_h8HoakhcMzxleQYiz8QSO4GTffsh5CfQQoC1cuYTLaaV2RI-7iF3sk4HydQYt6FGO1Yzae3R2kjQRUNR4aUBYAZgseko-XeVHX-1fny85D00Gd2MpHxSqdTdtakfu1ScVcqvT8MmOGs0UlgZ1u27MambOHXRS6F3IiqAJ9Urbr4YWAs2YZlkvXXBXdjF7UxTHOtacwb7WeKhlXS9XAg8tvrf61OyMDt1wZSo-7k0CEKylhwv8Rvv3l2y__z8CMI-1d2jvNXEO32c9YG7Y7GKQFhKOXceCotNSKliyK-RmJ4g4Lo2j3ALrmKn1EqB2rjG0lmfx-y1J5UVyw=w517-h659-no)

Kita akan mendapatkan pesan sukses.

[Sukses otentikasi Android Studio](https://lh3.googleusercontent.com/-NrACPupyRz_Le1T9alCPe61RmYdVnKhNDG_GWcGkW8f4qQlF1iy3cPRA2gglTSTqaOJg7uXDVzCcZdo9uAauSKvUEY1RCWEoJxvuBke_aSAEliftQmn8m32IMRv_D3g0-8S5bK4AqdKb-lk_nJ5tcA2VkSR3vTl-CEJMONX0r0xw2tvjmxWTY0i_A-BdpfQp5-73Ud_aunZ1qtMNI73taAcFmfBX3YYqYICpdlgzA3vGzuj5iXVPLh09ASrjqAPX9uDfQxnAixfsSZlYU2bZieo45DjeW_csNlMJIwred0ZY3vjhhT_Iudx4G0DAQMw3wN1rl3F4zo-XIi3vRMM8SjazqeQocwO78UKvhNCzyHkPkkXE-97GwO9cLrxUXcFlq0Zp5UAgUX9OY3kHtPNDX9dRdHZ0G_tUevNpGNu4CZE_svyiahUXU_gNUz3iLTVIZyglZumgHYYCnO9xLI8Fc0JTgiFJm5u-QwAqSk8T4OlAN-WreVPpSQO7LehZUWE2PhATdaGt8F-L0-aGtmzMlQSpEdjE9DIcnthyrOAsLQR_lZA1oma2M2jLre7vfCrgh1hJUrlOQkY3brqtXEYGN13eyS1jBRORaHV0A8_K2OpoEIGDcygOh3KTjNku8Au2U0NOG6ieW9QkZTTTg_bJRemDZWXfBzhek9rcWwP_g=w582-h424-no)

Berikutnya, kita akan disajikan pilihan apakah akan membuat project Firebase yang baru, atau menggunakan project yang sudah ada.

[Membuat project Firebase](https://lh3.googleusercontent.com/oarRaDebeCqbMWQwFAwXnSk-XtGcTuUdkR43GNbN93ZHmKWz2G4f6zbykop632mJaVD7Fp9E5d5govfso_UX7hipxgo-GYMoXrllVdp1PrxHU2zvX-PWXoT4rx_AvS6sOaQUIocxfA4qAkExapQQ7epXtk7aqS5nQzEf2S3IZeoE52DJ-rnY3hObpm0aoq9-S7c-BKRb67FiUxT8ShGFw822MawDPZ4jWArvqvbcgR1yVO00d9e7osEJ8a5NF9e0KA0bSMkwau3rp4sUjBTUNXTN3-wCaV4IFpq7zRzsPCc2m0RxmwhKsQNFTVs7lqAnsW9T3qio0sJZR1KJLTh_VJia6I6OzVLXnPKGWrTmJjn0phGRg7ytmd3BVV1jhj4hhUnrevTDrEMAAvottb5YMXCoRgbTrsK6w-Tq3-VoaVlp2ULSlPME_NJv6vOzpm6sQ8fcS1xSxsXnMI7B4ryp6FQhJluokXaNgP6zorJsqQdQeCgkAVmyKFIbvqIoZs0QKJKVxHvIf15bYnv_D9ro-iLdtfIhE4QX4Ctc_xow7KS2orMRmu041Tw5PvkZ2vwwZXmbjmFPWEG-OvHImAKMIN80TjSg5qFvrXEvnnpJrL0Bfq66MQ__sNYcr-JY0agI-_ZxUwYHDzkRtSr4TEXW5Lq1BQqBrwyvjAchmqNNEg=w1235-h694-no)

Dalam hal ini saya memilih membuat project baru. Nama project sudah diusulkan oleh Android Studio, yaitu disamakan dengan nama project android kita. Begitu kita klik OK, maka Android Studio akan berusaha membuat project di Firebase. Aktivitasnya bisa kita pantau di Event Log

[Event Log Create Project](https://lh3.googleusercontent.com/wPWxkeaCdrk-f6bh_anysiEEnYYFHsTb8345MuXOjkWt-lUOElugxP8HEH6T3CWh-L-h3lMUErvUGOCQVB13Ftr4K64J3xHKDSPqbkiWZRJvOEjpkwDD8rIqWZJwmplYAr3Oa26tfB5iH4EM3ABDx4wKSs1jp-kAAEc0AKwRcZyvNsVzDzB8yMg7LjinDPpc2fDsmUtjgIE_a4r3-H8wPzjdgOEsiO72sHIv7uknFxT_MhYUaGBzstZWsRG6Atujl7xV-BsKKTkZaJvDcKq8dFasyobv2rxA-ebzMxuBTeMA69X83a7bNajtardtkD7IizJN_vcrs2rsFRXx5Tm5t32XqmEr1VcSHH7Npd8qjCHeDxXbKP_ZpGidZrjp6qnxksTvlRGLBz3pxgCtvkuop4l8n3swF4ILpSuiSZNc7xBFE3umNPN72smCrfAcoCqElVX-uTqevRgcYf9cEz61zRroC3ZHB5aKOImREu0DZHncf4n3BfP5XrcXQWATR2gmYDAqLUMMcOk1_ZwAYMdkWrrQ4TLTBgwK5qwC2ZaGiwerb1Zx9nqmIFkfZwjh-uL-tm1XE5FqSsuZTOEkUIA4XG0wrXE7U2kUWf7P7Tye-_P-y_iP20NolK0BxJX7f1ddDRAGEO3guZd3sGbxDI0nMRqfQPoXKIrFUcQ8aMOaGA=w651-h461-no)

Proses ini akan menghasilkan file google-services.json dalam folder project Android kita.

[File JSON Google Services](https://lh3.googleusercontent.com/4r2BUbCkJQVkUngzrSnHUY_31WigM_D2jk5CYWM9Ni_VwUAZ1DzyYFs_Fevg1fOx9n2j5-i-Qtqm3Mg5J-wO-r9jng4eqoYm45-0sT3gRKtVA1K-DgSTG_r2N0oxC9BOuoV_KOQcmCn98LRjPH3IMFMjptrWRrHE5zS06mOht3EwiwZicNxTMXZD3rIShxCLF2MK-RK0gSImkLMM8Lh2XaxPcT-1IZPXpqz9pt77G5pJt-0T4jou0tuAouPDHB-l9YryC1iJJFaEXFKSzblw2ATQ22mLDmk0JNVirvZQulkTDgWsgImckaMdZoLKdN3ZKyAmb6W5m6tqXmiJglwA8R-gFCLijchw-Ygv8Xh3a6B-bIK-dPxEs1Fl2_BH-uvmkDpU9yGr8dzP2sYcGoHjz6zbCJ72pxtW3ORpSQrwPDuVXu_W4oFIBZoyLtVAXyB0v_1tngZeYNDyf4pJR5YsaTyTYRf3pxJqvmBxT2pr3x0FjgrcH7Ls1ez7ciyp-jgWbx4gTYwYOHY5mssyJqKJskHSk8POcLC91qi9TYrInmWm9hh26cFN93u7DoTZe474Ba5DNyLi0tjbnK3fwMY1hMe4_2VROnQiZIJ1MClcyJyTLoYVFKWYlTYUoyo_cWbh3rWogZPlxh7VREb14j6xPVEtaC6u-1iixfp9PFwUqQ=w698-h180-no)

File ini berisi konfigurasi dan otentikasi agar aplikasi android kita bisa terhubung dengan Firebase. Setelah selesai, maka langkah pertama akan dinyatakan sukses, ditandai dengan icon berwarna hijau.

[Sukses connect app](https://lh3.googleusercontent.com/Vy09kI0rxkgdBkSuwfNTLAmLKCMAMZkVQHnYTHibVX5lNcORU0p1R8-o9N67MBquGp1R6WUVVoXNx3LsWlhKw75zNp-RbU_swZathacukUNJalBkixN_tT9wYcRt-CT8J8xgrpc0SSSO4bNA5t8P9mHeXXfRlQCrwLIhPwnjPV-zRB-cyfWtf4mRLJ32FKEYafelQkUfj92_8uZeFHV8DTaUmRM5LsjOrng_dJZ5-cBALLP1SLpGxv39uVXqn_vWJt6nr3iNWcgaun0weovcuINWi8GNU1oQklfzaEPaE1iZt2P5WAVmwcouv7KUjPohVMG2RYmYv1itmm2FfTICoTyregIVsQffkfHYE8I7LjJl9JSwUbFzpYWNuD13KKhlJc-1p7GLnynV70Y_bFxcs6_h3-MRPw7lpeaIL2fyXimx7Se68CMnk04XG3gtgL0EqGdixS9srsYGZSLn2wWZwaXsFmf1qhPYYlM5X5kr6759KsWj1WAcOLdM_KBeOSGDlc9cFVENR3AgDsA6VG85rXMA9QrIOt97N4eSJHKz-hua6ofG8c0pvihIAPIiBwoPyxu5Eq_A__Y9KM9uBXviuGjs9Fg3ImnxmVMDZIZPPeXJ4sqVbROY2QJS5Poh0yyBL13Q187eYtjwdlBYD5sprlLdHa_ARNEdf7wlFhkhlg=w435-h652-no)

Berikutnya, langkah kedua, kita akan menambahkan library yang dibutuhkan oleh Google services ke dalam project Android kita.

[Menambahkan dependensi](https://lh3.googleusercontent.com/iTjKPs3YlQ2Lvm4RNQcUao8iVSX0Ut8r1FrRzkivdbW4sG-0596M_stmpQyJts6z8cGFxeYrOmVkreREP4v_8l3GhgsKTokxi_wGXgf5DlQ8rQISydLDkSyN-oG2xiwPcCZebqIqL2b5jFl3pCvjlIkek56_ggKeux78sG2Ok8QrLzkwbSdX9gXQuY1Xvh9y74a70bQpP1562sy3mlW3LES5-d4z4N6UFNJ0_U04xKtDi-GNHEGfUGmoY4Y0iTm8tH8sRb6CPx0rcsX3OXXM7i8pX75uSDp_iUZD1oc0K3iY7iE_eJc4nZVBBHctcO_AB0fv7-8LtMw-ZSIQXGD00ceWXZZ2FDo2YE30cAT1jxWW-FhOFqy2pVfUy8MfrhRauKfbcUAOG9sVNxYjo-fYFvotm62mFYuqMkA12ArXHoMVvKdJmh5hVIH6GhUkTmsASoCbF-JeTQjo1oEGOXI6YU8ymqnmkyd2dcxEBYtvGz9IvgjNvNej31xW9eTJ7XCPFHJP9tg-3QoE5hKIM6V-vAl-PRKozPEH8P-oMHHexjHQGBwqjDSSOyvNz9Jr0PSsz7iz8JqujbFx4EaR7F6ortNt8l1dDNWm_VSwKtrWreMKsC75kjD9evnMgRsH1xznDZFGL3aCbBz4QqwQ9IXaC7jxQ_5zbexmYmMoQlZnYw=w1235-h694-no)

Setelah kita OK, maka file build.gradle kita akan diedit oleh Android Studio.

[Perubahan file gradle](https://lh3.googleusercontent.com/KPzm_G06jNCblKxJiC_MlCXBvL5unG7ssDJ4O3P8ox9ZMklUPD2r8CXMPZsQwWUdQviiiCzZCiqCbtinEMvRdBFoJej8EZkV1jQIpHHmKgPCtCn5mXqPyVtq59WT94d95UxgIZk2loBDBYba9qaWa7qy1fgSrk50vznS10hyljuZBiVDzmACiaV2uDP-gjjxeu6ORh3D7YL5dskLkCEPZ1clgJv0nwtzsv6uUsj78CVAWUZsZ4SbVCBtegPFf5dfTVqQ5-b77dFM8GKEG43pmGRTW6B6uqzPT2VvVtpk3huHATt43lvO1c9zYwqll9km1RSrdg0uZvnVWPSCyHzG_0xjgr0MAAEARdtKiHhrmzZw_fJs7_KhbEvQHQlk0HszUCY6uyWf8hSZLYLmenPFn9EQse7prkaMGcNBqABglJV5WtUpzQF_6Vy3zDizoCtR5PLCezB29zXX6tS-1Em5oBMEH5THsOCtgxf5zc8vGka_JuG4YOnCoLxAqWuI1NxebLPZsamfpEYXUFlPGuVtUZAm1A5QsmnZBPyvb-FcUe7pUYgJUE7LUIHJwEVyzGIF1MzVM5KWmKkcShTz0Q1yEah5wlgpIRiTjFZ2cJdQrTbhgpw8HSZia0ILJzoYERdQgJ6Fa1oxzCC3C-LfDf6ZMX3ZDph6riwjBhakQ6o0sA=w688-h297-no)

Langkah kedua selesai, ditandai dengan icon hijau di nomer dua.

[Sukses setup project](https://lh3.googleusercontent.com/aL2gX3wmAucA1kaS2SsjksMEBx03rBqVa9xe8QEBf0pFZ4AVeYjud36UPFNkuyvEfcQxBpry1vTBSDbaMGiAutmPagbsAMW1Zu1YsCEUy7zxg-L36i0Guv_liAaLwq4BnF08WxI7XQsCJEhgCrHRVIVJB48jyetNetYVi9y-lSXICaOG3ww8G8DIhxsmijKo5cMehGbnSQUWcJ-MuzmZCbnQYvKxz_P96yc0kPzEOnf0e3uqLvWpAqhJF0TuE4j_LVV22BOGD8paL4mvXTUCofJIlYUFCxEAOz_OmUWzb4ts6N5ks1YFMq-KZHCcDi_tyCHHRKUoyg8zfe1jWcVGV7ykihYV_NvhvdMluGB3SS5_z2Pgbs1LIgqF7CyU1i0xkW0QFa846aiEBdwbkOvEzfkV_PA65IFsTLMhuP25xI2kDfqIBerl1rjOfmYkLBK0xTM2AS-vtVU2QnXwy3TrzMC0rkTMrrbEoY-GiAxufExIzx82JgWSW0eEZTvD6CvF6TKn-4CMF5TmZkHbM8I5XHmUsi2uzv6sO0GpSFTUT463FKahYa-StILltaU5UaXJBBLrhOTfxET4KdXyh3m5_arvYwbNL0bgeCVuVm1g9HlCSeDwWGGGaKDx3Rx1z88JaiZrlC7dKjCR4GI3bV-cbHODwrdw1oeEixU5OfneHw=w1235-h694-no)

Selanjutnya, kita perlu membuat kode program untuk menangani proses registrasi. Cara membuatnya sudah dijelaskan oleh Firebase Assistant. Tinggal kita ikut saja.

[Service Class Registrasi Token](https://lh3.googleusercontent.com/qyc9k1vOtuwuUfBm3KfU3KtppUSUhix2NDPRpqsHpwFkLvCeMP1topTaIzZyA5tNZz6UdXm4nObncEww_qVfFgQSffGHnyCCKkPCfCqIAe_MqBdxZ00yawMcFkBbKHFavSc-caoRs-jdpYnAFdlD5sPUhTdEPZbVhMqKx9tr28lJwo69wzB0Qsebdw6Ssulk4FSG4KjFlN4zcejkS5oLOzk71Izaef0zdjhi4StsYBVJa1WBIb-gEhxZJfPXq-7HCtamX8uPgfXA34_BxHbSWCsekzm4HAKcZMMQxJfMKDBDe3PtzFFbMaAJKq-yxv_zOR90oPeIVSZRAdwLqfxx8bYLPn0bGsJA62XupF61YbUFX8jFd_wFmLs_8B2NIpCxVUZLU6Dbt__BNJ_CziH_SzF_DFhX1oCgp_bjCdVPz-1LaswHXPPtlP1SZDrffTZU6KehFRQAGcaOSoGsO6pNWZI8xcSBauUG4tvsR3eVTRf_q0Tuu5BTVnLeggS4KzCS9c5oi779tlK9GGXj0bf741YjjyVcFPDV3Ivkhp9oK8F1j8GpTXdZRKM_gwvVSTypLynAIf_lN6aOEVJfw6meX-uVlDHmMHAqDa0V8WIdgTxRXsauriOFQFH3eq6ELi3tulYf2x2S_N9evq9-O_ORSOcQmYwKsqxZNlhS-iMhiA=w1235-h694-no)

Class di atas akan melakukan registrasi aplikasi kita ke FCM dan mendapatkan token. Token ini harus kita daftarkan ke aplikasi server kita, agar kita bisa mengirim data ke user tertentu. Nantinya kita kirim token berpasangan dengan user id, agar bisa diidentifikasi device mana milik user mana.

Class tadi juga harus didaftarkan ke AndroidManifest.xml

[RegistrasiService di Manifest](https://lh3.googleusercontent.com/oceBbxDZ6pjMbYb7FLUF3WlT59nvyJ_5HsKxw5Q7Wv8ew4gpcCCu3QYL0IRoS96zZ7NZ8TKEoRPezGLCiHV-yMtlWqXDOHcoA9kk3Ceobrom0L83WAzXWSp6Z5yepos9pW4xHCj8CVvnJee5V1V7u2bIwxJ0ImfvDr6SSJCIsWbudrJTqgJcW-gOBUm90n2LGeXv6xynJJo20Yo_oaHyWFWVDWpBE5wfyX8ktAOOT_Mr6VG4CgXBZ5J_88tuTQT4aak1Duqjy0wtctz5wLXofN5aQlSTVXLXcw_Kp9afyEwvbQ4F6rzHYhvMIwssJJBhcSoAIyhrK6IWEKGzYDDLtvXx-jJKH-S14gbd61AZJMlSqRuJy6LfoppnRjwPIBmJ27j9AZqSaJpgAd0YJgfbGCma59nH6_t2vU-z8n1iymzmgSvBr6JZf9fbz_FbK4l_zT7eTzSsRPML8JA5v5ICrv1sPN4tJWxPLrI0ejrqAO4zj1FcvJzjv4lLVWoiaD9qMnQfqbDQmWeUHJvVtWd193_biaivw1Uwzebwi25G_YKcou7zp7QX1_do_M-6W32vGyxQHnT_0gbUY9LkNqLl6BKWu5wcI-n7o8rWyRgvjF-ygQj3wyweAFFbUKLBWHnAE_iBG4QFiiCdKWI_wYMHUKXHEJcu9gGL_fNU-TsTZw=w1235-h694-no)

Langkah terakhir di sisi Android adalah membuat service untuk menerima FCM message. Cara membuatnya juga sudah ditunjukkan oleh Firebase Assistant. Tinggal kita ikuti saja.

[Service Terima Message](https://lh3.googleusercontent.com/cGc1QA_KUsIufiebCNPk36wKwb1LoBINkOAhmxd93Q5sTD-6NYGu2kEDi2vMT0_FJ8cvON14RO9niBylEvJqPonjXfn7GE5ww8IARot-CzVPzvlYCHWWiR1yGzZuZYj1EGLWZGccZJv5yNvqwlwXq04Y-pzpUR0RrhKkF4XBqznVmKD7FITrMqMPNzOfv9jvW5MAjQgDSP-l4blunCcBYskfzeK_jxiepciLtYM7y_pfW-cXq7LXa8zo6JQvOOgst0flLrqomPgX-UXsKr9Gr1PKUFRqP15xizFx7M75mYzvI6SSlQqseHao2YKu8vdsCc6fv4335aqvGYxCxzcsDo5mdPupDnivMTcRY-cxzbea7A92k-wIXnANrxwCbMdXEus33d1MosHhdOpkt3S5cqbFbSVPX_SVENVpf10-qY6jUX5fcH8B2lOWOGFfinwZS4i3a5aNK-JFxDf35lBT6qw7MbBZq_LPMWnD6w2EqNDTE-QIDGLRTVKu6UpJT15mhUXMIhG8sIZ4zW9vW0bOWCudcxMpRAqEGed73JnyVAYa0ommGTwFviGtXdE5gCks063KPQ7L0JtWU6DN9NKlTimoWoajAPxELa1CZ7mQoMvaoO4J_7nZuML7xnEca9KC9GreXgFQ2kY5sdOwTyry_5yOycLM1wabvzG-ykZwZA=w1235-h694-no)

Sama seperti sebelumnya, service inipun harus kita daftarkan ke AndroidManifest.xml.

[Manifest Terima Message](https://lh3.googleusercontent.com/91nA60smokYVxgnMh-m_Jm2t1WfWa088HQAOnE-mThAe9PymwR2N6HxQI1sJz2_qqLuy_wTd5I-8xzRhKlnkZ1rHaoSgtLw__Bc_x3iTSBbhBbJGu9PKthmulXGqfznYiOw-w4xzaxxCMJ_wMZM4kSRD2RWYXkyu15ntwBKS8WVqmAJApFKu1NiwfFBLZ-WpheAmZxCP2V_qmM-pxfPTySCThJfYVAK3Bk2-pveorfeBg0YgHRl0tadJmatE2y1AynC2jcnzL1OcU7VrRBSfTMkSSKUyutDWJkEWfbHET89mCsVZNW2E-7rgppcRmgVH2ug0UR_0UNC6EyWGw2kM1FEKzYyjLkM04oC40I_Ofqr9pMmREImurDcdi5lTUvS7k-Mne4VqKGL-y5bMnDmgWiRhYGJfG1OphGIT6z39CZv9mcpFp1k941z5P_C1IwYBJ6CxHhBoQyq3Y4clwwOaJUBVXLWOIekw8t_vCMbfNRZlYOcH_5zqicXN2nHa6sBSqh_gfDBSGUTJhRBvda1N_iuVEIeMbn9kAdf0vaCI9ZlinWnOIDlK5dQblOPc5lgYtGFwQLIOFeUWSsbr-eaHRcA35zQGq5uGGba3ZVeEAJZ3fv3Q7PejvQBPY9fmUHVfF1wkpJYer7DIfjvfDIDER0N5u7MzcHpfNSrBlMf65w=w1235-h694-no)

Setup di Aplikasi Server

Untuk bisa mengirim message, kita harus memiliki API Key server. Masuk ke Firebase Console.

[Firebase Console](https://lh3.googleusercontent.com/IJo3Pt4uBKKUCQS5E_uQBEqU7LQ5Z3QTryBAtM1ZU522fhHR_H1XkkaygUedN4UXo6S2xeWITd10Wz_OX0oS8TXn7xTZvIammlM8Az3PdSbIDms6Vg0j_9mNtzTPHNhz_RNbNRmpVHy22aeRNMO6HEfmaf2UKUhS4wrI-lXqhVbX2evF_OgzN2XMBBQQvfarQwtklbtMiubuJuL1Szjm22boKzMagXmR_YwYeSh6h-4Weu7jkElV3VcPyUF-o06BOU99jW8EF5jbm9CHd2tWRay0HY5q1_A2V5a-x-_TGNVmy1pjf7dB23v80a2BHWT5NoUnwDVOOyQAA8sOqzGKsE5Dxuc-Bxb_ITZlvxVRfTsFVbw7rbA_MJ9ZTtq3FlbdJfyjtRwnwjZbfXjVfkaVPjpkcw0PEhKEM5gANmpO0zdmIQ_2WKWBMTyDiW15SQo8NH_JTDg8EYFo6o8RQrj33OloCPis_qjeMfZmzcoPNe-gbACFH-029hzPUBXrmDAjsOJAzeBM_QKaBxfAuMnbdKBIykgLmivVZSI4tmXceQD238nJYxBM01d6FZZOOzOlZ-WxUPtrk56ojxjDW7EI9HVCugUJIaRM5N7rmsEzry8xaVQnLeS8UY7EGQS05yDQm5QGi3Y0WzCZDLC6TWD9n0Mvq_KfSKHmyy_MPJhdYg=w1235-h694-no)

Kita akan melihat bahwa project kita sudah terbentuk. Klik project tersebut.

[Detail Project](https://lh3.googleusercontent.com/VlRFWy5BGdWJme0hq-R7gVZEj_24_2Pi7t_Cfwq5jpiRxwJiVUVVxtt0840S32hLkiwgUAQziUdovrZS6oB_4um2fxmg7gkzmk5xVCU1_MH2xjBgzQKjUPX3KvH741P4lBQSviT0O1-tV_8QG2dr-5HFhROjsmEZ0izbDJR8sB7WOmqa4f8eQ_kZpNyX0UNvXsW5qPuDZXBbhJOA6AaZ1yhLTRKkxwsrxfyyfL7Jbnecdd_ZJWvbNhoZNzfQEkEclWxzb4bOoNNwPRL3MxZ5ztDmo_aNjKkVPFa-4XAKbocfSvRpV0sJVpqCYK5tdi8XFlMHRPLubIj78-sba7vOSSKM8FOMOjzfTDzcALXRugqHjWd_4V5Z1L7cuSsoyN114sAZPLlNvFK4E6bg907cPN7B2MNyveeKb55CPw1j-XoBnnbqRKxTtor9XYl9CPDivMfg9XLXtZMjQJCIdttoALbXTCTXBWfPvCkRxDau1mGDm9SRuwLGIDy-qzZNXC8XVGGu8Hu_7YT_YQOCRLBSpQz0CsjTr_z_ZvmuuVYJpxseFcijnXyGpCpp6rUaXfunaZtt1Ay5P8XOgaBfiEBuzMTwc9UyteQPGnzbXBrw8L3IKUjumLmpGW_Qen0jSZ1vdQeOTzTqxGR0PXReUlgf4xmFIs2y4VN2mjo5Mcwsrw=w1235-h694-no)

Untuk melihat API key, klik tombol roda gigi, kemudian klik Project Settings.

[Tombol Project Settings](https://lh3.googleusercontent.com/HD7FnccBrGbzyaGjhDvv8rBqdwCZ22vydEB6UhWcJcos_1gPdUhLp1pdVUEFHj7fDMp98Fk-PoIz8Uf5kyhXK3etaNex0Gk6i9iLOdLI5eJ7U1Tbl2i2kLxC7hcCUU1avLbMWmmTCp0KIHenEbmoXR7qVCbxZUJQ4cjjPy2dWfFlWRR-c-scE6LE85-3l77EFRVm378O2Xw3OWbOtax62LHIPT3Bx8hltwtz2enL2BihkholYGgFy7s2ZKV-a6I4RZEXGI3ugGwMTHXPyYG8QvEo9NUty4hn0Zo8M_SxXnaZvOkphlCgao4_933Mp4xB4Hth7YV-o5gP2BjxdrPPECvnZKrEVm97_cqkEOdmeYgZIsx9p7TzjFfUXKesQWmhUa2VtlGhKGUJ_enDywUe-Xkb9H70DorJgairuoe398DsdLL7zGUqzXSBzggNKUtkU1Lt-OnxWoYTHc4g_3ddfSyxb9tCcFggGozq3mGgNUjZKYEB9AZu6jpBEL_o6lb4lfEp2woVefuYTHkZwWtceEY3SGp5IoujlMZrbU08LWkbWGGmGOBCyF6bIr06DOwtanROK8SsqQnWTqKqU_tUOCYcUBJnoeVb3eAFQdHjBDcPOT7O6OjOLI0to1cUNURAR_1OMEKLLgI0JTG_6ZTONaT5erqR6kV_uRuWsutz1g=w1235-h694-no)

Kita akan mendapati layar setting project. Klik tab Cloud Messaging

[Layar Project Setting](https://lh3.googleusercontent.com/gKkZqHnRFXo2nQ88yUCSwQkAnMIuV9RasRu7vSyg76zPpqFnyGmV5VCeZq2f-dISRRo7_qnXPDEKgCoqTbXOowOYdfcn34lNg930QOo-MV2tD7eEdAfFJ0BNDunAyHibffGPuw=w1235-h694-no)

Nah, kita bisa mengcopy server key yang tampil di layar.

[Server API Key](https://lh3.googleusercontent.com/HnMitW-wJurD6KPtrzjMw4S44OPLB0k6aUBJZLy6IzVHXwCmXJ3vCYjB6uEtgROjjRNMRTaJiWO8e9rpzLwuFtaAB8P3MImPCE36k1bcFt2oMUSCMjmrgWQ6k5Y-cvJHg1fVYsH2M3_oSPVQPkzhE0YP3pK4XHDNwW0f_mv4evjoeAsyH5CTddDjndX-g0Jm57g8qnsi9cyvpfoI3vm8zLa5EpcOdja2U7GH4x2R7Z5HXZER1eD-lX4oAnArcyQ5uklgzsxndey-8IXwJpgfI9yxPiGes-0ZZDrkl0V23ny_5fhH2lY6VNRp2YjO_9HqwZZ4PKjSxyKoG45kdz4YgMi9ZSKWsiCKAhPPfgi2I-X_v2mK4nDKYuxHnPa0wrIPy0Ob0-yn8sHQ5juTceHVuA0l106lYQhNlMj7EsHrntJ6pRl1OmKZDVtBNUao0FYMpSwPtaNLPonTLgAJ8rm6uRCZJIeZCbK3l6dRzr8cV7BYOEuhIqsYiA7grysVJ1SUYYu2m_2AvlZ-AFVuSlwsD7UPW5Iu3Osdq_pTb-FMRORp0U0IzAC1WVzzWD9Xl5RCdy5-PIfmtvqyGebASNzElM-5pFfvYonsXylf4qq70pU9rgavVfdtRfDea9ukJLQ5I9GpW7ukJcH4KnxttC8ls7DuUNj5tW3XHzRLW9xLFg=w1235-h694-no)

Mengirim Message

Untuk mengirim message, kita bisa gunakan aplikasi yang bisa mengirim HTTP Request. Saya biasanya menggunakan Rest Console.

Pertama, kita isikan target URLnya.

[Target URL](https://lh3.googleusercontent.com/GJha2lhG947GZqhvxOi4WNs5RyEA7_BZcFkvK2fPTH4jaJGcseNt3-qYM-ieKs4c-f8aYzhiVuKf4-I-Q2ldyl5A3POjHtspct0Ct_7QntwOHwM3nPpQKQXv2QXb2FIpr3kz3KIuHcdN27f3neL9dNb4_D_0KQAFykYHXjS6N0Cc5pd-KAngQ-WOQgEOfcSjOUI_mj0rZmJTVzFSQYtjL2aj2cwbkxhUm3fSEvPpfgzHEfgo5fqqhLd7xefclDiXyDkI2VB8VPZCq2ak0HE_sRLf644Lm4NsbOmiXoHKLRsEmpJMfmW7Nst9SHE937gBwBioYDIVASeN41sQm-SjUp0rkmVIQpEVunb4TJT9MiN-_4NuMHfNVWX3tZpCSj5OH0anG6sUetDdjpsJuk3AgPCvHqza2HPvBHVF3IwdjPvT0exW2OLTXvB2DzyQrB5YXWNcnIkay5uQszceJ6fQ8P_VMXMkePkf8GlitV9E64UsJDE-jpzvi_zNmlBKFQ6GCOll92AlzuU0LBxcaD_zvrfxShrGnoU5FqhEWnXtqiHryZnuZ1Xsb_QbePDFKgxYFgIqMvxQOoo8yPCdwv3-BHpIg98puWQmnX7zihqHWMzoBtncCOnA6pT3gp0zQIALHC4h5YEoXSSr12eVkwye8bVpx3eZwDHyi2d-9EWOBA=w996-h398-no)

Kemudian, kita isi body request

[Body Request](https://lh3.googleusercontent.com/Ikyx_ricUYJ4jK_F-GVzG8TbjSM8SuT0xuBvCraiWDfb9EFku0zVTs7tZjD0uregRsC5n8DaDQB_uIMh9iQ6LwPuw32cQ8u5KFQbuvzpbrMD3WmrEfDmPSI0XqqMx7jf8n99kT3XGeeKRf3NUrppXwZ65T8NQ16py5CwxDS3dUBugyU7MLVgT0eSh5dhpWk5k-aRZjb9HMZxe6c1I5L6q5cfu4OiNJWXed_YgMD-jt0ZGmpr6-NB2U0DsYg4Hi94DVDuE8xgQSD3TAGOvL5IqIfMQn7IA0kTTJEzXdA4G6CcgSsi5CpSoY3_nrf8sKwobXqWr8LHSWW97TNf_pnSkBmaWyYmb4BdI9j4207fZXsntFCba3RnE_uuCjgQ-aQfTeFfExLimlve6nesgEUJqKm3lqbnOKDS57rTqZx9sxMZBvzQXApYApbgN3KDnFAUT5XW-TD7RwIXBBnYWS1QNNIzeoeaKelNeiW6DLw1-98uAluB1FV-w20WD87O-3RbRdOKi2X4S3Zc9UXLoZ4P7e4lnX7AA5_XqmYbzDFKwnVT2F8myiAdvcPeF5cO6AEnyx-xJJQJtD0YWxEYruKbwpa97l6VXzzQO9xsISOy2-4gg7rULbdMnv43AUFlb-MoNYI_RbwAwN3hyji6M46I1cD6lSvBHWc47MNOazlueA=w992-h582-no)

Pastikan content type yang digunakan adalah application/json.

Body messagenya sebagai berikut

{ "data": {
    "nama": "endy",
    "no_peserta": "123"
  },
  "to" : "ethAjHSkZac:APA91bHatrwLuNuGOWvRvaINJc3S2hIHczl2dU73kk2O9Dhf4CEJO99zINWgSENaBPy_6mm6L74TlF3IeqlZtd1HLy6Zf-RPxWuetwdQsPETw--Nq4o_nGOwjffhv42JegG8F8HvkVBu"
}

Isi field to adalah registration token yang didapat aplikasi android kita pada saat dijalankan. Untuk aplikasi saya, nilai token ini saya tampilkan di log

    public void onTokenRefresh() {
        // Get updated InstanceID token.
        String refreshedToken = FirebaseInstanceId.getInstance().getToken();

        // TODO: Implement this method to send any registration to your app's servers.
        sendRegistrationToServer(refreshedToken);
    }

    private void sendRegistrationToServer(String token) {
        Log.d(TAG, "Refreshed token: " + token);
    }

Sehingga token yang didapat bisa dilihat di Android Monitor.

[Android Monitor Token](https://lh3.googleusercontent.com/NQxjGmJHpBiGqJIh6kjpj213zUFJ764Rg-6y71Sm-Xw1Ud6_RVIaoAwyKXGaVROCc4ZVXi62NnaDhfsy23re4ggAUuOb970lKl2njdnns39Sj2-C2RvTvNTzLG4tc3zXI9fRQPysBqSksp3aZ3REQ527UdECivpAjuRZ4VICpweAU7e9UyA5vtgzqGj6phDM_ihP27q12PHtsxYhbfY2pk-aSRCP2nbbp5GHK2ku5D8v2c-I7vvpqi1DpYkiH2XwHz6Y9WhvqpjTiciP1vSpVweTa-pn5vudNryFDQGtSC1qreRMHWQeuqr6G2rQMKZtCiGlpmb2ztbBjqMArrl2Lb-ba4h3rKDDSHitcn5EylB7YbhtyyXzO65fzX5pmFJC8OpxPrtUnsapFAOdXdqHg72zDA5_qtCxMp6t7HnFxfPLXNKN3H_EEcDwLToBaxxRoR2e5lQQKNVXGBDxseisvZse0-TPtGp3WygTXXbkL2EvmuqSWstC-Jo4WcG6xHIzA0mPfvL1z4avA9xkbq8jMsvlTfKr66EYzmOMe1-Ur6nALXgQk3YnUxIbqxVQv4IFf4Zv5Ia-xyR6x8y-0DM4szQeagFA5CkNmYX_tEsot5WyaWw4zwjgSr7GVJGD9aU9ysjh4sb_uExpoRDTeWHnJwqKUK0t_BEV1Bn5p0POXA=w1322-h165-no)

Kemudian, kita isikan Authorization dengan key yang didapat dari Firebase Console tadi.

[Authorization Header](https://lh3.googleusercontent.com/m304L-YXodhPZ9dTI8101C6DV4geHp9y1FkQCnyWHVbva5W3vWDSKENxpgxjjHCv8GsFy5Yqt4uFzR0j7f9YCk5Sl43FN94Iyl_5hdo2iev023VsbMH82asuUigFawH-PYH0fZKqIvvOXFUaU4Md2mxp_72A9kmfolMsyACuQvM7KMIl-A4E4djDDhlVxCZFl2xQYZ5TpKHhdKTlCE_DDzSt5GeQXJg1M6LjNi4dJKDt_Qew_XsP4jwfElokwZe8P_8S2kHjAGD8h8UyplKYDs-uVXaxzCmFS0z4I_EAhazjHeMkh3CIkWXlH5r9YANTs3h-LWnS0PCurrLdjfHpEH7gefKI_IRWdqwqh6_MK_P_UHhfe_5A4Yns320rSD5WqzpSgQKeuS60kJUFM6n5M3EIBCqTj-WqhBnN0QVJh1Ru2vbvc3CpB7qOznU6Q7wtH0GZyMmQdk1mxSt_Gmrto_J1SLwBhauDBMmwsAhnKcaO7XeZvbVD5-Nzf_rWuwrIj1PsviXZYjoYadIk6k6MTf8oenY_13P5R3COvdoKaYlPnv7aikK2ZgOWr4mlc52sEx1VBazwLtT2hNchlQspLWFdDu3TK44PtXm67-WQArv14Y107WonFmrzUcT7-5A1H8Tc5ITTeYldN4BTNlLn2OxRMjAt2Snv8Q1X51e4OQ=w998-h205-no)

Jangan lupa untuk memberikan prefix key: sebelum nilai keynya.

Lakukan HTTP Post, dan FCM akan memberikan response seperti ini

[Response](https://lh3.googleusercontent.com/fhRDTbJ2d-8uskvtztz6YF7vEZkstDZHtpBhkmURSxveof89_r_DQz7VBEMH0a0H86NZjElYt1NInsXVR27fDoy8IZ1-pmRl1Ao7r47ILOfzetBbDTo4ulQ5vUb3fwHemjZt_JhEnSexNMARlekdk5CX2aOXzuJRFjADjNCGhr7dDIjWrF9v11fqkLVmnZBPl-b5yt-tNlWFr_5PO12dvhuSFyjp7AbxduKzo_smLQYkc_j1BdiZrlMoh3qVumrKipOlGobHUQlCeiWw41T6nOx8Aiqw6aTAzHz6NInRqg-iKQ0SsstEQc3IYCUug-n9r2QMhJkjKvgCY3mACqgafxgyezV66DymOHJuPpBnZ1ubDtsQgviYtpwsrPKxnkw8L4GGH3sQmxuydtyUtsFFbLvTpOYh3fGZ5n9KVpWbQkz8z0SONQVgkMl0_Y-BURUi1VrNZkLJsVrWiepDCrvA6HhokG7GHXEQu4G_SoSi7IbOo6VMHiBwQlZ94h9oM5XBcjRuTdFCjXS0slADU36Bl_xa0HOBFMa2GMiKGuq_5KdgXtj2o6qbfVwfTBtSeHbgyytEgvCJ03BFLEAxdvtAeh6RUpvIqRF9-8mGXKcTgs1a4NqohHO-goBpexSsAsDHuv5y8e2aLcVHqYqYDCaf_WKNl83dUaEu2pZ_tieyrw=w1001-h511-no)

Selanjutnya, kita bisa lihat messagenya diterima aplikasi Android kita dengan melihat ke Android Monitor.

[Android Monitor Message](https://lh3.googleusercontent.com/qt8GeUeceJbkna2_fYMATnYE4pxc90y8Y6l0wn7-TgiL6hrHDynrcIu92a8o6_hvETHF2ZhW3ODUj0neU3anM8ufGuyhavPfPZxIwHf25yKZtvCz9pM2Wiwrv8J12lr1grwSP0hVaPTkF86ciVAoBOeWqTL1zKMzoDsnvzledQ0Y4KWqAAz1SUfmHFaxeTLc9_54E_Hk0OBfABTjEsrC6yG09EKymxaP3sDvy5AipKqhZaunvP7dC1mQRWDQVY0fJ0g6s5NA-qLPSReuaAi7rawgultE3LvpS1c1V7Y5YQDrfeJCnpRXNkbCztz0ey4kSv_Myje8q6vogOy0DKmRRmf6CcMQdvbzHC-Wob9p2RkkUNf0Lug1VFytr83MUqQ-pDuVoThci-4hhL6V04f_KLH6NB8oNgkTsSd48KvxVJQuJGFFXab5L35U3juEOf8id4SzQaxOU_S550g-nBtO5HEurl2OCVLmOsOmmh31ziUC0ox-hYs82TXiou-oJ3R-0kz1-OtBK41K71YsFWZ-3Ik9D4Kh8IlUvytSoSUyTfqY-VJTbBUzzDmWdr7q89yVDMkQPgjuv0pu-gW82M9MkxXfO0QfTfwwunHCtqmzenuhOIe_TkMS7OPdfXDZeuLZS4fdunBd-cY-Ykr3shNIZZaF-1j-SoUXbqQh9ZMyZw=w994-h204-no)

Penutup

Demikianlah cara setup Firebase Cloud Messaging agar bisa digunakan di aplikasi Android. Selamat mencoba, semoga bermanfaat.