Skip to content

Commit 7c08f35

Browse files
committed
NIT
1 parent 2e7bbfa commit 7c08f35

File tree

3 files changed

+50
-50
lines changed

3 files changed

+50
-50
lines changed

articles/communication-services/quickstarts/chat/includes/chat-android.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@ Copy the following code into class `MainActivity` in file `MainActivity.java`:
162162
> Initializing `ApplicationConstants` needs to be added to `MainActivity.java` if EITHER of the following conditions is met: 1. The push notification feature is NOT enabled. 2. The version for the Azure Communication Chat library for Android is < '2.0.0'. Otherwise, please refer to step 11 in [Android push notifications](../../../tutorials/chat-android-push-notification.md). Please refer to the sample APP of the SDK version that you are consuming for reference.
163163
164164
`ACS_ENDPOINT`, `FIRST_USER_ID` and `FIRST_USER_ACCESS_TOKEN` are returned from calling Azure Function. Please check out [Azure Function integration](../../../tutorials/integrate-azure-function.md) for details. We use the response from calling Azure Function to initialize the list of parameters:
165-
1. `ACS_ENDPOINT`: the endpoint of your Communication Services resource.
166-
2. `FIRST_USER_ID` and `SECOND_USER_ID`: valid Communication Services user IDs generated by your Communication Services resource.
167-
3. `FIRST_USER_ACCESS_TOKEN`: the communication Services access token for `<FIRST_USER_ID>`.
165+
* `ACS_ENDPOINT`: the endpoint of your Communication Services resource.
166+
* `FIRST_USER_ID` and `SECOND_USER_ID`: valid Communication Services user IDs generated by your Communication Services resource.
167+
* `FIRST_USER_ACCESS_TOKEN`: the communication Services access token for `<FIRST_USER_ID>`.
168168

