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/communication-services/tutorials/chat-android-push-notification.md
+11-9Lines changed: 11 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,23 +5,24 @@ description: Learn how to enable push notification in Android App by using Azure
5
5
author: jiminwen
6
6
services: azure-communication-services
7
7
ms.author: jiminwen
8
-
ms.date: 08/16/2022
8
+
ms.date: 06/28/2025
9
9
ms.topic: tutorial
10
10
ms.service: azure-communication-services
11
11
---
12
12
13
13
14
14
# Enable push notifications in Android
15
15
16
-
Push notifications enable clients to be notified for incoming messages and other operations occurring in a chat thread in situations where the mobile app isn't running in the foreground. Azure Communication Services supports a [list of events that you can subscribe to](../concepts/chat/concepts.md#push-notifications).
16
+
Push notifications enable clients to be notified of incoming messages and other operations occurring in a chat thread when the mobile app isn't running in the foreground. Azure Communication Services supports a [list of events that you can subscribe to](../concepts/chat/concepts.md#push-notifications).
17
17
18
18
> [!NOTE]
19
-
> Chat push notifications are supported for Android SDK in versions starting from 1.1.0-beta.4 and 1.1.0. It is recommended that you use version 2.0.0 or newer, as older versions have a known issue with the registration renewal. Steps from 8 to 12 are only needed for versions equal to or greater than 2.0.0.
19
+
> Chat push notifications are supported for Android SDK in versions starting from 1.1.0-beta.4 and 1.1.0. We recommended that you use version 2.0.0 or newer, as older versions have a known issue with the registration renewal. Steps from 8 to 12 are only needed for versions equal to or greater than 2.0.0.
20
20
21
21
1. Set up Firebase Cloud Messaging for the ChatQuickstart project. Complete steps `Create a Firebase project`, `Register your app with Firebase`, `Add a Firebase configuration file`, `Add Firebase SDKs to your app`, and `Edit your app manifest` in [Firebase Documentation](https://firebase.google.com/docs/cloud-messaging/android/client).
22
22
23
23
2. Create a Notification Hub within the same subscription as your Communication Services resource, configure your Firebase Cloud Messaging settings for the hub, and link the Notification Hub to your Communication Services resource. See [Notification Hub provisioning](../concepts/notifications.md#notification-hub-provisioning).
24
-
3. Create a new file called `MyFirebaseMessagingService.java` in the same directory where `MainActivity.java` resides. Copy the following code into `MyFirebaseMessagingService.java`. You will need to replace `<your_package_name>` with the package name used in `MainActivity.java`. You can use your own value for `<your_intent_name>`. This value will be used in step 6 below.
24
+
25
+
3. Create a new file called `MyFirebaseMessagingService.java` in the same directory where `MainActivity.java` resides. Copy the following code into `MyFirebaseMessagingService.java`. You need to replace `<your_package_name>` with the package name used in `MainActivity.java`. You can use your own value for `<your_intent_name>`. Use this value in step **6**.
25
26
26
27
```java
27
28
package<your_package_name>;
@@ -149,7 +150,7 @@ Push notifications enable clients to be notified for incoming messages and other
149
150
}
150
151
```
151
152
152
-
7. Put the following code below the comment `<RECEIVE CHAT MESSAGES>` in `MainActivity`:
153
+
7. Put the following code after the comment `<RECEIVE CHAT MESSAGES>` in `MainActivity`:
153
154
154
155
```java
155
156
startFcmPushNotification();
@@ -220,11 +221,12 @@ Push notifications enable clients to be notified for incoming messages and other
220
221
}
221
222
}
222
223
```
223
-
**Explanation to code above:** The default initializer of `WorkManager` has been disabled in step 9. This step implements `Configuration.Provider` to provide a customized 'WorkFactory', which is responsible to create `WorkerManager` during runtime.
224
224
225
-
If the app is integrated with Azure Function, initialization of application parameters should be added in method 'onCreate()'. Method 'getWorkManagerConfiguration()' is called when the application is starting, before any activity, service, or receiver objects (excluding content providers) have been created, so that application parameters could be initialized before being used. More details can be found in the sample chat app.
225
+
**Explanation of the preceding code:** The default initializer of `WorkManager` is disabled in step **9**. This step implements `Configuration.Provider` to provide a customized `WorkFactory`, which is responsible to create `WorkerManager` during runtime.
226
+
227
+
If the app is integrated with Azure Function, initialize the application parameters in method `onCreate()`. Method `getWorkManagerConfiguration()` is called when the application is starting, before any activity, service, or receiver objects (excluding content providers) are created, so application parameters can be initialized before use. For more details, see the sample chat app.
226
228
227
-
12. Add the `android:name=.MyAppConfiguration` field, which uses the class name from step 11, into `AndroidManifest.xml`:
229
+
12. Add the `android:name=.MyAppConfiguration` field, which uses the class name from step **11**, into `AndroidManifest.xml`:
228
230
229
231
```
230
232
<application
@@ -238,7 +240,7 @@ If the app is integrated with Azure Function, initialization of application para
238
240
>
239
241
```
240
242
241
-
## Related topics
243
+
## Related articles
242
244
243
245
-[Migrate Android SDK push notifications to FCM v1](./call-chat-migrate-android-push-fcm-v1.md)
244
246
-[Register for Android SDK push notifications using FCM v1](./call-chat-register-android-push-fcm-v1.md)
0 commit comments