Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement core architecture to handle push notifications (APNs, UnifiedPush) #1237

Merged
merged 21 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
2dd7981
initial refactor to allow for push notifications
hjiangsu Mar 23, 2024
9a9ce07
temp
hjiangsu Mar 25, 2024
a121168
Merge branch 'develop' of github.com:thunder-app/thunder into feature…
hjiangsu Mar 25, 2024
12d29a6
used fix version of push
hjiangsu Mar 25, 2024
8e4ddcc
improved logic for android notifications
hjiangsu Mar 26, 2024
15440bc
adjusted settings logic, added notification type to setting
hjiangsu Mar 26, 2024
7cca3f2
Merge branch 'develop' of github.com:thunder-app/thunder into feature…
hjiangsu Mar 26, 2024
0a6418b
moved notifications to separate subdirectory, added stubs for connect…
hjiangsu Mar 27, 2024
ddf3a46
Merge branch 'develop' of https://github.com/thunder-app/thunder into…
hjiangsu Apr 18, 2024
6b8d985
code cleanup
hjiangsu Apr 18, 2024
57544d7
added more logic to handle push notifications
hjiangsu Apr 19, 2024
f615f03
refactored notifications, moved notification logic to its own directory
hjiangsu Apr 20, 2024
c84e920
moved notification_type enum
hjiangsu Apr 20, 2024
83c4970
fixed localization sorting
hjiangsu Apr 20, 2024
d790902
reverted pubspec.lock
hjiangsu Apr 20, 2024
0f4c663
added setting to change notification server
hjiangsu Apr 20, 2024
34893f1
cleaned up logic, added additional comments
hjiangsu Apr 22, 2024
65dee87
add softwrap option to picker item
hjiangsu Apr 23, 2024
6f8f622
disable push notification server option when not using apns/unified p…
hjiangsu Apr 23, 2024
79f02ce
fixed issue where empty notification groups were being shown
hjiangsu Apr 23, 2024
f8190f7
revert back background task config
hjiangsu Apr 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ PODS:
- Flutter
- pointer_interceptor_ios (0.0.1):
- Flutter
- push_ios (0.0.1):
- Flutter
- share_plus (0.0.1):
- Flutter
- shared_preferences_foundation (0.0.1):
Expand Down Expand Up @@ -79,6 +81,7 @@ DEPENDENCIES:
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
- pointer_interceptor_ios (from `.symlinks/plugins/pointer_interceptor_ios/ios`)
- push_ios (from `.symlinks/plugins/push_ios/ios`)
- share_plus (from `.symlinks/plugins/share_plus/ios`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
- sqflite (from `.symlinks/plugins/sqflite/darwin`)
Expand Down Expand Up @@ -124,6 +127,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/permission_handler_apple/ios"
pointer_interceptor_ios:
:path: ".symlinks/plugins/pointer_interceptor_ios/ios"
push_ios:
:path: ".symlinks/plugins/push_ios/ios"
share_plus:
:path: ".symlinks/plugins/share_plus/ios"
shared_preferences_foundation:
Expand Down Expand Up @@ -156,6 +161,7 @@ SPEC CHECKSUMS:
path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2
pointer_interceptor_ios: 9280618c0b2eeb80081a343924aa8ad756c21375
push_ios: 2bd1b4d3f782209da1f571db1250af236957e807
share_plus: 8875f4f2500512ea181eef553c3e27dba5135aad
shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695
sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec
Expand Down
8 changes: 8 additions & 0 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
CF3F7AD7E4C59A30FCCF598C /* Pods-Runner.debug-development.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug-development.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug-development.xcconfig"; sourceTree = "<group>"; };
D2C3376210191F1E2A497D1B /* Pods-RunnerTests.debug-production.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug-production.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug-production.xcconfig"; sourceTree = "<group>"; };
D41A83512BAF667A004F5C45 /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = "<group>"; };
D458C5672B0D6F7D0090D826 /* Open In Thunder.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = "Open In Thunder.appex"; sourceTree = BUILT_PRODUCTS_DIR; };
D458C5692B0D6F7D0090D826 /* SafariWebExtensionHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SafariWebExtensionHandler.swift; sourceTree = "<group>"; };
D458C56C2B0D6F7D0090D826 /* _locales */ = {isa = PBXFileReference; lastKnownFileType = folder; path = _locales; sourceTree = "<group>"; };
Expand Down Expand Up @@ -195,6 +196,7 @@
97C146F01CF9000F007C117D /* Runner */ = {
isa = PBXGroup;
children = (
D41A83512BAF667A004F5C45 /* Runner.entitlements */,
97C146FA1CF9000F007C117D /* Main.storyboard */,
97C146FD1CF9000F007C117D /* Assets.xcassets */,
97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
Expand Down Expand Up @@ -628,6 +630,7 @@
APP_DISPLAY_NAME = Thunder;
ASSETCATALOG_COMPILER_APPICON_NAME = "AppIcon-production";
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = L7P596HY6P;
ENABLE_BITCODE = NO;
Expand Down Expand Up @@ -815,6 +818,7 @@
APP_DISPLAY_NAME = Thunder;
ASSETCATALOG_COMPILER_APPICON_NAME = "AppIcon-production";
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = L7P596HY6P;
ENABLE_BITCODE = NO;
Expand All @@ -840,6 +844,7 @@
APP_DISPLAY_NAME = Thunder;
ASSETCATALOG_COMPILER_APPICON_NAME = "AppIcon-production";
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = L7P596HY6P;
ENABLE_BITCODE = NO;
Expand Down Expand Up @@ -919,6 +924,7 @@
APP_DISPLAY_NAME = Thunder;
ASSETCATALOG_COMPILER_APPICON_NAME = "AppIcon-development";
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = L7P596HY6P;
ENABLE_BITCODE = NO;
Expand Down Expand Up @@ -1060,6 +1066,7 @@
APP_DISPLAY_NAME = Thunder;
ASSETCATALOG_COMPILER_APPICON_NAME = "AppIcon-development";
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = L7P596HY6P;
ENABLE_BITCODE = NO;
Expand Down Expand Up @@ -1193,6 +1200,7 @@
APP_DISPLAY_NAME = Thunder;
ASSETCATALOG_COMPILER_APPICON_NAME = "AppIcon-development";
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = L7P596HY6P;
ENABLE_BITCODE = NO;
Expand Down
8 changes: 8 additions & 0 deletions ios/Runner/Runner.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>aps-environment</key>
<string>development</string>
</dict>
</plist>
7 changes: 4 additions & 3 deletions lib/core/enums/local_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ enum LocalSettings {
showUpdateChangelogs(name: 'setting_show_update_changelogs', key: 'showUpdateChangelogs', category: LocalSettingsCategories.general, subCategory: LocalSettingsSubCategories.notifications),
scoreCounters(name: 'setting_score_counters', key: "showScoreCounters", category: LocalSettingsCategories.general, subCategory: LocalSettingsSubCategories.feed),
appLanguageCode(name: 'setting_app_language_code', key: 'appLanguage', category: LocalSettingsCategories.general, subCategory: LocalSettingsSubCategories.feedTypeAndSorts),
enableInboxNotifications(
name: 'setting_enable_inbox_notifications', key: 'enableInboxNotifications', category: LocalSettingsCategories.general, subCategory: LocalSettingsSubCategories.notifications),
inboxNotificationType(name: 'setting_inbox_notification_type', key: 'inboxNotificationType', category: LocalSettingsCategories.general, subCategory: LocalSettingsSubCategories.notifications),
pushNotificationServer(name: 'setting_push_notification_server', key: 'pushNotificationServer', category: LocalSettingsCategories.general, subCategory: LocalSettingsSubCategories.notifications),

/// -------------------------- Feed Post Related Settings --------------------------
// Compact Related Settings
Expand Down Expand Up @@ -323,7 +323,8 @@ extension LocalizationExt on AppLocalizations {
'markPostAsReadOnScroll': markPostAsReadOnScroll,
'showInAppUpdateNotifications': showInAppUpdateNotifications,
'showUpdateChangelogs': showUpdateChangelogs,
'enableInboxNotifications': enableInboxNotifications,
'inboxNotificationType': enableInboxNotifications,
'pushNotificationServer': pushNotificationServer,
'showScoreCounters': showScoreCounters,
'appLanguage': appLanguage,
'compactView': compactView,
Expand Down
76 changes: 74 additions & 2 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@
"@appearance": {
"description": "Title of Appearance in Settings -> Appearance"
},
"applePushNotificationService": "Apple Push Notification Service",
"@applePushNotificationService": {
"description": "Describes the notification type for Apple Push Notification Service"
},
"applied": "Applied",
"@applied": {},
"apply": "Apply",
Expand Down Expand Up @@ -499,6 +503,14 @@
"@disable": {
"description": "Action for disabling something"
},
"disablePushNotifications": "Disable Push Notifications",
"@disablePushNotifications": {
"description": "Description when disabling push notifications"
},
"disabled": "Disabled",
"@disabled": {
"description": "Describes the state of something that is disabled"
},
"discussionLanguages": "Discussion Languages",
"@discussionLanguages": {
"description": "Only load posts and communities in your language(s)"
Expand Down Expand Up @@ -563,7 +575,7 @@
"@enableFloatingButtonOnPosts": {
"description": "Setting for enable floating button on posts"
},
"enableInboxNotifications": "Enable Inbox Notifications (Experimental)",
"enableInboxNotifications": "Enable Inbox Notifications",
"@enableInboxNotifications": {
"description": "Setting name for inbox notifications"
},
Expand Down Expand Up @@ -617,10 +629,18 @@
},
"failedToBlock": "Failed to block: {errorMessage}",
"@failedToBlock": {},
"failedToDisablePushNotifications": "Failed to disable push notifications",
"@failedToDisablePushNotifications": {
"description": "Error message when failed to disable push notifications."
},
"failedToLoadBlocks": "Could not load blocks: {errorMessage}",
"@failedToLoadBlocks": {},
"failedToUnblock": "Could not unblock: {errorMessage}",
"@failedToUnblock": {},
"failedToUpdateNotificationSettings": "Failed to update notification settings",
"@failedToUpdateNotificationSettings": {
"description": "Error message when failed to update notification settings."
},
"favorites": "Favorites",
"@favorites": {
"description": "The favorited communities on the drawer"
Expand Down Expand Up @@ -861,6 +881,10 @@
"@loadMoreSingular": {},
"local": "Local",
"@local": {},
"localNotifications": "Local Notifications",
"@localNotifications": {
"description": "Describes the notification type for Local Notifications"
},
"localPosts": "Local Posts",
"@localPosts": {},
"lockPost": "Lock Post",
Expand Down Expand Up @@ -1059,6 +1083,10 @@
"@noUserBlocks": {},
"noUsersFound": "No users found.",
"@noUsersFound": {},
"none": "None",
"@none": {
"description": "Describes the notification type when push notifications are disabled"
},
"normal": "Normal",
"@normal": {
"description": "Normal name thickness/weight"
Expand All @@ -1081,7 +1109,7 @@
"@notificationsNotAllowed": {
"description": "Description for when notifications are now allowed for app"
},
"notificationsWarningDialog": "Notifications are an experimental feature which may not function correctly on all devices.\n\n· Checks will occur every ~15 minutes and will consume additional battery.\n\n· Disable battery optimizations for a higher likelihood of successful notifications.\n\nSee the following page for more information.",
"notificationsWarningDialog": "Notifications are an **experimental feature** which may not function correctly on all devices.\n\n - Checks will occur every ~15 minutes and will consume additional battery.\n\n - Disable battery optimizations for a higher likelihood of successful notifications.\n\n See the following page for more information.",
"@notificationsWarningDialog": {
"description": "The content of the warning dialog for the notifications feature"
},
Expand Down Expand Up @@ -1253,6 +1281,22 @@
"@purgedPost": {
"description": "Short decription for moderator action to purge a post"
},
"pushNotification": "Push Notifications",
"@pushNotification": {
"description": "Setting for push notifications"
},
"pushNotificationDescription": "If enabled, Thunder will send your JWT token(s) to the server in order to poll for new notifications. \n\n **NOTE:** This will not take effect until the next time the app is launched.",
"@pushNotificationDescription": {
"description": "Description of push notification setting"
},
"pushNotificationServer": "Push Notification Server",
"@pushNotificationServer": {
"description": "Setting for choosing push notification server"
},
"pushNotificationServerDescription": "Configure the push notification server. The server must be properly configured to send push notifications to your device.\n\n **Only enter a server that you trust with your credentials.**",
"@pushNotificationServerDescription": {
"description": "Description of choosing push notification server setting"
},
"reachedTheBottom": "Hmmm. It seems like you've reached the bottom.",
"@reachedTheBottom": {},
"readAll": "Read All",
Expand Down Expand Up @@ -1875,6 +1919,10 @@
"@unhidCommunity": {
"description": "Short decription for moderator action to unhide a community"
},
"unifiedPushNotifications": "Unified Push Notifications",
"@unifiedPushNotifications": {
"description": "Describes the notification type for Unified Push Notifications"
},
"unlockPost": "Unlock Post",
"@unlockPost": {
"description": "Action for unlocking a post (moderator action)"
Expand Down Expand Up @@ -1927,10 +1975,26 @@
"@useAdvancedShareSheet": {
"description": "Toggle to use advanced share sheet."
},
"useApplePushNotifications": "Use APNs Notifications",
"@useApplePushNotifications": {
"description": "Toggle to use APNs."
},
"useApplePushNotificationsDescription": "Uses Apple's Push Notification service",
"@useApplePushNotificationsDescription": {
"description": "Subtitle of the setting for using APNs"
},
"useCompactView": "Enable for small posts, disable for big.",
"@useCompactView": {
"description": "Option to enable or disable compact view for small posts."
},
"useLocalNotifications": "Use Local Notifications (Experimental)",
"@useLocalNotifications": {
"description": "Toggle to use local notifications."
},
"useLocalNotificationsDescription": "Periodically checks for notifications in the background",
"@useLocalNotificationsDescription": {
"description": "Subtitle of the setting for using local notifications"
},
"useMaterialYouTheme": "Use Material You Theme",
"@useMaterialYouTheme": {
"description": "Toggle to use Material You theme."
Expand All @@ -1941,6 +2005,14 @@
},
"useSuggestedTitle": "Use suggested title: {title}",
"@useSuggestedTitle": {},
"useUnifiedPushNotifications": "Use UnifiedPush Notifications",
"@useUnifiedPushNotifications": {
"description": "Toggle to use UnifiedPush Notifications"
},
"useUnifiedPushNotificationsDescription": "Requires a compatible app",
"@useUnifiedPushNotificationsDescription": {
"description": "Subtitle of the setting for using UnifiedPush Notifications"
},
"user": "User",
"@user": {
"description": "Role name for user"
Expand Down
Loading
Loading