diff --git a/Signal.xcodeproj/project.pbxproj b/Signal.xcodeproj/project.pbxproj index 4c8592d5349..663cacfb698 100644 --- a/Signal.xcodeproj/project.pbxproj +++ b/Signal.xcodeproj/project.pbxproj @@ -8,6 +8,7 @@ /* Begin PBXBuildFile section */ 06289300DC49EDEA6FEC730C /* Pods_SignalPerformanceTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C61A9604F0FC0D258C8CE27F /* Pods_SignalPerformanceTests.framework */; }; + 0634FE5625C71E3100D6E5EE /* SendMessage.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = 0634FE5525C71E3100D6E5EE /* SendMessage.intentdefinition */; }; 2AE2882E4C2B96BFFF9EE27C /* Pods_SignalShareExtension.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0F94C85CB0B235DA37F68ED0 /* Pods_SignalShareExtension.framework */; }; 3236FCC42592B67B006D33B9 /* NameCollisionReviewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3236FCC32592B67B006D33B9 /* NameCollisionReviewCell.swift */; }; 323C4FE524EE7B0F00DC94B8 /* LinkPreviewsMegaphone.swift in Sources */ = {isa = PBXBuildFile; fileRef = 323C4FE424EE7B0F00DC94B8 /* LinkPreviewsMegaphone.swift */; }; @@ -959,6 +960,7 @@ /* Begin PBXFileReference section */ 02CD38E58B58A689DCF037AD /* Pods-SignalTests.app store release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SignalTests.app store release.xcconfig"; path = "Pods/Target Support Files/Pods-SignalTests/Pods-SignalTests.app store release.xcconfig"; sourceTree = ""; }; + 0634FE5525C71E3100D6E5EE /* SendMessage.intentdefinition */ = {isa = PBXFileReference; lastKnownFileType = file.intentdefinition; path = SendMessage.intentdefinition; sourceTree = ""; }; 0F94C85CB0B235DA37F68ED0 /* Pods_SignalShareExtension.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SignalShareExtension.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 10AE4264D3E52937D8964A86 /* Pods-SignalMessaging.profiling.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SignalMessaging.profiling.xcconfig"; path = "Pods/Target Support Files/Pods-SignalMessaging/Pods-SignalMessaging.profiling.xcconfig"; sourceTree = ""; }; 1BC279B87E730B066A5AFB2A /* Pods-SignalPerformanceTests.app store release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SignalPerformanceTests.app store release.xcconfig"; path = "Pods/Target Support Files/Pods-SignalPerformanceTests/Pods-SignalPerformanceTests.app store release.xcconfig"; sourceTree = ""; }; @@ -3253,6 +3255,7 @@ 45CD81A41DBFF8CF004C9430 /* Storyboards */, 450DF2061E0DD28D003D14BE /* UserInterface */, 76EB04C818170B33006006FC /* util */, + 0634FE5525C71E3100D6E5EE /* SendMessage.intentdefinition */, ); path = src; sourceTree = ""; @@ -5274,6 +5277,7 @@ 340FC8AB204DAC8D007AEB0F /* DomainFrontingCountryViewController.m in Sources */, 88C659B024688335002AC115 /* SelfSignedIdentity.swift in Sources */, 347C3857252E1E2300F3D941 /* CVComponentThreadDetails.swift in Sources */, + 0634FE5625C71E3100D6E5EE /* SendMessage.intentdefinition in Sources */, 347C3846252CE6C900F3D941 /* CVComponentSenderName.swift in Sources */, 4C586926224FAB83003FD070 /* AVAudioSession+OWS.m in Sources */, 3470C8772555883600F5847C /* CVLoadRequest.swift in Sources */, diff --git a/Signal/Signal-Info.plist b/Signal/Signal-Info.plist index fbcf8b970ac..73eb826bce1 100644 --- a/Signal/Signal-Info.plist +++ b/Signal/Signal-Info.plist @@ -137,6 +137,10 @@ Signal will save photos to your library. NSPhotoLibraryUsageDescription Signal will let you choose which photos from your library to send. + NSUserActivityTypes + + SendMessageIntent + PHPhotoLibraryPreventAutomaticLimitedAccessAlert UIAppFonts diff --git a/Signal/src/AppDelegate.m b/Signal/src/AppDelegate.m index b99e783e10a..788bd789a0a 100644 --- a/Signal/src/AppDelegate.m +++ b/Signal/src/AppDelegate.m @@ -43,6 +43,7 @@ #import #import #import +#import NSString *const AppDelegateStoryboardMain = @"Main"; @@ -891,6 +892,30 @@ - (BOOL)application:(UIApplication *)application return NO; } return [self tryToOpenUrl:userActivity.webpageURL]; + } else if ([userActivity.activityType isEqualToString:@"SendMessageIntent"]) { + OWSLogWarn(@"Executing intent %@", userActivity.activityType); + + SendMessageIntent *intent = (SendMessageIntent *) userActivity.interaction.intent; + + NSString *text = intent.message; + MessageBody *testMessageBody = [[MessageBody alloc] initWithText:text + ranges:MessageBodyRanges.empty]; + NSString *number = [intent.recipient stringByReplacingOccurrencesOfString:@" " withString:@""]; + OWSLogInfo(@"SendMessageIntent parameters: number %@ text %@", number, text); + + + [self.databaseStorage uiReadWithBlock:^(SDSAnyReadTransaction *transaction) { + TSThread *thread = [AnyContactThreadFinder.alloc contactThreadForPhoneNumber:number transaction:transaction]; + OWSLogInfo(@"Sending message %@ to recipient %@", text, thread.recipientAddresses[0]); + TSOutgoingMessage *message = [ThreadUtil enqueueMessageWithBody:testMessageBody + thread:thread + quotedReplyModel:Nil + linkPreviewDraft:Nil + transaction:transaction]; + }]; + + // Send message in background + return NO; } else { OWSLogWarn(@"userActivity: %@, but not yet supported.", userActivity.activityType); } diff --git a/Signal/src/SendMessage.intentdefinition b/Signal/src/SendMessage.intentdefinition new file mode 100644 index 00000000000..39dbbbff3ab --- /dev/null +++ b/Signal/src/SendMessage.intentdefinition @@ -0,0 +1,184 @@ + + + + + INEnums + + INIntentDefinitionModelVersion + 1.2 + INIntentDefinitionNamespace + tpoGz5 + INIntentDefinitionSystemVersion + 19E287 + INIntentDefinitionToolsBuildVersion + 12D4e + INIntentDefinitionToolsVersion + 12.4 + INIntents + + + INIntentCategory + share + INIntentConfigurable + + INIntentDescription + Send Message to the target recipient + INIntentDescriptionID + hnvUAa + INIntentInput + message + INIntentLastParameterTag + 6 + INIntentManagedParameterCombinations + + recipient,message + + INIntentParameterCombinationSupportsBackgroundExecution + + INIntentParameterCombinationTitle + Send Message + INIntentParameterCombinationTitleID + 0uDpUD + INIntentParameterCombinationUpdatesLinked + + + + INIntentName + SendMessage + INIntentParameterCombinations + + recipient,message + + INIntentParameterCombinationIsLinked + + INIntentParameterCombinationSupportsBackgroundExecution + + INIntentParameterCombinationTitle + Send Message + INIntentParameterCombinationTitleID + puTSVI + + + INIntentParameters + + + INIntentParameterConfigurable + + INIntentParameterDisplayName + Message + INIntentParameterDisplayNameID + kj79D0 + INIntentParameterDisplayPriority + 1 + INIntentParameterMetadata + + INIntentParameterMetadataCapitalization + Sentences + INIntentParameterMetadataDefaultValueID + 9W8SwT + INIntentParameterMetadataMultiline + + + INIntentParameterName + message + INIntentParameterPromptDialogs + + + INIntentParameterPromptDialogCustom + + INIntentParameterPromptDialogType + Configuration + + + INIntentParameterPromptDialogCustom + + INIntentParameterPromptDialogFormatString + What would you like to say? + INIntentParameterPromptDialogFormatStringID + wcKuBY + INIntentParameterPromptDialogType + Primary + + + INIntentParameterSupportsResolution + + INIntentParameterTag + 2 + INIntentParameterType + String + + + INIntentParameterConfigurable + + INIntentParameterDisplayName + Recipient Phone Number + INIntentParameterDisplayNameID + qEjt8p + INIntentParameterDisplayPriority + 2 + INIntentParameterMetadata + + INIntentParameterMetadataCapitalization + Sentences + INIntentParameterMetadataDefaultValueID + t6y1rx + + INIntentParameterName + recipient + INIntentParameterPromptDialogs + + + INIntentParameterPromptDialogCustom + + INIntentParameterPromptDialogType + Configuration + + + INIntentParameterPromptDialogCustom + + INIntentParameterPromptDialogFormatString + Where to send the message? + INIntentParameterPromptDialogFormatStringID + bOj4Uz + INIntentParameterPromptDialogType + Primary + + + INIntentParameterSupportsResolution + + INIntentParameterTag + 6 + INIntentParameterType + String + + + INIntentResponse + + INIntentResponseCodes + + + INIntentResponseCodeName + success + INIntentResponseCodeSuccess + + + + INIntentResponseCodeName + failure + + + + INIntentTitle + Send Message + INIntentTitleID + lxktYH + INIntentType + Custom + INIntentVerb + Send + + + INTypes + + +