How to Use Proactive Suggestions for iOS 10

Continued from page 2.

Since iOS also recognizes that the user is looking at an address, it too provides location suggestions. For example, it might offer Yelp reviews or suggest a new Uber request to get to the restaurant. As for where the “intelligent” comes in, iOS 10 recognizes which car-sharing app the user uses more (Lyft versus Uber), or if the user isn’t a car-sharing user; depending on the results, iOS would intelligently assume that Sally wants normal turn-by-turn directions.

Integrate NSUserActivity into MapKit Apps

In MapKit-based apps, developers associate a point on a map with an activity state so that the point can be captured and reused elsewhere. Using the same NSUserActivity, restaurantActivity, we associate an MKMapItem to our activity:

restaurantActivity.mapItem = mapItem

The developer can opt for a more comprehensive approach by adopting app search:

let attributes = CSSearchableItemAttributeSet(itemContentType: "location")
attributes.namedLocation = "Apple Inc."
attributes.subThoroughfare = "1"
attributes.thoroughfare = "Infinite Loop" = "Cupertino"
attributes.stateOrProvince = "CA" = "United States"
attributes.latitude = 37.33072
attributes.longitude = -122.029674
attributes.phoneNumbers = ["(800) 275-2273"]
attributes.supportsPhoneCall = true
attributes.supportsNavigation = true

The second approach provides developers with a more comprehensive set of metadata which can be fully indexed. By setting information such as phone numbers and website addresses, it gives Sally more information about a location. For instance, setting attribute.phoneNumbers permits Siri to recognize when Sally says, “Call restaurant Lavash” or when she asks Siri to “Navigate to this location” by setting the latitude and longitude.

There are other types of CSSearchableItemAttributeSet properties a developer can opt for. Among them:

  • Documents, such as audiences, creator, or subject
  • Places, such as city or location
  • Events, such as due dates, completion dates, start dates, or important dates
  • Messages, such as phone calls, account handles, or email addresses

You can explore these types and more in Apple’s documentation.

Implement QuickType Suggestions

Back to our search for lunch, in which Sally is contemplating a restaurant listing on Yelp and asking friends for their opinions. (“Should we meet here? At what time?”) If she went from Yelp straight to the iOS messaging app, the operating system would inject proactive suggestions straight into the iMessage app. The QuickType suggestions make it easier for the user to share which restaurant she is looking at, without requiring her to copy-and-paste the address from Yelp into iMessage.

QuickType suggestions also takes advantage of Siri integration. So the restaurant entry within the user’s app could support the user saying, “Give me directions there,” whereupon Siri would contextually recognize that the user meant directions to that restaurant, and open up Apple Maps for directions to that location.

Location suggestions also work with other third-party apps, not just iOS system apps like Maps. Naturally, those third-party apps have to enable support.

Integrate with Contacts

Another enhancement to proactive suggestions is contact integrations. iOS suggests the user’s social handle by scouring through the various social media apps that the user uses, such as WhatsApp or Viber, and within the user’s contacts card, adds a suggestion for all the found social media handles, to be added to that card.

Be sure to read the next Search article: Bing Search API Tutorial