mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Better phone number parsing for SMS.
This commit is contained in:
parent
5e92fdbbbe
commit
cf4a126188
1 changed files with 3 additions and 5 deletions
|
@ -145,16 +145,14 @@
|
|||
- (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope
|
||||
{
|
||||
// search by contact name or number
|
||||
NSString *normalizedNumber = [PhoneNumberUtil normalizePhoneNumber:searchText];
|
||||
NSPredicate *resultPredicate = [NSPredicate predicateWithFormat:@"(fullName contains[c] %@) OR (allPhoneNumbers contains[c] %@)", searchText, normalizedNumber];
|
||||
NSPredicate *resultPredicate = [NSPredicate predicateWithFormat:@"(fullName contains[c] %@) OR (allPhoneNumbers contains[c] %@)", searchText, searchText];
|
||||
searchResults = [contacts filteredArrayUsingPredicate:resultPredicate];
|
||||
if (!searchResults.count && _searchController.searchBar.text.length == 0) searchResults = contacts;
|
||||
|
||||
// formats the user input into a pretty number to display
|
||||
NSString *formattedNumber = [PhoneNumber bestEffortFormatPartialUserSpecifiedTextToLookLikeAPhoneNumber:normalizedNumber];
|
||||
NSString *formattedNumber = [PhoneNumber tryParsePhoneNumberFromUserSpecifiedText:searchText].toE164;
|
||||
|
||||
// text to a non-signal number if we have no results and a valid phone #
|
||||
if (searchResults.count == 0 && normalizedNumber.length > 8) {
|
||||
if (searchResults.count == 0 && searchText.length > 8) {
|
||||
NSString *sendTextTo = @"Send SMS to: ";
|
||||
sendTextTo = [sendTextTo stringByAppendingString:formattedNumber];
|
||||
[sendTextButton setTitle:sendTextTo forState:UIControlStateNormal];
|
||||
|
|
Loading…
Reference in a new issue