﻿<a id="account_removal_reporter_webservice"></a>

# Account Removal Reporter

## Overview

This web service can be used to report user log out or account removal to a server.
This can be used to clean up the server side data when the user logs out or removes the account from the app.
An example of such data can be a push token reported previously by [Push Token Reporter](push_token_reporter.md).

!!! warning
    Account Removal Reporter web service will only be called when the user logs out or removes the account from the app. It will not be called upon uninstalling the app or when the app data is cleared by the operating system.

## Parameters

Parameter templates for Account Removal Reporter can use any variables from [global](intro.md#global-params) and [account](intro.md#account-params)
scopes. The Account Removal Reporter also shares the following parameters with the [Push Token Reporter](push_token_reporter.md).

<a id="account-removal-selector"></a>

### `selector` { .reference-entry }

This parameter uniquely identifies the account.

Example: `12869E0E6E553673C54F29105A0647204C416A2A:7C3A0D14`

### `pushToken` { .reference-entry }

This is the identifier needed by Apple and Google push notification services to deliver the push to the specific
device and app. The value of this parameter is a base64 - encoded string of variable length.

### `pushTokenIncomingCall` { .reference-entry }

This is the identifier needed by Apple voip (pushkit) notification service to deliver the incoming call push to the specific device and app. The value of this parameter will be a base64 - encoded string of variable length.
As of iOS13 there are two push token/application ID pairs. One for delivering pushes for incoming calls and the other for delivering all other pushes. This is the one to use for incoming call pushes. The application ID to use along with this token is in `pushappid_incoming_call`.

### `pushTokenOther` { .reference-entry }

This is the identifier needed by Apple non-voip (remote-notification) notification service to deliver the push to the specific device and app. The value of this parameter will be a base64 - encoded string of variable length.
As of iOS13 there are two push token/application ID pairs. One for delivering pushes for incoming calls and the other for delivering all other pushes. This is the one to use for other pushes. It is alias to `pushToken`. The application ID to use along with this token is in `pushappid_other` or just `pushappid`.

### `pushappid` { .reference-entry }

This is the application ID to use along with the `pushToken`.

### `pushappid_incoming_call` { .reference-entry }

This is the application ID to use along with the `pushTokenIncomingCall`.

### `pushappid_other` { .reference-entry }

This is the application ID to use along with the `pushTokenOther`. It is the alias for `pushappid`.

## Configuration

The following [Account XML](../account/account.md) keys are relevant for Account Removal Reporter configuration:

### `reportAccountRemovalUrl` { .reference-entry }

Contains the URL, including URL scheme, of the web service, possibly also with query string.

Example (with query-string and both token/appid pairs):

```
https://example.com/removeToken/?username=%account[username]%&selector=%selector%&token_calls=%pushTokenIncomingCall%&appid_calls=%pushappid_incoming_call%&token_msgs=%pushTokenOther%&appid_msgs=%pushappid_other%
```

Example (without query-string and with just non-incoming-call token/appid):

```
https://example.com/removePushToken/%account[username]%/%selector%/%pushToken%&appid=%pushappid%
```

### `reportAccountRemovalPostData` { .reference-entry }

If filled in, the app will use POST request to report the token.

Example (for application/x-www-form-urlencoded):

```
username=%account[username]%&selector=%selector%&token_calls=%pushTokenIncomingCall%&appid_calls=%pushappid_incoming_call%&token_msgs=%pushTokenOther%&appid_msgs=%pushappid_other%
```

Example (for application/json):

```json
{ "username" : "%account[username]%", "token_calls" : "%pushTokenIncomingCall%", "token_msgs" : "%pushTokenOther%", "selector" : "%selector%", "appId_calls": "%pushappid_incoming_call%", "appId_msgs" : "%pushappid_other%" }
```

### `reportAccountRemovalContentType` { .reference-entry }

Specifies the value of Content-Type header to be sent in the request. If not specified, the app will default to
`application/x-www-form-urlencoded`

## Response

Due to the time sensitive nature of log out, the app does perform the request to the web service in a fire-and-forget manner, and it does not validate the response or even if the request was successful.

## Examples

### GET method

request:

```http
GET /removeToken/?username=johndow&password=12345678&selector=12869E0E6E553673C54F29105A0647204C416A2A:7C3A0D14&token_msgs=QVBBOTFiRzlhcVd2bW54bllCWldHOWh4dnRrZ3pUWFNvcGZpdWZ6bWM2dFAzS2J&appid_msgs=com.cloudsoftphone.app&token_calls=Udl99X2JFP1bWwS5gR%2FwGeLE1hmAB2CMpr1Ej0wxkrY%3D&appid_calls=com.cloudsoftphone.app.pushkit HTTP/1.1
Host: example.com
Connection: close
Cache-Control: max-age=0
User-Agent: CloudSoftphone/1.5.6
```

response:

```http
HTTP/1.1 200 OK
Date: Sun, 15 Mar 2015 00:46:17 GMT
Server: Apache/2.4.7 (Ubuntu)
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 0
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
```

### POST method, JSON

request:

```http
POST /removeToken/johndow/ HTTP/1.1
Host: example.com
Connection: close
Cache-Control: max-age=0
User-Agent: CloudSoftphone/1.5.6
Content-Type: application/json
Content-Length: 183

{
    "token_msgs"    : "QVBBOTFiRzlhcVd2bW54bllCWldHOWh4dnRrZ3pUWFNvcGZpdWZ6bWM2dFAzS2J",
    "appid_msgs"    : "com.cloudsoftphone.app",
    "token_calls"   : "Udl99X2JFP1bWwS5gR/wGeLE1hmAB2CMpr1Ej0wxkrY=",
    "appid_calls"   : "com.cloudsoftphone.app.pushkit",
    "selector"      : "12869E0E6E553673C54F29105A0647204C416A2A:7C3A0D14"
}
```

response:

```http
HTTP/1.1 200 OK
Date: Sun, 15 Mar 2015 00:46:17 GMT
Server: Apache/2.4.7 (Ubuntu)
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 0
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
```