mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-03-03 15:26:47 +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
|
||||
|
||||
- Adds link preview to images
|
||||
- Adds option to manual focus in the camera
|
||||
- Adds support to switch between front and back cameras during video recording
|
||||
- Adds basic face filters
|
||||
|
|
|
|||
|
|
@ -109,10 +109,10 @@ func getPushNotificationData(pushData: String) -> (
|
|||
} else if pushUser != nil {
|
||||
return (
|
||||
pushUser!.displayName,
|
||||
getPushNotificationText(pushNotification: pushNotification).0, pushUser!.userID
|
||||
getPushNotificationText(pushNotification: pushNotification, true).0, pushUser!.userID
|
||||
)
|
||||
} else {
|
||||
let content = getPushNotificationText(pushNotification: pushNotification)
|
||||
let content = getPushNotificationText(pushNotification: pushNotification, false)
|
||||
return (
|
||||
content.1, content.0, 1
|
||||
)
|
||||
|
|
@ -205,15 +205,20 @@ func readFromKeychain(key: String) -> String? {
|
|||
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
|
||||
|
||||
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
|
||||
if systemLanguage.contains("de") { // German
|
||||
title = "[Unbekannt]"
|
||||
title = "Du"
|
||||
noTranslationFoundTitle = "Du hast eine neue Nachricht."
|
||||
noTranslationFoundBody = "Öffne twonly um mehr zu erfahren."
|
||||
if (userKnown) {
|
||||
pushNotificationText = [
|
||||
.text: "hat eine Nachricht{inGroup} gesendet.",
|
||||
.twonly: "hat ein twonly{inGroup} gesendet.",
|
||||
|
|
@ -233,7 +238,13 @@ func getPushNotificationText(pushNotification: PushNotification) -> (String, Str
|
|||
.response: "hat dir{inGroup} geantwortet.",
|
||||
.addedToGroup: "hat dich zu \"{{content}}\" hinzugefügt.",
|
||||
]
|
||||
} else { // Default to English
|
||||
} else {
|
||||
pushNotificationText = [
|
||||
.contactRequest: "hast eine neue Kontaktanfrage erhalten.",
|
||||
]
|
||||
}
|
||||
} else {
|
||||
if (userKnown) {
|
||||
pushNotificationText = [
|
||||
.text: "sent a message{inGroup}.",
|
||||
.twonly: "sent a twonly{inGroup}.",
|
||||
|
|
@ -253,9 +264,18 @@ func getPushNotificationText(pushNotification: PushNotification) -> (String, Str
|
|||
.response: "has responded{inGroup}.",
|
||||
.addedToGroup: "has added you to \"{{content}}\"",
|
||||
]
|
||||
} else {
|
||||
pushNotificationText = [
|
||||
.contactRequest: "have received a new contact request.",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
var content = pushNotificationText[pushNotification.kind] ?? ""
|
||||
if (content == "") {
|
||||
title = noTranslationFoundTitle
|
||||
body = noTranslationFoundBody
|
||||
}
|
||||
|
||||
if pushNotification.hasAdditionalContent {
|
||||
content.replace("{{content}}", with: pushNotification.additionalContent)
|
||||
|
|
|
|||
|
|
@ -2518,6 +2518,12 @@ abstract class AppLocalizations {
|
|||
/// **'wants to connect with you.'**
|
||||
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.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
|
|
@ -2572,11 +2578,17 @@ abstract class AppLocalizations {
|
|||
/// **'has responded{inGroup}.'**
|
||||
String notificationResponse(Object inGroup);
|
||||
|
||||
/// No description provided for @notificationTitleUnknownUser.
|
||||
/// No description provided for @notificationTitleUnknown.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'[Unknown]'**
|
||||
String get notificationTitleUnknownUser;
|
||||
/// **'You have a new message.'**
|
||||
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.
|
||||
///
|
||||
|
|
|
|||
|
|
@ -1380,6 +1380,10 @@ class AppLocalizationsDe extends AppLocalizations {
|
|||
@override
|
||||
String get notificationContactRequest => 'möchte sich mit dir vernetzen.';
|
||||
|
||||
@override
|
||||
String get notificationContactRequestUnknownUser =>
|
||||
'hast eine neue Kontaktanfrage erhalten.';
|
||||
|
||||
@override
|
||||
String get notificationAcceptRequest => 'ist jetzt mit dir vernetzt.';
|
||||
|
||||
|
|
@ -1418,7 +1422,10 @@ class AppLocalizationsDe extends AppLocalizations {
|
|||
}
|
||||
|
||||
@override
|
||||
String get notificationTitleUnknownUser => '[Unbekannt]';
|
||||
String get notificationTitleUnknown => 'Du hast eine neue Nachricht.';
|
||||
|
||||
@override
|
||||
String get notificationBodyUnknown => 'Öffne twonly um mehr zu erfahren.';
|
||||
|
||||
@override
|
||||
String get notificationCategoryMessageTitle => 'Nachrichten';
|
||||
|
|
|
|||
|
|
@ -1372,6 +1372,10 @@ class AppLocalizationsEn extends AppLocalizations {
|
|||
@override
|
||||
String get notificationContactRequest => 'wants to connect with you.';
|
||||
|
||||
@override
|
||||
String get notificationContactRequestUnknownUser =>
|
||||
'have received a new contact request.';
|
||||
|
||||
@override
|
||||
String get notificationAcceptRequest => 'is now connected with you.';
|
||||
|
||||
|
|
@ -1410,7 +1414,10 @@ class AppLocalizationsEn extends AppLocalizations {
|
|||
}
|
||||
|
||||
@override
|
||||
String get notificationTitleUnknownUser => '[Unknown]';
|
||||
String get notificationTitleUnknown => 'You have a new message.';
|
||||
|
||||
@override
|
||||
String get notificationBodyUnknown => 'Open twonly to learn more.';
|
||||
|
||||
@override
|
||||
String get notificationCategoryMessageTitle => 'Messages';
|
||||
|
|
|
|||
|
|
@ -1372,6 +1372,10 @@ class AppLocalizationsSv extends AppLocalizations {
|
|||
@override
|
||||
String get notificationContactRequest => 'wants to connect with you.';
|
||||
|
||||
@override
|
||||
String get notificationContactRequestUnknownUser =>
|
||||
'have received a new contact request.';
|
||||
|
||||
@override
|
||||
String get notificationAcceptRequest => 'is now connected with you.';
|
||||
|
||||
|
|
@ -1410,7 +1414,10 @@ class AppLocalizationsSv extends AppLocalizations {
|
|||
}
|
||||
|
||||
@override
|
||||
String get notificationTitleUnknownUser => '[Unknown]';
|
||||
String get notificationTitleUnknown => 'You have a new message.';
|
||||
|
||||
@override
|
||||
String get notificationBodyUnknown => 'Open twonly to learn more.';
|
||||
|
||||
@override
|
||||
String get notificationCategoryMessageTitle => 'Messages';
|
||||
|
|
|
|||
|
|
@ -99,9 +99,10 @@ Future<void> handlePushData(String pushDataB64) async {
|
|||
}
|
||||
} catch (e) {
|
||||
Log.error(e);
|
||||
final lang = getLocalizations();
|
||||
await customLocalPushNotification(
|
||||
'Du hast eine neue Nachricht.',
|
||||
'Öffne twonly um mehr zu erfahren.',
|
||||
lang.notificationTitleUnknown,
|
||||
lang.notificationBodyUnknown,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -186,16 +187,14 @@ Future<void> showLocalPushNotification(
|
|||
Future<void> showLocalPushNotificationWithoutUserId(
|
||||
PushNotification pushNotification,
|
||||
) async {
|
||||
String? body;
|
||||
|
||||
body = getPushNotificationText(pushNotification);
|
||||
|
||||
final lang = getLocalizations();
|
||||
|
||||
final title = lang.notificationTitleUnknownUser;
|
||||
var title = lang.notificationTitleUnknown;
|
||||
var body = lang.notificationBodyUnknown;
|
||||
|
||||
if (body == '') {
|
||||
Log.error('No push notification type defined!');
|
||||
if (pushNotification.kind == PushKind.contactRequest) {
|
||||
title = lang.you;
|
||||
body = lang.notificationContactRequestUnknownUser;
|
||||
}
|
||||
|
||||
final androidNotificationDetails = AndroidNotificationDetails(
|
||||
|
|
|
|||
Loading…
Reference in a new issue