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/how-tos/calling-sdk/includes/push-notifications/push-notifications-android.md
+37-34Lines changed: 37 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,36 +5,36 @@ ms.topic: include
5
5
ms.date: 08/06/2024
6
6
ms.author: sanathr
7
7
---
8
-
> [!IMPORTANT]
9
-
> On June 20, 2023, Google announced that it [deprecated sending messages using the FCM legacy APIs](https://firebase.google.com/docs/cloud-messaging). Google is removing the legacy FCM from service in June 2024. Google recommends [migrating from legacy FCM APIs to FCM HTTP v1](https://firebase.google.com/docs/cloud-messaging/migrate-v1).
10
-
> Please follow this [migration guide](/azure/communication-services/tutorials/call-chat-migrate-android-push-fcm-v1) if your Communication reosurce is still using the old FCM legacy APIs.
### Additional Prerequisites for Push Notifications
9
+
- A Firebase account with Firebase Cloud Messaging (FCM) enabled and with your FCM service connected to an Azure Notification Hubs instance. For more information, see [Communication Services notifications](../../../../concepts/notifications.md).
10
+
- Android Studio version 3.6 or later to build your application.
11
+
- A set of permissions to enable the Android application to receive notification messages from FCM. In your `AndroidManifest.xml` file, add the following permissions right after `<manifest ...>` or below the `</application>` tag:
15
12
16
-
A Firebase account set up with Cloud Messaging (FCM) enabled and with your Firebase Cloud Messaging service connected to an Azure Notification Hub instance. See [Communication Services notifications](../../../../concepts/notifications.md) for more information.
17
-
Additionally, the tutorial assumes you're using Android Studio version 3.6 or higher to build your application.
A set of permissions is required for the Android application in order to be able to receive notifications messages from Firebase Cloud Messaging. In your `AndroidManifest.xml` file, add the following set of permissions right after the `<manifest ...>` or below the `</application>` tag.
19
+
> [!IMPORTANT]
20
+
> On June 20, 2023, Google announced that it [deprecated sending messages by using the FCM legacy APIs](https://firebase.google.com/docs/cloud-messaging) and would start removing the legacy FCM from service in June 2024. Google recommends [migrating from legacy FCM APIs to FCM HTTP v1](https://firebase.google.com/docs/cloud-messaging/migrate-v1).
21
+
>
22
+
> If your Communication Services resource is still using the FCM legacy APIs, follow [this migration guide](/azure/communication-services/tutorials/call-chat-migrate-android-push-fcm-v1).
Mobile push notifications are the pop-up notifications you see on mobile devices. For calling, we'll be focusing on VoIP (Voice over Internet Protocol) push notifications. We register for push notifications, handle push notifications, and then unregister push notifications.
26
+
Mobile push notifications are the pop-up notifications that appear on mobile devices. For calling, this article focuses on voice over Internet Protocol (VoIP) push notifications.
29
27
30
28
> [!NOTE]
31
-
> Registering for Push Notifications and handling of the incoming Push Notifications for a Teams user, the APIs are the same. The APIs described here can also be invoked on the `CommonCallAgent` or `TeamsCallAgent` classes.
29
+
> When the application registers for push notifications and handles the incoming push notifications for a Teams user, the APIs are the same. The APIs that this article describes can also be invoked on the `CommonCallAgent` or `TeamsCallAgent` class.
To register for push notifications, the application needs to call `registerPushNotification()` on a `CallAgent` instance with a device registration token.
35
+
To register for push notifications, the application needs to call `registerPushNotification()` on a `CallAgent` instance by using a device registration token.
36
36
37
-
To obtain the device registration token, add the Firebase SDK to your application module's `build.gradle` file by adding the following lines in the `dependencies` section if it's not already there:
37
+
To obtain the device registration token, add the Firebase SDK to your application module's `build.gradle` file by adding the following lines in the `dependencies` section (if the lines aren't already there):
38
38
39
39
```groovy
40
40
// Add the SDK for Firebase Cloud Messaging
@@ -48,13 +48,13 @@ In your project level's *build.gradle* file, add the following line in the `depe
48
48
classpath 'com.google.gms:google-services:4.3.3'
49
49
```
50
50
51
-
Add the following plugin to the beginning of the file if it's not already there:
51
+
Add the following plug-in to the beginning of the file if it's not already there:
52
52
53
53
```groovy
54
54
apply plugin: 'com.google.gms.google-services'
55
55
```
56
56
57
-
Select *Sync Now* in the toolbar. Add the following code snippet to get the device registration token generated by the Firebase Cloud Messaging SDK for the client application instance. Be sure to add the below imports to the header of the main Activity for the instance to retrieve the token.
57
+
On the toolbar, select **Sync Now**. Add the following code snippet to get the device registration token that the Firebase Cloud Messaging SDK generated for the client application instance. Be sure to add the following imports to the header of the main activity for the instance to retrieve the token.
Register the device registration token with the Calling Services SDK for incoming call push notifications:
86
87
87
88
```java
@@ -94,19 +95,19 @@ catch(Exception e) {
94
95
}
95
96
```
96
97
97
-
## Push notification handling
98
+
## Handle push notifications
98
99
99
-
To receive incoming call push notifications, call *handlePushNotification()* on a *CallAgent* instance with a payload.
100
+
To receive incoming call push notifications, call `handlePushNotification()` on a `CallAgent` instance with a payload.
100
101
101
-
To obtain the payload from Firebase Cloud Messaging, begin by creating a new Service (File > New > Service > Service) that extends the *FirebaseMessagingService* Firebase SDK class and override the `onMessageReceived` method. This method is the event handler called when Firebase Cloud Messaging delivers the push notification to the application.
102
+
To obtain the payload from Firebase Cloud Messaging, begin by creating a new service (select **File** > **New** > **Service** > **Service**) that extends the `FirebaseMessagingService` Firebase SDK class and overrides the `onMessageReceived` method. This method is the event handler that's called when Firebase Cloud Messaging delivers the push notification to the application.
@@ -116,6 +117,7 @@ public class MyFirebaseMessagingService extends FirebaseMessagingService {
116
117
}
117
118
}
118
119
```
120
+
119
121
Add the following service definition to the `AndroidManifest.xml` file, inside the `<application>` tag:
120
122
121
123
```xml
@@ -128,7 +130,7 @@ Add the following service definition to the `AndroidManifest.xml` file, inside t
128
130
</service>
129
131
```
130
132
131
-
Once the payload is retrieved, it can be passed to the *Communication Services* SDK to be parsed out into an internal *IncomingCallInformation* object that will handle calling the *handlePushNotification* method on a *CallAgent* instance. A `CallAgent` instance is created by calling the `createCallAgent(...)` method on the `CallClient` class.
133
+
After you retrieve the payload, you can pass it to the Communication Services SDK to be parsed into an internal `IncomingCallInformation` object. This object handles calling the `handlePushNotification` method on a `CallAgent` instance. You create a `CallAgent` instance by calling the `createCallAgent(...)` method on the `CallClient` class.
132
134
133
135
```java
134
136
try {
@@ -140,11 +142,11 @@ catch(Exception e) {
140
142
}
141
143
```
142
144
143
-
When the handling of the Push notification message is successful, and the all events handlers are registered properly, the application rings.
145
+
When the handling of the push notification message is successful, and the all event handlers are registered properly, the application rings.
144
146
145
147
## Unregister push notifications
146
148
147
-
Applications can unregister push notification at any time. Call the `unregisterPushNotification()` method on callAgent to unregister.
149
+
Applications can unregister push notification at any time. To unregister, call the `unregisterPushNotification()` method on `callAgent`:
148
150
149
151
```java
150
152
try {
@@ -155,13 +157,14 @@ catch(Exception e) {
155
157
}
156
158
```
157
159
158
-
## Disable internal push for incoming call
160
+
## Disable internal push notifications for an incoming call
161
+
162
+
The push payload of an incoming call can be delivered to the callee in two ways:
159
163
160
-
There are two ways that a push payload of an incoming call can be delivered to the callee.
161
-
- Using FCM and registering the device token with the API mentioned above, `registerPushNotification` on `CallAgent` or `TeamsCallAgent`.
162
-
- When a `CallAgent` or `TeamsCallAgent` is created, SDK also registers with an internal service to get the push payload delivered.
164
+
- Using FCM and registering the device token with the API mentioned earlier, `registerPushNotification` on `CallAgent` or `TeamsCallAgent`
165
+
- Registering the SDK with an internal service upon creation of `CallAgent` or `TeamsCallAgent` to get the push payload delivered
163
166
164
-
Using the property `setDisableInternalPushForIncomingCall` in `CallAgentOptions` or `TeamsCallAgentOptions` it's possible to instruct the SDK to disable the delivery of the push payload using the internal push service.
167
+
By using the property `setDisableInternalPushForIncomingCall` in `CallAgentOptions` or `TeamsCallAgentOptions`, it's possible to instruct the SDK to disable the delivery of the push payload via the internal push service:
Mobile push notifications are the pop-up notifications you see on mobile devices. For calling, we'll be focusing on VoIP (Voice over Internet Protocol) push notifications. We'll register for push notifications, handle push notifications, and then un-register push notifications. For a guide on CallKit integration in your iOS application, refer here, [CallKit integration with iOS ACS SDK](../../callkit-integration.md).
10
+
Mobile push notifications are the pop-up notifications that appear on mobile devices. For calling, this article focuses on voice over Internet Protocol (VoIP) push notifications. For a guide on CallKit integration in your iOS application, see [Integrate with CallKit](../../callkit-integration.md).
12
11
13
12
> [!NOTE]
14
-
> Registering for Push Notifications and handling of the incoming Push Notifications for a Teams user, the APIs are the same. The APIs described here can also be invoked on the `CommonCallAgent` or `TeamsCallAgent`classes.
13
+
> When the application registers for push notifications and handles the incoming push notifications for a Teams user, the APIs are the same. The APIs that this article describes can also be invoked on the `CommonCallAgent` or `TeamsCallAgent`class.
A mobile push notification is the pop-up notification that you get in the mobile device. For calling, we'll focus on VoIP (voice over Internet Protocol) push notifications.
17
+
### Set up push notifications
19
18
20
-
The following sections describe how to register for, handle, and unregister push notifications. Before you start those tasks, complete these prerequisites:
19
+
Before you start the tasks of registering for, handling, and unregistering push notifications, complete this setup task:
21
20
22
21
1. In Xcode, go to **Signing & Capabilities**. Add a capability by selecting **+ Capability**, and then select **Push Notifications**.
23
22
2. Add another capability by selecting **+ Capability**, and then select **Background Modes**.
24
23
3. Under **Background Modes**, select the **Voice over IP** and **Remote notifications** checkboxes.
25
24
26
25
:::image type="content" source="../../../../quickstarts/voice-video-calling/media/ios/xcode-push-notification.png" alt-text="Screenshot that shows how to add capabilities in Xcode." lightbox="../../../../quickstarts/voice-video-calling/media/ios/xcode-push-notification.png":::
27
26
28
-
###Register for push notifications
27
+
## Register for push notifications
29
28
30
-
To register for push notifications, call `registerPushNotification()` on a `CallAgent` instance with a device registration token.
29
+
To register for push notifications, call `registerPushNotification()` on a `CallAgent` instance by using a device registration token.
31
30
32
-
Registration for push notifications needs to happen after successful initialization. When the `callAgent` object is destroyed, `logout`will be called, which will automatically unregister push notifications.
31
+
Registration for push notifications needs to happen after successful initialization. When the `callAgent` object is destroyed, `logout`is called, which automatically unregisters push notifications.
33
32
34
33
```swift
35
34
let deviceToken: Data = pushRegistry?.pushToken(for: PKPushType.voIP)
@@ -43,7 +42,8 @@ callAgent.registerPushNotifications(deviceToken: deviceToken!) { (error) in
43
42
```
44
43
45
44
## Handle push notifications
46
-
To receive push notifications for incoming calls, call `handlePushNotification()` on a `CallAgent` instance with a dictionary payload.
45
+
46
+
To receive push notifications for incoming calls, call `handlePushNotification()` on a `CallAgent` instance with a dictionary payload:
47
47
48
48
```swift
49
49
let callNotification = PushNotificationInfo.fromDictionary(pushPayload.dictionaryPayload)
@@ -56,9 +56,10 @@ callAgent.handlePush(notification: callNotification) { (error) in
56
56
}
57
57
}
58
58
```
59
+
59
60
## Unregister push notifications
60
61
61
-
Applications can unregister push notification at any time. Simply call the `unregisterPushNotification` method on `CallAgent`.
62
+
Applications can unregister push notification at any time. To unregister, call the `unregisterPushNotification` method on `CallAgent`.
62
63
63
64
> [!NOTE]
64
65
> Applications are not automatically unregistered from push notifications on logout.
@@ -73,13 +74,14 @@ callAgent.unregisterPushNotification { (error) in
73
74
}
74
75
```
75
76
76
-
## Disable internal push for incoming call
77
+
## Disable internal push notifications for an incoming call
78
+
79
+
The push payload of an incoming call can be delivered to the callee in two ways:
77
80
78
-
There are 2 ways that a push payload of an incoming call can be delivered to the callee.
79
-
- Using APNS and registering the device token with the API mentioned above, `registerPushNotification` on `CallAgent` or `TeamsCallAgent`.
80
-
- When a `CallAgent` or `TeamsCallAgent` is created, SDK also registers with an internal service to get the push payload delivered.
81
+
- Using Apple Push Notification service (APNS) and registering the device token with the API mentioned earlier, `registerPushNotification` on `CallAgent` or `TeamsCallAgent`
82
+
- Registering the SDK with an internal service upon creation of `CallAgent` or `TeamsCallAgent` to get the push payload delivered
81
83
82
-
Using the property `disableInternalPushForIncomingCall` in `CallAgentOptions` or `TeamsCallAgentOptions` it's possible to instruct the SDK to disable the delivery of the push payload using the internal push service.
84
+
By using the property `disableInternalPushForIncomingCall` in `CallAgentOptions` or `TeamsCallAgentOptions`, it's possible to instruct the SDK to disable the delivery of the push payload via the internal push service:
Azure Communication Services Web Calling SDK - Web push notifications are in public preview and available as part of version 1.12.0-beta.2+.
16
17
17
-
Please visit our web push notifications quickstart tutorial: https://github.com/Azure-Samples/communication-services-javascript-quickstarts/blob/main/calling-web-push-notifications/README.md
18
+
For step-by-step instructions, see the [quickstart on GitHub](https://github.com/Azure-Samples/communication-services-javascript-quickstarts/blob/main/calling-web-push-notifications/README.md).
0 commit comments