You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/notification-hubs/notification-hubs-android-push-notification-google-fcm-get-started.md
+21-15Lines changed: 21 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ ms.tgt_pltfrm: mobile-android
15
15
ms.devlang: java
16
16
ms.topic: tutorial
17
17
ms.custom: mvc
18
-
ms.date: 07/15/2019
18
+
ms.date: 09/11/2019
19
19
ms.author: jowargo
20
20
---
21
21
@@ -186,7 +186,7 @@ Your hub is now configured to work with Firebase Cloud Messaging. You also have
186
186
> [!IMPORTANT]
187
187
> Enter the **name** and the **DefaultListenSharedAccessSignature** of your hub before proceeding further.
188
188
189
-
3. Add another new class to your project named `RegistrationIntentService`. This class implements the `IntentService` interface. It also handles [refreshing the FCM token](https://developers.google.com/instance-id/guides/android-implementation#refresh_tokens) and [registering with the notification hub](notification-hubs-push-notification-registration-management.md).
189
+
2. Add another new class to your project named `RegistrationIntentService`. This class implements the `IntentService` interface. It also handles [refreshing the FCM token](https://developers.google.com/instance-id/guides/android-implementation#refresh_tokens) and [registering with the notification hub](notification-hubs-push-notification-registration-management.md).
190
190
191
191
Use the following code for this class.
192
192
@@ -288,7 +288,7 @@ Your hub is now configured to work with Firebase Cloud Messaging. You also have
288
288
}
289
289
```
290
290
291
-
4. In the `MainActivity` class, add the following `import` statements above the class declaration.
291
+
3. In the `MainActivity` class, add the following `import` statements above the class declaration.
@@ -299,7 +299,7 @@ Your hub is now configured to work with Firebase Cloud Messaging. You also have
299
299
import android.widget.Toast;
300
300
```
301
301
302
-
5. Add the following members at the top of the class. You use these fields to [check the availability of Google Play Services as recommended by Google](https://developers.google.com/android/guides/setup#ensure_devices_have_the_google_play_services_apk).
302
+
4. Add the following members at the top of the class. You use these fields to [check the availability of Google Play Services as recommended by Google](https://developers.google.com/android/guides/setup#ensure_devices_have_the_google_play_services_apk).
303
303
304
304
```java
305
305
public static MainActivity mainActivity;
@@ -308,7 +308,7 @@ Your hub is now configured to work with Firebase Cloud Messaging. You also have
308
308
private static final int PLAY_SERVICES_RESOLUTION_REQUEST = 9000;
309
309
```
310
310
311
-
6. In the `MainActivity` class, add the following method to check the availability of Google Play Services.
311
+
5. In the `MainActivity` class, add the following method to check the availability of Google Play Services.
312
312
313
313
```java
314
314
/**
@@ -335,7 +335,7 @@ Your hub is now configured to work with Firebase Cloud Messaging. You also have
335
335
}
336
336
```
337
337
338
-
7. In the `MainActivity` class, add the following code that checks for Google Play Services before calling the `IntentService` to get your FCM registration token and register with your hub:
338
+
6. In the `MainActivity` class, add the following code that checks for Google Play Services before calling the `IntentService` to get your FCM registration token and register with your hub:
339
339
340
340
```java
341
341
public void registerWithNotificationHubs()
@@ -348,7 +348,7 @@ Your hub is now configured to work with Firebase Cloud Messaging. You also have
348
348
}
349
349
```
350
350
351
-
8. In the `OnCreate` method of the `MainActivity` class, add the following code to start the registration process when the activity is created:
351
+
7. In the `OnCreate` method of the `MainActivity` class, add the following code to start the registration process when the activity is created:
352
352
353
353
```java
354
354
@Override
@@ -362,7 +362,7 @@ Your hub is now configured to work with Firebase Cloud Messaging. You also have
362
362
}
363
363
```
364
364
365
-
9. To verify app state and report status in your app, add these additional methods to `MainActivity`:
365
+
8. To verify app state and report status in your app, add these additional methods to `MainActivity`:
366
366
367
367
```java
368
368
@Override
@@ -401,15 +401,17 @@ Your hub is now configured to work with Firebase Cloud Messaging. You also have
401
401
}
402
402
```
403
403
404
-
10. The `ToastNotify` method uses the *"Hello World"* `TextView` control to report status and notifications persistently in the app. In your **res** > **layout** > **activity_main.xml** layout, add the following ID for that control.
404
+
9. The `ToastNotify` method uses the *"Hello World"* `TextView` control to report status and notifications persistently in the app. In your **res** > **layout** > **activity_main.xml** layout, add the following ID for that control.
405
405
406
406
```java
407
407
android:id="@+id/text_hello"
408
408
```
409
409
410
-
11. Next you add a subclass for the receiver that you defined in AndroidManifest.xml. Add another new class to your project named `FirebaseService`.
410
+

411
411
412
-
12. Add the following import statements at the top of `FirebaseService.java`:
412
+
10. Next you add a subclass for the receiver that you defined in AndroidManifest.xml. Add another new class to your project named `FirebaseService`.
413
+
414
+
11. Add the following import statements at the top of `FirebaseService.java`:
@@ -424,10 +426,10 @@ Your hub is now configured to work with Firebase Cloud Messaging. You also have
424
426
import android.net.Uri;
425
427
import android.os.Build;
426
428
import android.os.Bundle;
427
-
import android.support.v4.app.NotificationCompat;
429
+
import androidx.core.app.NotificationCompat;
428
430
```
429
431
430
-
13. Add the following code for the `FirebaseService` class, making it a subclass of `FirebaseMessagingService`.
432
+
12. Add the following code for the `FirebaseService` class, making it a subclass of `FirebaseMessagingService`.
431
433
432
434
This code overrides the `onMessageReceived` method and reports notifications that are received. it also sends the push notification to the Android notification manager by using the `sendNotification()` method. Call the `sendNotification()` method when the app isn't running and a notification is received.
433
435
@@ -514,12 +516,16 @@ Your hub is now configured to work with Firebase Cloud Messaging. You also have
514
516
}
515
517
```
516
518
517
-
14. In Android Studio, on the menu bar, select **Build** > **Rebuild Project** to make sure that there aren't any errors in your code. If you receive an error about the `ic_launcher` icon, remove the following statement from the AndroidManifest.xml file:
519
+
13. In Android Studio, on the menu bar, select **Build** > **Rebuild Project** to make sure that there aren't any errors in your code. If you receive an error about the `ic_launcher` icon, remove the following statement from the AndroidManifest.xml file:
518
520
519
521
```
520
522
android:icon="@mipmap/ic_launcher"
521
523
```
522
-
15. Run the app on your device and verify that it registers successfully with the hub.
524
+
14. Ensure you have a virtual device for running the app. If you do not have one, add one as follows:
15. Run the app on your selected device and verify that it registers successfully with the hub.
523
529
524
530
> [!NOTE]
525
531
> Registration might fail during the initial launch until the `onTokenRefresh()` method of the instance ID service is called. The refresh should initiate a successful registration with the notification hub.
Copy file name to clipboardExpand all lines: articles/notification-hubs/push-notifications-android-specific-users-firebase-cloud-messaging.md
+9-2Lines changed: 9 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ ms.tgt_pltfrm: mobile-android
14
14
ms.devlang: java
15
15
ms.topic: tutorial
16
16
ms.custom: mvc
17
-
ms.date: 05/01/2019
17
+
ms.date: 09/11/2019
18
18
ms.author: jowargo
19
19
---
20
20
@@ -466,7 +466,14 @@ The next step is to update the Android application created in the [Tutorial: Pus
466
466
```java
467
467
useLibrary 'org.apache.http.legacy'
468
468
```
469
-
13. Build the project.
469
+
13. If your app is targeting API level 28 (Android 9.0) or above, include the following declaration within the `<application>` element of `AndroidManifest.xml`.
Copy file name to clipboardExpand all lines: includes/notification-hubs-enable-firebase-cloud-messaging.md
+4-3Lines changed: 4 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@
5
5
author: spelluru
6
6
ms.service: notification-hubs
7
7
ms.topic: include
8
-
ms.date: 02/05/2019
8
+
ms.date: 09/11/2019
9
9
ms.author: spelluru
10
10
ms.custom: include file
11
11
---
@@ -28,10 +28,11 @@
28
28
```
29
29
classpath 'com.google.gms:google-services:4.0.1'
30
30
```
31
-
2. In your app-level build.gradle file (<project>/<app-module>/build.gradle), add the following statement to the **dependencies** section.
31
+
2. In your app-level build.gradle file (<project>/<app-module>/build.gradle), add the following statements to the **dependencies** section.
0 commit comments