I'm trying to break through focus mode in my app that receives VOIP notifications. I've added a particular contact to the "allowlist" for a particular focus mode. When I receive a call from my app, I create an INStartCallIntent.
To create the INPerson, I use an INPersonHandle with the value being the identifier that I fetch from the contact. There are also 2 other identifier fields in INPerson that are both nullable (contactIdentifier and customIdentifier). I've also tried populating those with the fetched contact's identifier.
Here's my general prototyped code (yes I know this is all hard coded, but it's just a prototype for now).
INPersonHandle *handle = [[INPersonHandle alloc] initWithValue:identifier type:INPersonHandleTypeUnknown];
INPerson *caller = [[INPerson alloc] initWithPersonHandle:handle
nameComponents:nameComponents
displayName:name
image:nil
contactIdentifier:identifier
customIdentifier:nil
isContactSuggestion:NO
suggestionType:INPersonSuggestionTypeSocialProfile];
NSDate *_Nonnull dateCreated = [NSDate date];
INCallRecord *const callRecord = [[INCallRecord alloc] initWithIdentifier:callId
dateCreated:dateCreated
callRecordType:INCallRecordTypeRinging
callCapability:callCapability
callDuration:nil
unseen:nil
participants:@[caller]
numberOfCalls:@(1)
isCallerIdBlocked:nil];
INStartCallIntent *const intent = [[INStartCallIntent alloc] initWithCallRecordFilter:nil
callRecordToCallBack:callRecord
audioRoute:INCallAudioRouteSpeakerphoneAudioRoute
destinationType:INCallDestinationTypeNormal
contacts:@[caller]
callCapability:callCapability];
// Donate the interaction to Siri
INInteraction *const interaction = [[INInteraction alloc] initWithIntent:intent response:nil];
interaction.direction = INInteractionDirectionIncoming;
[interaction donateInteractionWithCompletion:nil];
Nothing I've tried yet has been able to break through focus mode and I think it's because the identifiers aren't matching up. Apple seems to have a clear way to match contacts for email address and phone number identifiers, but it's unclear how they match based on an unknown type for the INPersonHandleType.