+ * Modify this method to associate the user's FCM InstanceID token with any server-side account
+ * maintained by your application.
+ *
+ * @param token The new token.
+ */
+ private void sendRegistrationToServer(String token) {
+ // This method is blank, but if you were to build a server that stores users token
+ // information, this is where you'd send the token to the server.
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/android/example/com/squawker/fcm/SquawkFirebaseMessageService.java b/app/src/main/java/android/example/com/squawker/fcm/SquawkFirebaseMessageService.java
new file mode 100644
index 00000000..bc117fc5
--- /dev/null
+++ b/app/src/main/java/android/example/com/squawker/fcm/SquawkFirebaseMessageService.java
@@ -0,0 +1,164 @@
+/*
+* Copyright (C) 2017 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package android.example.com.squawker.fcm;
+
+import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.content.ContentValues;
+import android.content.Context;
+import android.content.Intent;
+import android.example.com.squawker.MainActivity;
+import android.example.com.squawker.R;
+import android.example.com.squawker.provider.SquawkContract;
+import android.example.com.squawker.provider.SquawkProvider;
+import android.media.RingtoneManager;
+import android.net.Uri;
+import android.os.AsyncTask;
+import android.support.v4.app.NotificationCompat;
+import android.util.Log;
+
+import com.google.firebase.messaging.FirebaseMessagingService;
+import com.google.firebase.messaging.RemoteMessage;
+
+import java.util.Map;
+
+/**
+ * Listens for squawk FCM messages both in the background and the foreground and responds
+ * appropriately
+ * depending on type of message
+ */
+public class SquawkFirebaseMessageService extends FirebaseMessagingService {
+
+ private static final String JSON_KEY_AUTHOR = SquawkContract.COLUMN_AUTHOR;
+ private static final String JSON_KEY_AUTHOR_KEY = SquawkContract.COLUMN_AUTHOR_KEY;
+ private static final String JSON_KEY_MESSAGE = SquawkContract.COLUMN_MESSAGE;
+ private static final String JSON_KEY_DATE = SquawkContract.COLUMN_DATE;
+
+ private static final int NOTIFICATION_MAX_CHARACTERS = 30;
+ private static String LOG_TAG = SquawkFirebaseMessageService.class.getSimpleName();
+
+ /**
+ * Called when message is received.
+ *
+ * @param remoteMessage Object representing the message received from Firebase Cloud Messaging
+ */
+ @Override
+ public void onMessageReceived(RemoteMessage remoteMessage) {
+ // There are two types of messages data messages and notification messages. Data messages
+ // are handled
+ // here in onMessageReceived whether the app is in the foreground or background. Data
+ // messages are the type
+ // traditionally used with FCM. Notification messages are only received here in
+ // onMessageReceived when the app
+ // is in the foreground. When the app is in the background an automatically generated
+ // notification is displayed.
+ // When the user taps on the notification they are returned to the app. Messages
+ // containing both notification
+ // and data payloads are treated as notification messages. The Firebase console always
+ // sends notification
+ // messages. For more see: https://firebase.google.com/docs/cloud-messaging/concept-options\
+
+ // The Squawk server always sends just *data* messages, meaning that onMessageReceived when
+ // the app is both in the foreground AND the background
+
+ Log.d(LOG_TAG, "-> From: " + remoteMessage.getFrom());
+
+ // Check if message contains a data payload.
+
+ Map