diff --git a/src/ios.m b/src/ios.m index be5479df..10e93adc 100644 --- a/src/ios.m +++ b/src/ios.m @@ -199,9 +199,12 @@ static void _start_initial_load(WKWebView* web_view) return YES; } -- (BOOL)application:(UIApplication*)application continueUserActivity:(NSUserActivity*)activity restorationHandler:(void (^)(NSArray>*))restorationHandler +- (BOOL)application:(UIApplication*)application + continueUserActivity:(NSUserActivity*)activity + restorationHandler:(void (^)(NSArray>*))restorationHandler { - if ([activity.activityType isEqual:CSSearchableItemActionType]) { + if ([activity.activityType isEqual:CSSearchableItemActionType]) + { const char* identifier = [[activity.userInfo valueForKey:CSSearchableItemActivityIdentifier] UTF8String]; tf_printf("Jumping to search result: %s.\n", identifier); @@ -210,7 +213,9 @@ static void _start_initial_load(WKWebView* web_view) tf_printf("Navigating to %s.", url); ViewController* view_controller = (ViewController*)self.window.rootViewController; [view_controller.web_view loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithUTF8String:url]]]]; - } else { + } + else + { tf_printf("no search\n"); } return NO; @@ -223,11 +228,15 @@ void tf_notify_message_added_ios(const char* identifier, const char* title, cons CSSearchableItemAttributeSet* attribute_set = [[CSSearchableItemAttributeSet alloc] initWithContentType:UTTypeText]; attribute_set.title = [NSString stringWithUTF8String:content]; attribute_set.contentDescription = [NSString stringWithUTF8String:title]; - CSSearchableItem* item = [[CSSearchableItem alloc] initWithUniqueIdentifier:[NSString stringWithUTF8String:identifier] domainIdentifier:@"com.unprompted.tildefriends.messages" attributeSet:attribute_set]; - [[CSSearchableIndex defaultSearchableIndex] indexSearchableItems:@[item] completionHandler:^(NSError* _Nullable error) { - if (error) { + CSSearchableItem* item = [[CSSearchableItem alloc] initWithUniqueIdentifier:[NSString stringWithUTF8String:identifier] domainIdentifier:@"com.unprompted.tildefriends.messages" + attributeSet:attribute_set]; + [[CSSearchableIndex defaultSearchableIndex] indexSearchableItems:@[ item ] completionHandler:^(NSError* _Nullable error) { + if (error) + { tf_printf("indexing error: %s.\n", [error.localizedDescription UTF8String]); - } else { + } + else + { tf_printf("indexed successfully.\n"); } }];