Skip to content

Commit c574fb0

Browse files
committed
add support for logging to ntfy (nothing more than just dumping content in the HTTP body)
1 parent b686cb6 commit c574fb0

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

client/src/main/java/net/kzxiv/notify/client/NotificationService.java

+10
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ else if (res.getString(R.string.protocol_json).equals(protocol))
104104
payload = getPayloadJson(packageName, notification);
105105
else if (res.getString(R.string.protocol_gotify).equals(protocol))
106106
payload = getPayloadGotify(packageName, notification);
107+
else if (res.getString(R.string.protocol_ntfy).equals(protocol))
108+
payload = getPayloadNtfy(packageName, notification);
107109
else
108110
payload = null;
109111

@@ -321,4 +323,12 @@ private final Object[] getPayloadGotify(String packageName, Notification notific
321323
return new Object[] { "application/json", result.toString().getBytes() };
322324
}
323325

326+
private final Object[] getPayloadNtfy(String packageName, Notification notification)
327+
{
328+
final String title = notification.extras.getString(Notification.EXTRA_TITLE);
329+
final String message = notification.extras.getString(Notification.EXTRA_TEXT);
330+
331+
return new Object[] { "text/plain", String.format("%s: %s\n%s", packageName, title, message).getBytes() };
332+
}
333+
324334
}

client/src/main/res/values/strings.xml

+3
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@
1717
<string name="protocol_adtv">de.cyberdream.androidtv.notifications</string>
1818
<string name="protocol_json">json</string>
1919
<string name="protocol_gotify">gotify</string>
20+
<string name="protocol_ntfy">ntfy</string>
2021

2122
<string-array name="protocols">
2223
<item>Kodi</item>
2324
<item>Kodi (Addon)</item>
2425
<item>Notifications for Android TV</item>
2526
<item>JSON</item>
2627
<item>Gotify</item>
28+
<item>ntfy</item>
2729
</string-array>
2830

2931
<string-array name="protocol_names">
@@ -32,6 +34,7 @@
3234
<item>@string/protocol_adtv</item>
3335
<item>@string/protocol_json</item>
3436
<item>@string/protocol_gotify</item>
37+
<item>@string/protocol_ntfy</item>
3538
</string-array>
3639

3740
<string name="general">General</string>

0 commit comments

Comments
 (0)