PC Pusher 5.3 En
Содержание
What's new
- Since version 5.2, Pusher does not require a database.
- Support sending to Huawei devices.
Authentication data and push templates
Authentication data and templates for sending pushes to PC applications are hardwired into the server module. Thus, for typical use with a PC application, configuration of the module is not required.
Status of sent pushes
The states of sent pushes are stored in the memory of the server module. The size of the ring buffer for storing push statuses is 1000. The position of a push in the queue does not change from the moment of creation.
Configuration
Configuration options include:
- general parameters of the module;
- authentication data for the application (differentiated by application/bundle id);
- templates for applied systems (differentiated by systemid).
The search for configuration parameters is carried out in the following directories in sequence, until the first of the listed ones is found:
/opt/wildfly/pc_pusher
/opt/pc/pc_pusher
C:\\pc\\pc_pusher
C:\\wildfly\\pc_pusher
or in the directory specified through environment variables, with the parameter -Dpcp_config=
. If the path to the directory is set through environment variables, then the search in directories is not performed by default.
Directory structure
.
├── apps
│ ├── com.example.corp.dev.json
│ ├── com.example.cort.json
│ ├── com.example.retail.dev.json
│ └── com.example.retail.json
├── systems
│ └── 3550fa38-5d17-4fbf-a660-506227a2ed0e.json
└── pusher.conf.json
General parameters
General module parameters are set in the root of the configuration directory in the file pusher.conf.json.
Property | Description |
---|---|
debug_info | Enable debug information output. |
proxy | Parameters for connecting through a proxy. |
notification_status_buffer_size | Size of the queue for storing transaction statuses. |
core_size | Initial number of workers. |
queue_size | If the queue grows to this value, then the number of workers increases to max_core_size .
|
max_core_size | Maximum number of workers. If the queue is full, then Exception "TASKS_QUEUE_IS_FULL" (HTTP 400, PC_Error 313) is returned. |
performance_log | If debug_info is enabled, then in this case will be launched a daemon process , which will calculate the performance of the pusher with a period of performance_log_period and output the results to the log.
|
Configuration file example
The values shown are set by default
{
"debug_info": false,
"notification_status_buffer_size": 1000,
"proxy": {
"host": null,
"port": 3128,
"username": null,
"password": null
},
"push_tasks_pool": {
"core_size": 5,
"max_core_size": 50,
"queue_size":500
},
"performance_log": false,
"performance_log_period": 1000
}
Application Credentials
Authentication data for sending push notifications to applications are set in files named %app_id%.json
in directory apps
(where %app_id%
— application/bundle ID).
For iOS, only one of the listed authentication options is sufficient (p8/p12/firebase).
An example of a file with authentication data:
{
"android": {
"google_api_key": "AAAAoZ7vyz4:APA91bFqLfNe... ...DbKBCGCXk"
},
"ios": {
"apns_p8": {
"use_dev_gate": false,
"apns_key_id": "JVBQX52N5Z",
"apns_team_id": "48HZH4RWJD",
"apns_key": "-----BEGIN PRIVATE KEY-----\nMIGTAgEAMBMGByqGSM49AgE... ...tRHxUI6\n-----END PRIVATE KEY-----"
},
"apns_p12": {
"use_dev_gate": false,
"p12_file": "/opt/pc/apns_keyfile.p12",
"p12_pass": "Pa$$w0rd"
},
"firebase": {
"google_api_key": "AAAAoZ7vyz4:APA91bFqLfNe... ...DbKBCGCXk"
}
},
"huawei": {
"client_secret": "0a5be... ...f04bec3a",
"client_id": "10... ...79"
}
}
Push-notifications templates
Templates for push notifications to applications are specified in files named %systemid%.json
, or default.json
in directory systems
. The file with the specified SystemID has priority. Sample file with templates:
{
"android": {
"templates": {
"transaction": [
{
"to": "%DEVICE_TOKEN%",
"notification": {
"tag": "%USER_ID%",
"title": "PayControl",
"body": "New operation to confirm",
"icon": "paycontrol_push",
"sound": "default"
},
"data": {
"type": "PayControl_v2"
}
},
{
"to": "%DEVICE_TOKEN%",
"data": {
"type": "PayControl_v2",
"userid": "%USER_ID%",
"transactionid": "%TRANSACTION_ID%"
}
}
]
}
},
"ios": {
"use_dev_gate": false,
"templates": {
"transaction": [
{
"aps": {
"alert": "New operation to confirm",
"sound": "default",
"badge": 1,
"mutable-content": 1,
"category": "NEW_OPERATION"
},
"type": "PayControl",
"userid": "%USER_ID%",
"transactionid": "%TRANSACTION_ID%",
"pc_notification_type": "alert",
"pc_notification_priority": 10,
"pc_notification_timeout": 600,
"pc_collapse_id": "%USER_ID%"
}
]
}
},
"huawei": {
"templates": {
"transaction": [
{
"validate_only": false,
"message": {
"android": {
"notification": {
"tag": "%USER_ID%",
"title": "PayControl",
"body": "New operation to confirm",
"icon": "paycontrol_push",
"click_action": {
"type": 3
}
}
},
"token": [
"%DEVICE_TOKEN%"
]
}
},
{
"validate_only": false,
"message": {
"android": {
"collapse_key": -1,
"urgency": "HIGH",
"ttl": "86400",
"data": "{\"type\": \"PayControl_v2\",\n\"userid\": \"%USER_ID%\",\"transactionid\": \"%TRANSACTION_ID%\"}"
},
"token": [
"%DEVICE_TOKEN%"
]
}
}
]
}
}
}
Settings for sending pushes to another application
By default, if app/bundle id, used to send push notifications, is not explicitly specified for the device, PCS 3.8 sends push to PC Classic app.
To send push notifications to another application, you need to:
- Make settings for the authentication data of the "other" mobile application in accordance with article above
- Register the app/bundle id of the required application in the PCS database(after executing the request, you need to restart Wildfly):
Example:
insert into pc_sys_property values (nextval('pc_setting_seq'), 'APP_ID_FOR_PUSHER', '{"Android":"com.example.mobile.app","iOS":"com.example.apple.app","Huawei":"com.example.apple.app"}');
Templates:
- PostgreSQL
insert into pc_sys_property values (nextval('pc_setting_seq'), 'APP_ID_FOR_PUSHER', '{"Android":"your_appid","iOS":"your_appid","Huawei":"your_appid"}');
- MS SQL
insert into pc_sys_property values (NEXT VALUE FOR PC_SETTING_SEQ, 'APP_ID_FOR_PUSHER', '{"Android":"your_appid","iOS":"your_appid","Huawei":"your_appid"}');
- Oracle
insert into pc_sys_property values (PC_SETTING_SEQ.NEXTVAL, 'APP_ID_FOR_PUSHER', '{"Android":"your_appid","iOS":"your_appid","Huawei":"your_appid"}');