mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-03-03 15:06:46 +00:00
fix #383
This commit is contained in:
parent
b48df1baa5
commit
76c56b06fe
7 changed files with 112 additions and 59 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
## 0.0.89
|
## 0.0.89
|
||||||
|
|
||||||
|
- Adds link preview to images
|
||||||
- Adds option to manual focus in the camera
|
- Adds option to manual focus in the camera
|
||||||
- Adds support to switch between front and back cameras during video recording
|
- Adds support to switch between front and back cameras during video recording
|
||||||
- Adds basic face filters
|
- Adds basic face filters
|
||||||
|
|
|
||||||
|
|
@ -109,10 +109,10 @@ func getPushNotificationData(pushData: String) -> (
|
||||||
} else if pushUser != nil {
|
} else if pushUser != nil {
|
||||||
return (
|
return (
|
||||||
pushUser!.displayName,
|
pushUser!.displayName,
|
||||||
getPushNotificationText(pushNotification: pushNotification).0, pushUser!.userID
|
getPushNotificationText(pushNotification: pushNotification, true).0, pushUser!.userID
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
let content = getPushNotificationText(pushNotification: pushNotification)
|
let content = getPushNotificationText(pushNotification: pushNotification, false)
|
||||||
return (
|
return (
|
||||||
content.1, content.0, 1
|
content.1, content.0, 1
|
||||||
)
|
)
|
||||||
|
|
@ -205,57 +205,77 @@ func readFromKeychain(key: String) -> String? {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getPushNotificationText(pushNotification: PushNotification) -> (String, String) {
|
func getPushNotificationText(pushNotification: PushNotification, userKnown: bool) -> (String, String) {
|
||||||
let systemLanguage = Locale.current.language.languageCode?.identifier ?? "en" // Get the current system language
|
let systemLanguage = Locale.current.language.languageCode?.identifier ?? "en" // Get the current system language
|
||||||
|
|
||||||
var pushNotificationText: [PushKind: String] = [:]
|
var pushNotificationText: [PushKind: String] = [:]
|
||||||
var title = "[Unknown]"
|
var title = "You"
|
||||||
|
var noTranslationFoundTitle = "You have a new message."
|
||||||
|
var noTranslationFoundBody = "Open twonly to learn more."
|
||||||
|
|
||||||
// Define the messages based on the system language
|
// Define the messages based on the system language
|
||||||
if systemLanguage.contains("de") { // German
|
if systemLanguage.contains("de") { // German
|
||||||
title = "[Unbekannt]"
|
title = "Du"
|
||||||
pushNotificationText = [
|
noTranslationFoundTitle = "Du hast eine neue Nachricht."
|
||||||
.text: "hat eine Nachricht{inGroup} gesendet.",
|
noTranslationFoundBody = "Öffne twonly um mehr zu erfahren."
|
||||||
.twonly: "hat ein twonly{inGroup} gesendet.",
|
if (userKnown) {
|
||||||
.video: "hat ein Video{inGroup} gesendet.",
|
pushNotificationText = [
|
||||||
.image: "hat ein Bild{inGroup} gesendet.",
|
.text: "hat eine Nachricht{inGroup} gesendet.",
|
||||||
.audio: "hat eine Sprachnachricht{inGroup} gesendet.",
|
.twonly: "hat ein twonly{inGroup} gesendet.",
|
||||||
.contactRequest: "möchte sich mit dir vernetzen.",
|
.video: "hat ein Video{inGroup} gesendet.",
|
||||||
.acceptRequest: "ist jetzt mit dir vernetzt.",
|
.image: "hat ein Bild{inGroup} gesendet.",
|
||||||
.storedMediaFile: "hat dein Bild gespeichert.",
|
.audio: "hat eine Sprachnachricht{inGroup} gesendet.",
|
||||||
.reaction: "hat auf dein Bild reagiert.",
|
.contactRequest: "möchte sich mit dir vernetzen.",
|
||||||
.testNotification: "Das ist eine Testbenachrichtigung.",
|
.acceptRequest: "ist jetzt mit dir vernetzt.",
|
||||||
.reopenedMedia: "hat dein Bild erneut geöffnet.",
|
.storedMediaFile: "hat dein Bild gespeichert.",
|
||||||
.reactionToVideo: "hat mit {{content}} auf dein Video reagiert.",
|
.reaction: "hat auf dein Bild reagiert.",
|
||||||
.reactionToText: "hat mit {{content}} auf deinen Text reagiert.",
|
.testNotification: "Das ist eine Testbenachrichtigung.",
|
||||||
.reactionToImage: "hat mit {{content}} auf dein Bild reagiert.",
|
.reopenedMedia: "hat dein Bild erneut geöffnet.",
|
||||||
.reactionToAudio: "hat mit {{content}} auf deine Sprachnachricht reagiert.",
|
.reactionToVideo: "hat mit {{content}} auf dein Video reagiert.",
|
||||||
.response: "hat dir{inGroup} geantwortet.",
|
.reactionToText: "hat mit {{content}} auf deinen Text reagiert.",
|
||||||
.addedToGroup: "hat dich zu \"{{content}}\" hinzugefügt.",
|
.reactionToImage: "hat mit {{content}} auf dein Bild reagiert.",
|
||||||
]
|
.reactionToAudio: "hat mit {{content}} auf deine Sprachnachricht reagiert.",
|
||||||
} else { // Default to English
|
.response: "hat dir{inGroup} geantwortet.",
|
||||||
pushNotificationText = [
|
.addedToGroup: "hat dich zu \"{{content}}\" hinzugefügt.",
|
||||||
.text: "sent a message{inGroup}.",
|
]
|
||||||
.twonly: "sent a twonly{inGroup}.",
|
} else {
|
||||||
.video: "sent a video{inGroup}.",
|
pushNotificationText = [
|
||||||
.image: "sent an image{inGroup}.",
|
.contactRequest: "hast eine neue Kontaktanfrage erhalten.",
|
||||||
.audio: "sent a voice message{inGroup}.",
|
]
|
||||||
.contactRequest: "wants to connect with you.",
|
}
|
||||||
.acceptRequest: "is now connected with you.",
|
} else {
|
||||||
.storedMediaFile: "has stored your image.",
|
if (userKnown) {
|
||||||
.reaction: "has reacted to your image.",
|
pushNotificationText = [
|
||||||
.testNotification: "This is a test notification.",
|
.text: "sent a message{inGroup}.",
|
||||||
.reopenedMedia: "has reopened your image.",
|
.twonly: "sent a twonly{inGroup}.",
|
||||||
.reactionToVideo: "has reacted with {{content}} to your video.",
|
.video: "sent a video{inGroup}.",
|
||||||
.reactionToText: "has reacted with {{content}} to your text.",
|
.image: "sent an image{inGroup}.",
|
||||||
.reactionToImage: "has reacted with {{content}} to your image.",
|
.audio: "sent a voice message{inGroup}.",
|
||||||
.reactionToAudio: "has reacted with {{content}} to your voice message.",
|
.contactRequest: "wants to connect with you.",
|
||||||
.response: "has responded{inGroup}.",
|
.acceptRequest: "is now connected with you.",
|
||||||
.addedToGroup: "has added you to \"{{content}}\"",
|
.storedMediaFile: "has stored your image.",
|
||||||
]
|
.reaction: "has reacted to your image.",
|
||||||
|
.testNotification: "This is a test notification.",
|
||||||
|
.reopenedMedia: "has reopened your image.",
|
||||||
|
.reactionToVideo: "has reacted with {{content}} to your video.",
|
||||||
|
.reactionToText: "has reacted with {{content}} to your text.",
|
||||||
|
.reactionToImage: "has reacted with {{content}} to your image.",
|
||||||
|
.reactionToAudio: "has reacted with {{content}} to your voice message.",
|
||||||
|
.response: "has responded{inGroup}.",
|
||||||
|
.addedToGroup: "has added you to \"{{content}}\"",
|
||||||
|
]
|
||||||
|
} else {
|
||||||
|
pushNotificationText = [
|
||||||
|
.contactRequest: "have received a new contact request.",
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var content = pushNotificationText[pushNotification.kind] ?? ""
|
var content = pushNotificationText[pushNotification.kind] ?? ""
|
||||||
|
if (content == "") {
|
||||||
|
title = noTranslationFoundTitle
|
||||||
|
body = noTranslationFoundBody
|
||||||
|
}
|
||||||
|
|
||||||
if pushNotification.hasAdditionalContent {
|
if pushNotification.hasAdditionalContent {
|
||||||
content.replace("{{content}}", with: pushNotification.additionalContent)
|
content.replace("{{content}}", with: pushNotification.additionalContent)
|
||||||
|
|
|
||||||
|
|
@ -2518,6 +2518,12 @@ abstract class AppLocalizations {
|
||||||
/// **'wants to connect with you.'**
|
/// **'wants to connect with you.'**
|
||||||
String get notificationContactRequest;
|
String get notificationContactRequest;
|
||||||
|
|
||||||
|
/// No description provided for @notificationContactRequestUnknownUser.
|
||||||
|
///
|
||||||
|
/// In en, this message translates to:
|
||||||
|
/// **'have received a new contact request.'**
|
||||||
|
String get notificationContactRequestUnknownUser;
|
||||||
|
|
||||||
/// No description provided for @notificationAcceptRequest.
|
/// No description provided for @notificationAcceptRequest.
|
||||||
///
|
///
|
||||||
/// In en, this message translates to:
|
/// In en, this message translates to:
|
||||||
|
|
@ -2572,11 +2578,17 @@ abstract class AppLocalizations {
|
||||||
/// **'has responded{inGroup}.'**
|
/// **'has responded{inGroup}.'**
|
||||||
String notificationResponse(Object inGroup);
|
String notificationResponse(Object inGroup);
|
||||||
|
|
||||||
/// No description provided for @notificationTitleUnknownUser.
|
/// No description provided for @notificationTitleUnknown.
|
||||||
///
|
///
|
||||||
/// In en, this message translates to:
|
/// In en, this message translates to:
|
||||||
/// **'[Unknown]'**
|
/// **'You have a new message.'**
|
||||||
String get notificationTitleUnknownUser;
|
String get notificationTitleUnknown;
|
||||||
|
|
||||||
|
/// No description provided for @notificationBodyUnknown.
|
||||||
|
///
|
||||||
|
/// In en, this message translates to:
|
||||||
|
/// **'Open twonly to learn more.'**
|
||||||
|
String get notificationBodyUnknown;
|
||||||
|
|
||||||
/// No description provided for @notificationCategoryMessageTitle.
|
/// No description provided for @notificationCategoryMessageTitle.
|
||||||
///
|
///
|
||||||
|
|
|
||||||
|
|
@ -1380,6 +1380,10 @@ class AppLocalizationsDe extends AppLocalizations {
|
||||||
@override
|
@override
|
||||||
String get notificationContactRequest => 'möchte sich mit dir vernetzen.';
|
String get notificationContactRequest => 'möchte sich mit dir vernetzen.';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get notificationContactRequestUnknownUser =>
|
||||||
|
'hast eine neue Kontaktanfrage erhalten.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get notificationAcceptRequest => 'ist jetzt mit dir vernetzt.';
|
String get notificationAcceptRequest => 'ist jetzt mit dir vernetzt.';
|
||||||
|
|
||||||
|
|
@ -1418,7 +1422,10 @@ class AppLocalizationsDe extends AppLocalizations {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get notificationTitleUnknownUser => '[Unbekannt]';
|
String get notificationTitleUnknown => 'Du hast eine neue Nachricht.';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get notificationBodyUnknown => 'Öffne twonly um mehr zu erfahren.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get notificationCategoryMessageTitle => 'Nachrichten';
|
String get notificationCategoryMessageTitle => 'Nachrichten';
|
||||||
|
|
|
||||||
|
|
@ -1372,6 +1372,10 @@ class AppLocalizationsEn extends AppLocalizations {
|
||||||
@override
|
@override
|
||||||
String get notificationContactRequest => 'wants to connect with you.';
|
String get notificationContactRequest => 'wants to connect with you.';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get notificationContactRequestUnknownUser =>
|
||||||
|
'have received a new contact request.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get notificationAcceptRequest => 'is now connected with you.';
|
String get notificationAcceptRequest => 'is now connected with you.';
|
||||||
|
|
||||||
|
|
@ -1410,7 +1414,10 @@ class AppLocalizationsEn extends AppLocalizations {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get notificationTitleUnknownUser => '[Unknown]';
|
String get notificationTitleUnknown => 'You have a new message.';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get notificationBodyUnknown => 'Open twonly to learn more.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get notificationCategoryMessageTitle => 'Messages';
|
String get notificationCategoryMessageTitle => 'Messages';
|
||||||
|
|
|
||||||
|
|
@ -1372,6 +1372,10 @@ class AppLocalizationsSv extends AppLocalizations {
|
||||||
@override
|
@override
|
||||||
String get notificationContactRequest => 'wants to connect with you.';
|
String get notificationContactRequest => 'wants to connect with you.';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get notificationContactRequestUnknownUser =>
|
||||||
|
'have received a new contact request.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get notificationAcceptRequest => 'is now connected with you.';
|
String get notificationAcceptRequest => 'is now connected with you.';
|
||||||
|
|
||||||
|
|
@ -1410,7 +1414,10 @@ class AppLocalizationsSv extends AppLocalizations {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get notificationTitleUnknownUser => '[Unknown]';
|
String get notificationTitleUnknown => 'You have a new message.';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get notificationBodyUnknown => 'Open twonly to learn more.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get notificationCategoryMessageTitle => 'Messages';
|
String get notificationCategoryMessageTitle => 'Messages';
|
||||||
|
|
|
||||||
|
|
@ -99,9 +99,10 @@ Future<void> handlePushData(String pushDataB64) async {
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Log.error(e);
|
Log.error(e);
|
||||||
|
final lang = getLocalizations();
|
||||||
await customLocalPushNotification(
|
await customLocalPushNotification(
|
||||||
'Du hast eine neue Nachricht.',
|
lang.notificationTitleUnknown,
|
||||||
'Öffne twonly um mehr zu erfahren.',
|
lang.notificationBodyUnknown,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -186,16 +187,14 @@ Future<void> showLocalPushNotification(
|
||||||
Future<void> showLocalPushNotificationWithoutUserId(
|
Future<void> showLocalPushNotificationWithoutUserId(
|
||||||
PushNotification pushNotification,
|
PushNotification pushNotification,
|
||||||
) async {
|
) async {
|
||||||
String? body;
|
|
||||||
|
|
||||||
body = getPushNotificationText(pushNotification);
|
|
||||||
|
|
||||||
final lang = getLocalizations();
|
final lang = getLocalizations();
|
||||||
|
|
||||||
final title = lang.notificationTitleUnknownUser;
|
var title = lang.notificationTitleUnknown;
|
||||||
|
var body = lang.notificationBodyUnknown;
|
||||||
|
|
||||||
if (body == '') {
|
if (pushNotification.kind == PushKind.contactRequest) {
|
||||||
Log.error('No push notification type defined!');
|
title = lang.you;
|
||||||
|
body = lang.notificationContactRequestUnknownUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
final androidNotificationDetails = AndroidNotificationDetails(
|
final androidNotificationDetails = AndroidNotificationDetails(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue