mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-30 21:26:57 +02:00
Univeral links: Handle universal links clicked within the app
This commit is contained in:
@@ -1233,6 +1233,41 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)dataSource:(MXKDataSource *)dataSource shouldDoAction:(NSString *)actionIdentifier inCell:(id<MXKCellRendering>)cell userInfo:(NSDictionary *)userInfo defaultValue:(BOOL)defaultValue
|
||||
{
|
||||
BOOL shouldDoAction = defaultValue;
|
||||
|
||||
if ([actionIdentifier isEqualToString:kMXKRoomBubbleCellShouldInteractWithURL])
|
||||
{
|
||||
// Try to catch universal link supported by the app
|
||||
NSURL *url = userInfo[kMXKRoomBubbleCellUrl];
|
||||
|
||||
// Patch: iOS handles URL badly when there are several hash keys ('%23') in the link
|
||||
// And vector.im links have often several hash keys...
|
||||
if ([url.host isEqualToString:@"vector.im"])
|
||||
{
|
||||
// Replacing the first '%23' occurence into a '#' makes NSURL works correctly
|
||||
NSString *urlString = url.absoluteString;
|
||||
NSRange range = [urlString rangeOfString:@"%23"];
|
||||
if (NSNotFound != range.location)
|
||||
{
|
||||
urlString = [urlString stringByReplacingCharactersInRange:range withString:@"#"];
|
||||
url = [NSURL URLWithString:urlString];
|
||||
}
|
||||
|
||||
// If the link can be open it by the app, let it do
|
||||
if ([[AppDelegate theDelegate] isUniversalLink:url])
|
||||
{
|
||||
shouldDoAction = NO;
|
||||
|
||||
[[AppDelegate theDelegate] handleUniversalLinkFragment:url.fragment];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return shouldDoAction;
|
||||
}
|
||||
|
||||
- (void)cancelEventSelection
|
||||
{
|
||||
if (self.currentAlert)
|
||||
|
||||
Reference in New Issue
Block a user