Bark is an iOS push notification tool app that allows users to send custom push notifications to their devices via HTTP requests. It leverages Apple Push Notification service (APNs) and supports advanced iOS notification features like grouping, custom icons/sounds, time-sensitive notifications, critical alerts, and end-to-end encryption.
# Install CocoaPods dependencies
pod install
# Always work with the workspace, not the project
# Open: Bark.xcworkspace# Run tests via fastlane
bundle exec fastlane tests
# Run tests via xcodebuild
xcodebuild test -workspace Bark.xcworkspace -scheme Bark# Build the app
xcodebuild -workspace Bark.xcworkspace -scheme Bark build
# Build for TestFlight (requires proper certificates and environment variables)
bundle exec fastlane betaMain App Target (Bark/)
- Entry point:
AppDelegate.swift- handles app lifecycle, APNs registration, Realm setup AppDelegate+Realm.swift- Realm database initialization and migration logic- Realm schema version: 17 (see
RealmConfiguration.swift)
Notification Extensions
-
NotificationServiceExtension/- UNNotificationServiceExtension that processes incoming notificationsNotificationService.swift- orchestrates notification processing through a pipeline of processorsProcessor/directory contains specialized processors that run sequentially:CiphertextProcessor- decrypts encrypted push content (must run first)MarkdownProcessor- renders markdown in notification bodyLevelProcessor- handles notification levels (active/timeSensitive/passive/critical)BadgeProcessor- manages app badge countAutoCopyProcessor- auto-copies content to clipboardArchiveProcessor- saves message to Realm databaseMuteProcessor- handles group mutingCallProcessor- plays repeating sound for 30 secondsSoundUrlProcessor- downloads a sound from thesoundUrlparameter (e.g. TTS clip) and uses it as the notification soundImageProcessor- downloads and attaches imagesIconProcessor- sets custom notification icon (iOS 15+, runs last as it may timeout)
-
notificationContentExtension/- custom notification UINotificationViewController.swift- displays custom content in notification
Model/ - Data models
Message.swift- Realm object for stored notifications (properties: title, subtitle, body, bodyType, url, image, group, createDate)MessageItemModel.swift- view model for message displayAlgorithm.swift- encryption/decryption algorithms for end-to-end encryption
Controller/ - View controllers using MVVM pattern
- Suffix
ViewControllerfor views,ViewModelfor view models - Key screens:
HomeViewController+HomeViewModel- main screen showing tutorial and test URLMessageListViewController+MessageListViewModel- notification history grouped by date/groupServerListViewController+ServerListViewModel- manage multiple push serversCryptoSettingController+CryptoSettingViewModel- configure encryption keysSoundsViewController+SoundsViewModel- manage custom notification sounds
View/ - Reusable UI components
- Custom cells, buttons, text views
View/MessageList/- specialized views for message display with markdown support
Common/ - Shared utilities and managers
Client.swift- singleton managing app state, device token, current tab navigationServerManager.swift- manages multiple push servers (default: https://api.day.app)BarkSettings.swift- UserDefaults wrapper for persistent settings using DefaultsKitRealmConfiguration.swift- shared Realm configuration between app and extensionsMoya/- Network layer using Moya + RxSwiftBarkApi.swift- API endpoints (ping, register)BarkTargetType.swift- base target typeObservable+Extension.swift- Rx helpers
- RxSwift/RxCocoa - Reactive programming for data binding and async operations
- Realm - Local database for message persistence (shared between app and extensions via App Groups)
- Moya - Network abstraction layer over Alamofire
- Material/SnapKit - UI framework and Auto Layout DSL
- CryptoSwift - Encryption for secure push notifications
- Kingfisher - Image downloading and caching
- Device Registration: App requests APNs token → sends to server via
/registerendpoint → server stores device token with user's key - Receiving Push: Server sends push → APNs delivers to device →
NotificationServiceExtensionprocesses through processor pipeline → notification displayed - Message Storage:
ArchiveProcessorsaves to Realm → Darwin notification sent to main app → main app refreshes message list - Encryption Flow: If ciphertext parameter present →
CiphertextProcessordecrypts using locally stored key → continues normal processing
The app uses App Groups to share data between the main app and notification extensions:
- Realm database at shared Documents directory
- Settings via
BarkSettings(DefaultsKit) - Darwin notifications for cross-process communication (e.g., "com.bark.newmessage")
Users can configure multiple push servers (ServerManager):
- Default server:
https://api.day.app - Each server has: id, address, key, optional name
- Old single-server data (pre-v1.2.6) is automatically migrated to new multi-server format
Order matters - processors run sequentially in NotificationService.swift:
- Ciphertext decryption (must be first - may contain all push data)
- Content processing (markdown, level, badge, autoCopy)
- Database archiving
- Mute checking
- Sound effects (call mode)
- Media attachments (image, icon - icon last as it may timeout)
- Always open
Bark.xcworkspace, neverBark.xcproject - Minimum iOS deployment target: 15.0
- Realm schema migrations are handled in
RealmConfiguration.swift- incrementschemaVersionwhen changing Message model - The app supports both iPhone and iPad (with split view controller on iPad)
- Localization is managed via
Localizable.xcstrings - Custom notification sounds are in
Sounds/directory - Code signing is disabled for Pods (see Podfile post_install)
- Do not use simulators for testing. If simulator testing is absolutely necessary, you must obtain my approval beforehand.
Tests are located in BarkTests/ directory. The CI runs tests on every push to master via GitHub Actions (.github/workflows/tests.yaml).