From e3430d0b4129ae6bbab02f846ebabc69a3da36fa Mon Sep 17 00:00:00 2001 From: Lyla Date: Thu, 23 Feb 2017 17:18:12 -0800 Subject: [PATCH 1/2] TFCM.02-Solution-TestGettingExtraData --- .../android/example/com/squawker/MainActivity.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/android/example/com/squawker/MainActivity.java b/app/src/main/java/android/example/com/squawker/MainActivity.java index 5abffe75..552f3ea6 100644 --- a/app/src/main/java/android/example/com/squawker/MainActivity.java +++ b/app/src/main/java/android/example/com/squawker/MainActivity.java @@ -86,8 +86,14 @@ protected void onCreate(Bundle savedInstanceState) { // Start the loader getSupportLoaderManager().initLoader(LOADER_ID_MESSAGES, null, this); - // TODO (1) Get the test data here from the extras bundle that came with this intent. - // To confirm that the data was passed in, make sure to show the data in a log statement. + // Gets the extra data from the intent that started the activity. For *notification* + // messages, this will contain key value pairs stored in the *data* section of the message. + Bundle extras = getIntent().getExtras(); + // Checks if the extras exist and if the key "test" from our FCM message is in the intent + if (extras != null && extras.containsKey("test")) { + // If the key is there, print out the value of "test" + Log.d(LOG_TAG, "Contains: " + extras.getString("test")); + } } From 2acdaaba661f5d052e711cdfef080f3d7dc0d1c6 Mon Sep 17 00:00:00 2001 From: Lyla Date: Fri, 27 Jan 2017 18:17:40 -0800 Subject: [PATCH 2/2] TFCM.03-Exercise-GetInstanceIdToken --- app/src/main/AndroidManifest.xml | 3 +++ .../java/android/example/com/squawker/MainActivity.java | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 39412b52..29ce1f00 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -33,6 +33,9 @@ android:value=".MainActivity" /> + + \ No newline at end of file diff --git a/app/src/main/java/android/example/com/squawker/MainActivity.java b/app/src/main/java/android/example/com/squawker/MainActivity.java index 552f3ea6..0bb93f23 100644 --- a/app/src/main/java/android/example/com/squawker/MainActivity.java +++ b/app/src/main/java/android/example/com/squawker/MainActivity.java @@ -95,6 +95,14 @@ protected void onCreate(Bundle savedInstanceState) { Log.d(LOG_TAG, "Contains: " + extras.getString("test")); } + // TODO (1) Make a new package for your FCM service classes called "fcm" + // TODO (2) Create a new Service class that extends FirebaseInstanceIdService. + // You'll need to implement the onTokenRefresh method. Simply have it print out + // the new token. + // TODO (3) Here, in MainActivity, get a token using FirebaseInstanceId.getInstance().getToken() + // TODO (4) Get the message from that token and print it in a log statement + + } @Override