169169
Code block for initialing application parameters by calling Azure Function:
170170
```java

articles/communication-services/tutorials/chat-android-push-notification.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -195,28 +195,28 @@ Push notifications let clients be notified for incoming messages and other opera
195195
11. Add a custom `WorkManager` initializer by creating a class implementing `Configuration.Provider`:
196196

197197
```java
198-
public class MyAppConfiguration extends Application implements Configuration.Provider {
199-
Consumer<Throwable> exceptionHandler = new Consumer<Throwable>() {
198+
public class MyAppConfiguration extends Application implements Configuration.Provider {
199+
Consumer<Throwable> exceptionHandler = new Consumer<Throwable>() {
200+
@Override
201+
public void accept(Throwable throwable) {
202+
Log.i("YOUR_TAG", "Registration failed for push notifications!" + throwable.getMessage());
203+
}
204+
};
205+
200206
@Override
201-
public void accept(Throwable throwable) {
202-
Log.i("YOUR_TAG", "Registration failed for push notifications!" + throwable.getMessage());
207+
public void onCreate() {
208+
super.onCreate();
209+
// Initialize application parameters here
210+
WorkManager.initialize(getApplicationContext(), getWorkManagerConfiguration());
211+
}
212+
213+
@NonNull
214+
@Override
215+
public Configuration getWorkManagerConfiguration() {
216+
return new Configuration.Builder().
217+
setWorkerFactory(new RegistrationRenewalWorkerFactory(COMMUNICATION_TOKEN_CREDENTIAL, exceptionHandler)).build();
203218
}
204-
};
205-
206-
@Override
207-
public void onCreate() {
208-
super.onCreate();
209-
// Initialize application parameters here
210-
WorkManager.initialize(getApplicationContext(), getWorkManagerConfiguration());
211-
}
212-
213-
@NonNull
214-
@Override
215-
public Configuration getWorkManagerConfiguration() {
216-
return new Configuration.Builder().
217-
setWorkerFactory(new RegistrationRenewalWorkerFactory(COMMUNICATION_TOKEN_CREDENTIAL, exceptionHandler)).build();
218219
}
219-
}
220220
```
221221
**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.
222222

articles/communication-services/tutorials/integrate-azure-function.md

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,28 @@ Before you get started, make sure to:
3131
```
3232
4. Modify the `index.js` file so it looks like the code below:
3333
```JavaScript
34-
const { CommunicationIdentityClient } = require('@azure/communication-identity');
35-
const connectionString = '<your_connection_string>'
36-
const acsEndpoint = "<your_ACS_endpoint>"
37-
38-
module.exports = async function (context, req) {
39-
let tokenClient = new CommunicationIdentityClient(connectionString);
40-
41-
const userIDHolder = await tokenClient.createUser();
42-
const userId = userIDHolder.communicationUserId
43-
44-
const userToken = await (await tokenClient.getToken(userIDHolder, ["chat"])).token;
45-
46-
context.res = {
47-
body: {
48-
acsEndpoint,
49-
userId,
50-
userToken
51-
}
52-
};
53-
}
34+
const { CommunicationIdentityClient } = require('@azure/communication-identity');
35+
const connectionString = '<your_connection_string>'
36+
const acsEndpoint = "<your_ACS_endpoint>"
37+
38+
module.exports = async function (context, req) {
39+
let tokenClient = new CommunicationIdentityClient(connectionString);
40+
41+
const userIDHolder = await tokenClient.createUser();
42+
const userId = userIDHolder.communicationUserId
43+
44+
const userToken = await (await tokenClient.getToken(userIDHolder, ["chat"])).token;
45+
46+
context.res = {
47+
body: {
48+
acsEndpoint,
49+
userId,
50+
userToken
51+
}
52+
};
53+
}
5454
```
55-
**Explanation to code above**: The first line import the interface for the `CommunicationIdentityClient`. The connection string in the second line can be found in your ACS resource in the Azure Portal. The `ACSEndpoint` is the URL of the ACS resource that was created.
55+
**Explanation to code above**: The first line import the interface for the `CommunicationIdentityClient`. The connection string in the second line can be found in your ACS resource in the Azure portal. The `ACSEndpoint` is the URL of the ACS resource that was created.
5656

5757
5. Open the local Azure Function folder in Visual Studio Code. Open the `index.js` and run the local Azure Function. A local Azure Function endpoint will be created and printed in the terminal. The printed message looks similar to:
5858

@@ -63,16 +63,16 @@ HttpTrigger1: [GET,POST] http://localhost:7071/api/HttpTrigger1
6363

6464
Open the link in a browser. The result will be similar to this example:
6565
```
66-
{
67-
"acsEndpoint": "<Azure Function endpoint>",
68-
"userId": "8:acs:a636364c-c565-435d-9818-95247f8a1471_00000014-f43f-b90f-9f3b-8e3a0d00c5d9",
69-
"userToken": "eyJhbGciOiJSUzI1NiIsImtpZCI6IjEwNiIsIng1dCI6Im9QMWFxQnlfR3hZU3pSaXhuQ25zdE5PU2p2cyIsInR5cCI6IkpXVCJ9.eyJza3lwZWlkIjoiYWNzOmE2MzYzNjRjLWM1NjUtNDM1ZC05ODE4LTk1MjQ3ZjhhMTQ3MV8wMDAwMDAxNC1mNDNmLWI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2MzY0Yy1jNTY1LTQzNWQtOTgxOC05NTI0N2Y4YTE0NzEiLCJyZXNvdXJjZUxvY2F0aW9uIjoidW5pdGVkc3RhdGVzIiwiaWF0IjoxNjY3ODYyNzYyfQ.t-WpaUUmLJaD0V2vgn3M5EKdJUQ_JnR2jnBUZq3J0zMADTnFss6TNHMIQ-Zvsumwy14T1rpw-1FMjR-zz2icxo_mcTEM6hG77gHzEgMR4ClGuE1uRN7O4-326ql5MDixczFeIvIG8s9kAeJQl8N9YjulvRkGS_JZaqMs2T8Mu7qzdIOiXxxlmcl0HeplxLaW59ICF_M4VPgUYFb4PWMRqLXWjKyQ_WhiaDC3FvhpE_Bdb5U1eQXDw793V1_CRyx9jMuOB8Ao7DzqLBQEhgNN3A9jfEvIE3gdwafpBWlQEdw-Uuf2p1_xzvr0Akf3ziWUsVXb9pxNlQQCc19ztl3MIQ"
70+
}
7171
```
7272

7373
6. Deploy the local function to the cloud. More details can be found in [this documentation](../../azure-functions/functions-develop-vs-code.md).
7474

75-
7. **Test the deployed Azure Function.** First, find your Azure Function in the Azure Portal. Then, use the "Get Function URL" button to get the Azure Function endpoint. The result you see should be similar to what was shown in step 5. The Azure Function endpoint will be used in the app for initializing application parameters.
75+
7. **Test the deployed Azure Function.** First, find your Azure Function in the Azure portal. Then, use the "Get Function URL" button to get the Azure Function endpoint. The result you see should be similar to what was shown in step 5. The Azure Function endpoint will be used in the app for initializing application parameters.
7676

7777
8. Implement `UserTokenClient`, which is used to call the target Azure Function resource and obtain the ACS endpoint, user ID and user token from the returned JSON object. Refer to the sample app for usage.
7878

@@ -83,7 +83,7 @@ Open the link in a browser. The result will be similar to this example:
8383
## (Optional) secure the Azure Function endpoint
8484
For demonstration purposes, this sample uses a publicly accessible endpoint by default to fetch an Azure Communication Services token. For production scenarios, one option is to use your own secured endpoint to provision your own tokens.
8585

86-
With extra configuration, this sample supports connecting to an Azure Active Directory (Azure AD) protected endpoint so that user log in is required for the app to fetch an Azure Communication Services token. The user will be required to sign in with Microsoft account to access the app. This setup increases the security level while users are required to log in. Decide whether to enable it based on the use cases.
86+
With extra configuration, this sample supports connecting to an Azure Active Directory (Azure AD) protected endpoint so that user log is required for the app to fetch an Azure Communication Services token. The user will be required to sign in with Microsoft account to access the app. This setup increases the security level while users are required to log in. Decide whether to enable it based on the use cases.
8787

8888
Note that we currently don't support Azure AD in sample code. Follow the links below to enable it in your app and Azure Function:
8989

0 commit comments

Comments
 (0)