diff --git a/CHANGELOG.md b/CHANGELOG.md index e222556..1bbdec6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/ios/NotificationService/NotificationService.swift b/ios/NotificationService/NotificationService.swift index ab236bd..f8e68be 100644 --- a/ios/NotificationService/NotificationService.swift +++ b/ios/NotificationService/NotificationService.swift @@ -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,57 +205,77 @@ 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]" - pushNotificationText = [ - .text: "hat eine Nachricht{inGroup} gesendet.", - .twonly: "hat ein twonly{inGroup} gesendet.", - .video: "hat ein Video{inGroup} gesendet.", - .image: "hat ein Bild{inGroup} gesendet.", - .audio: "hat eine Sprachnachricht{inGroup} gesendet.", - .contactRequest: "möchte sich mit dir vernetzen.", - .acceptRequest: "ist jetzt mit dir vernetzt.", - .storedMediaFile: "hat dein Bild gespeichert.", - .reaction: "hat auf dein Bild reagiert.", - .testNotification: "Das ist eine Testbenachrichtigung.", - .reopenedMedia: "hat dein Bild erneut geöffnet.", - .reactionToVideo: "hat mit {{content}} auf dein Video reagiert.", - .reactionToText: "hat mit {{content}} auf deinen Text reagiert.", - .reactionToImage: "hat mit {{content}} auf dein Bild reagiert.", - .reactionToAudio: "hat mit {{content}} auf deine Sprachnachricht reagiert.", - .response: "hat dir{inGroup} geantwortet.", - .addedToGroup: "hat dich zu \"{{content}}\" hinzugefügt.", - ] - } else { // Default to English - pushNotificationText = [ - .text: "sent a message{inGroup}.", - .twonly: "sent a twonly{inGroup}.", - .video: "sent a video{inGroup}.", - .image: "sent an image{inGroup}.", - .audio: "sent a voice message{inGroup}.", - .contactRequest: "wants to connect with you.", - .acceptRequest: "is now connected with you.", - .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}}\"", - ] + 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.", + .video: "hat ein Video{inGroup} gesendet.", + .image: "hat ein Bild{inGroup} gesendet.", + .audio: "hat eine Sprachnachricht{inGroup} gesendet.", + .contactRequest: "möchte sich mit dir vernetzen.", + .acceptRequest: "ist jetzt mit dir vernetzt.", + .storedMediaFile: "hat dein Bild gespeichert.", + .reaction: "hat auf dein Bild reagiert.", + .testNotification: "Das ist eine Testbenachrichtigung.", + .reopenedMedia: "hat dein Bild erneut geöffnet.", + .reactionToVideo: "hat mit {{content}} auf dein Video reagiert.", + .reactionToText: "hat mit {{content}} auf deinen Text reagiert.", + .reactionToImage: "hat mit {{content}} auf dein Bild reagiert.", + .reactionToAudio: "hat mit {{content}} auf deine Sprachnachricht reagiert.", + .response: "hat dir{inGroup} geantwortet.", + .addedToGroup: "hat dich zu \"{{content}}\" hinzugefügt.", + ] + } else { + pushNotificationText = [ + .contactRequest: "hast eine neue Kontaktanfrage erhalten.", + ] + } + } else { + if (userKnown) { + pushNotificationText = [ + .text: "sent a message{inGroup}.", + .twonly: "sent a twonly{inGroup}.", + .video: "sent a video{inGroup}.", + .image: "sent an image{inGroup}.", + .audio: "sent a voice message{inGroup}.", + .contactRequest: "wants to connect with you.", + .acceptRequest: "is now connected with you.", + .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] ?? "" + if (content == "") { + title = noTranslationFoundTitle + body = noTranslationFoundBody + } if pushNotification.hasAdditionalContent { content.replace("{{content}}", with: pushNotification.additionalContent) diff --git a/lib/src/localization/generated/app_localizations.dart b/lib/src/localization/generated/app_localizations.dart index 2a6f815..fb8ea1b 100644 --- a/lib/src/localization/generated/app_localizations.dart +++ b/lib/src/localization/generated/app_localizations.dart @@ -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. /// diff --git a/lib/src/localization/generated/app_localizations_de.dart b/lib/src/localization/generated/app_localizations_de.dart index c328e26..3a3c99a 100644 --- a/lib/src/localization/generated/app_localizations_de.dart +++ b/lib/src/localization/generated/app_localizations_de.dart @@ -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'; diff --git a/lib/src/localization/generated/app_localizations_en.dart b/lib/src/localization/generated/app_localizations_en.dart index 13f17c7..fecc2ac 100644 --- a/lib/src/localization/generated/app_localizations_en.dart +++ b/lib/src/localization/generated/app_localizations_en.dart @@ -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'; diff --git a/lib/src/localization/generated/app_localizations_sv.dart b/lib/src/localization/generated/app_localizations_sv.dart index 7b15afc..bcd7c52 100644 --- a/lib/src/localization/generated/app_localizations_sv.dart +++ b/lib/src/localization/generated/app_localizations_sv.dart @@ -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'; diff --git a/lib/src/services/notifications/background.notifications.dart b/lib/src/services/notifications/background.notifications.dart index 4c652d2..f7eaacc 100644 --- a/lib/src/services/notifications/background.notifications.dart +++ b/lib/src/services/notifications/background.notifications.dart @@ -99,9 +99,10 @@ Future 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 showLocalPushNotification( Future 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(