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

Add INSendMessageIntent NSUserActivity support to the main App #4863

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions Riot/Generated/InfoPlist.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ internal enum InfoPlist {
internal static let nsMicrophoneUsageDescription: String = _document["NSMicrophoneUsageDescription"]
internal static let nsPhotoLibraryUsageDescription: String = _document["NSPhotoLibraryUsageDescription"]
internal static let nsSiriUsageDescription: String = _document["NSSiriUsageDescription"]
internal static let nsUserActivityTypes: [String] = _document["NSUserActivityTypes"]
internal static let uiBackgroundModes: [String] = _document["UIBackgroundModes"]
internal static let uiLaunchStoryboardName: String = _document["UILaunchStoryboardName"]
internal static let uiRequiredDeviceCapabilities: [String] = _document["UIRequiredDeviceCapabilities"]
Expand Down
20 changes: 20 additions & 0 deletions Riot/Modules/Application/LegacyAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,26 @@ - (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserAct
{
continueUserActivity = [self handleUniversalLink:userActivity];
}
else if ([userActivity.activityType isEqualToString:INSendMessageIntentIdentifier])
{
INInteraction *interaction = userActivity.interaction;
if (interaction && [interaction.intent isKindOfClass:[INSendMessageIntent class]])
{
INSendMessageIntent *intent = (INSendMessageIntent *)(interaction.intent);
INPerson *person = intent.recipients.firstObject;
if (person && person.customIdentifier) {
NSString *identifier = person.customIdentifier;

[self startDirectChatWithUserId:identifier completion:NULL];
// TODO: initialize text if from a siri shortcut
continueUserActivity = YES;
} else {
MXLogWarning(@"A recipient was missing in the INSendMessageIntent");
}
} else {
MXLogWarning(@"How can an INSendMessageIntent activity not have an INSendMessageIntent?");
}
}
else if ([userActivity.activityType isEqualToString:INStartAudioCallIntentIdentifier] ||
[userActivity.activityType isEqualToString:INStartVideoCallIntentIdentifier])
{
Expand Down
6 changes: 6 additions & 0 deletions Riot/SupportingFiles/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@
<string>The photo library is used to send photos and videos.</string>
<key>NSSiriUsageDescription</key>
<string>Siri is used to perform calls even from the lock screen.</string>
<key>NSUserActivityTypes</key>
<array>
<string>INSendMessageIntent</string>
<string>INStartAudioCallIntent</string>
<string>INStartVideoCallIntent</string>
</array>
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
Expand Down
Loading