Contents

init(personHandle:nameComponents:displayName:image:contactIdentifier:customIdentifier:isMe:suggestionType:)

Creates a person that includes required metadata for messaging intents.

Declaration

convenience init(personHandle: INPersonHandle, nameComponents: PersonNameComponents?, displayName: String?, image: INImage?, contactIdentifier: String?, customIdentifier: String?, isMe: Bool, suggestionType: INPersonSuggestionType)

Parameters

  • personHandle:

    A string that contains information your app uses to identify the user. You can create a person handle from an email address, phone number, or account name associated with the user.

  • nameComponents:

    The name of the user, specified as a set of name components.

  • displayName:

    The string you display for the user’s name.

  • image:

    An image of the person.

  • contactIdentifier:

    The identifier associated with the user’s Cncontact object. Specify a value for this parameter when the user has a corresponding entry in the Contacts database.

  • customIdentifier:

    A custom string that you use to identify people in your app.

  • isMe:

    A Boolean value that indicates whether the person is the current device user.

  • suggestionType:

    The contact information to surface in interactions involving the user. Use this property to identify a user by their social media account name or instant messaging address, instead of by their actual name.

Return Value

An initialized person object or nil if initialization fails.

Discussion

It’s important to set isMe when using Messaging intents. For example, if the message sender for an outgoing message is also the user of the device, set isMe to true. Similarly, when creating the recipient array for an incoming message — which includes the current user of the device — set isMe to true for the person in the recipient list that is the current device user, and set isMe to false for all other recipients.

You can also use this method to suggest how you want to identify the person when your app donates interactions to the system. For example, you might ask the system to identify the user by their social media account name instead of by their actual name.

Use this method when creating person objects you plan to return as part of a response to Siri. Specify as much information as possible about the user. This method makes copies of the parameters instead of keeping the originals.

See Also

Creating a person