PhsNotifications: Add support for updating already delivered notifications
parent
2d6125f6ef
commit
69136f7798
|
|
@ -122,11 +122,19 @@ void IntegrationPluginPushNotifications::executeAction(ThingActionInfo *info)
|
||||||
QString title = action.param(pushNotificationsNotifyActionTitleParamTypeId).value().toString();
|
QString title = action.param(pushNotificationsNotifyActionTitleParamTypeId).value().toString();
|
||||||
QString body = action.param(pushNotificationsNotifyActionBodyParamTypeId).value().toString();
|
QString body = action.param(pushNotificationsNotifyActionBodyParamTypeId).value().toString();
|
||||||
QString data = action.paramValue(pushNotificationsNotifyActionDataParamTypeId).toString();
|
QString data = action.paramValue(pushNotificationsNotifyActionDataParamTypeId).toString();
|
||||||
|
QString notificationId = action.paramValue(pushNotificationsNotifyActionNotificationIdParamTypeId).toString();
|
||||||
|
bool remove = action.paramValue(pushNotificationsNotifyActionRemoveParamTypeId).toBool();
|
||||||
|
bool sound = action.paramValue(pushNotificationsNotifyActionSoundParamTypeId).toBool();
|
||||||
|
|
||||||
if (pushService != "None" && token.isEmpty()) {
|
if (pushService != "None" && token.isEmpty()) {
|
||||||
return info->finish(Thing::ThingErrorAuthenticationFailure, QT_TR_NOOP("Push notifications need to be reconfigured."));
|
return info->finish(Thing::ThingErrorAuthenticationFailure, QT_TR_NOOP("Push notifications need to be reconfigured."));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (notificationId.isEmpty()) {
|
||||||
|
notificationId = QUuid::createUuid().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QVariantMap nymeaData;
|
QVariantMap nymeaData;
|
||||||
// FIXME: This is quite ugly but there isn't an API that allows to retrieve the server UUID yet
|
// FIXME: This is quite ugly but there isn't an API that allows to retrieve the server UUID yet
|
||||||
NymeaSettings settings(NymeaSettings::SettingsRoleGlobal);
|
NymeaSettings settings(NymeaSettings::SettingsRoleGlobal);
|
||||||
|
|
@ -157,31 +165,39 @@ void IntegrationPluginPushNotifications::executeAction(ThingActionInfo *info)
|
||||||
notification.insert("title", title);
|
notification.insert("title", title);
|
||||||
notification.insert("body", body);
|
notification.insert("body", body);
|
||||||
notification.insert("nymeaData", nymeaData);
|
notification.insert("nymeaData", nymeaData);
|
||||||
|
notification.insert("notificationId", notificationId);
|
||||||
|
notification.insert("remove", remove);
|
||||||
|
|
||||||
|
|
||||||
if (pushService == "FB-GCM") {
|
if (pushService == "FB-GCM") {
|
||||||
|
|
||||||
QVariantMap soundMap;
|
notification.insert("sound", sound);
|
||||||
soundMap.insert("sound", "default");
|
|
||||||
|
|
||||||
QVariantMap android;
|
QVariantMap android;
|
||||||
android.insert("priority", "high");
|
android.insert("priority", "high");
|
||||||
android.insert("notification", soundMap);
|
|
||||||
|
|
||||||
payload.insert("android", android);
|
payload.insert("android", android);
|
||||||
payload.insert("data", notification);
|
payload.insert("data", notification);
|
||||||
|
|
||||||
} else if (pushService == "FB-APNs") {
|
} else if (pushService == "FB-APNs") {
|
||||||
|
|
||||||
|
if (sound) {
|
||||||
notification.insert("sound", "default");
|
notification.insert("sound", "default");
|
||||||
|
}
|
||||||
|
|
||||||
QVariantMap headers;
|
QVariantMap headers;
|
||||||
headers.insert("apns-priority", "10");
|
headers.insert("apns-priority", sound ? "10" : "1");
|
||||||
|
headers.insert("apns-collapse-id", notificationId);
|
||||||
|
|
||||||
QVariantMap apns;
|
QVariantMap apns;
|
||||||
apns.insert("headers", headers);
|
apns.insert("headers", headers);
|
||||||
|
|
||||||
|
notification.insert("tag", notificationId);
|
||||||
|
|
||||||
payload.insert("notification", notification);
|
payload.insert("notification", notification);
|
||||||
payload.insert("apns", apns);
|
payload.insert("apns", apns);
|
||||||
|
|
||||||
|
payload.insert("collapse_key", notificationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -198,8 +214,8 @@ void IntegrationPluginPushNotifications::executeAction(ThingActionInfo *info)
|
||||||
|
|
||||||
QVariantMap notification;
|
QVariantMap notification;
|
||||||
notification.insert("card", card);
|
notification.insert("card", card);
|
||||||
notification.insert("vibrate", true);
|
notification.insert("vibrate", sound);
|
||||||
notification.insert("sound", true);
|
notification.insert("sound", sound);
|
||||||
notification.insert("nymeaData", nymeaData);
|
notification.insert("nymeaData", nymeaData);
|
||||||
|
|
||||||
QVariantMap data;
|
QVariantMap data;
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,27 @@
|
||||||
"inputType": "TextArea",
|
"inputType": "TextArea",
|
||||||
"defaultValue": ""
|
"defaultValue": ""
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "a961c428-c824-410a-b4e6-527a13c4c4ed",
|
||||||
|
"name": "notificationId",
|
||||||
|
"displayName": "Notification ID",
|
||||||
|
"type": "QString",
|
||||||
|
"defaultValue": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "0f3c3661-e0c0-46df-a6da-aaf3a0e8157c",
|
||||||
|
"name": "sound",
|
||||||
|
"displayName": "Play sound",
|
||||||
|
"type": "bool",
|
||||||
|
"defaultValue": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "92ffd4ff-4bb7-4261-a904-1ae3890704e0",
|
||||||
|
"name": "remove",
|
||||||
|
"displayName": "Remove",
|
||||||
|
"type": "bool",
|
||||||
|
"defaultValue": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "ca36a33f-a7f2-4f59-8767-3522ecaaf8fb",
|
"id": "ca36a33f-a7f2-4f59-8767-3522ecaaf8fb",
|
||||||
"name": "data",
|
"name": "data",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue