Automatically detect and copy verification codes from iMessage and SMS.
- 🔐 Automatic OTP detection from messages
- 📋 Auto-copy to clipboard
- ⌨️ Optional auto-paste
- 🔔 Desktop notifications
- 🎯 Global keyboard shortcut (⇧⌘E) to resync messages
- 🌐 Support for 145+ services
2FHey uses smart keyword-based detection to identify verification code messages. When a message contains words like "verification", "code", "OTP", "PIN", etc., it automatically:
- Extracts 4-8 digit codes (or alphanumeric codes)
- Identifies the service (Google, Apple, Bank, etc.)
- Copies the code to your clipboard
- Shows a notification overlay
- Optionally auto-pastes the code
The app automatically detects codes in various formats:
- Standard digits:
123456 - Spaced/dashed:
123-456or123 456 - Alphanumeric:
ABC123,X7Y9Z2 - Google format:
G-12345 - Chinese brackets:
【验证码123456】
- Download from 2fhey.com (via Gumroad)
- Move to Applications folder
- Launch and grant required permissions:
- Full Disk Access - to read Messages database
- Accessibility - for auto-paste and keyboard shortcuts
- ⇧⌘E (Shift + Command + E) - Resync messages and copy the latest OTP code to clipboard
- Useful if 2FHey missed a message or you need to retrieve a recent code again
- Can be disabled in Settings if it conflicts with other apps
If you use a service that isn't automatically recognized, you can add it to the known services list by creating a PR to update OTPParserConstants.knownServices in TwoFHey/OTPParser/OTPParserContants.swift.
2FHey supports OTP detection in multiple languages including English, French, Spanish, Portuguese, German, and Chinese. The language files are automatically updated from GitHub without requiring a new app release.
The app uses a three-tier loading strategy:
- First launch: Loads from bundled language files and custom patterns (immediate availability)
- Subsequent launches: Loads from cached files (fast)
- Background update: Fetches latest from GitHub on each app launch
Files are fetched from:
https://raw.githubusercontent.com/SoFriendly/2fhey/main/TwoFHey/OTPKeywords/{language}.json
https://raw.githubusercontent.com/SoFriendly/2fhey/main/TwoFHey/OTPKeywords/custom-patterns.json
To add support for a new language:
-
Create a new JSON file in
TwoFHey/OTPKeywords/with the following structure:{ "keywords": [ "code", "verification", "verify" ], "patterns": [ "code[\\s:]+([\\d\\s-]{4,8})", "verification[\\s:]+([\\d\\s-]{4,8})" ] } -
Add the filename to the
languageFilesarray inSimpleOTPParser.swift:22 -
Submit a pull request
-
All users will receive the new language support on their next app launch (no binary update required!)
For services with unique OTP formats (like Chase, Geico, etc.), you can add patterns to TwoFHey/OTPKeywords/custom-patterns.json:
{
"customPatterns": [
{
"service": "YourService",
"pattern": "YourService code: (\\d{6})"
}
]
}Pattern tips:
- Use capture groups
()to extract the code - First capture group will be used as the OTP code
- Service name is automatically associated with the pattern
- Patterns are checked first (highest priority)
Custom patterns are also updated remotely from GitHub on app launch.
Each language file contains:
-
keywords: An array of words that indicate an OTP message (e.g., "code", "verification", "vérification")
- All keywords from all languages are merged and checked together
- This allows detection of multilingual messages
-
patterns: An array of regex patterns for language-specific code extraction
- These are high-priority patterns like
"验证码:123456"or"code: 123456" - Pattern captures should extract just the numeric code in capture group 1
- Patterns are checked before generic digit extraction
- These are high-priority patterns like
Downloaded language files and custom patterns are cached at: ~/Library/Caches/OTPKeywords/
If GitHub is unreachable, the app automatically falls back to:
- Cached files from previous downloads
- Bundled files included in the app
Version 2.0+ uses a simplified keyword-based OTP parser (SimpleOTPParser.swift) instead of complex regex patterns. This makes the app more reliable and easier to maintain.
The old regex-based system (AppConfig.json and 130+ service patterns) has been deprecated in favor of smart detection that works with any service.