I am developing a CarPlay app, that has been approved for EV Charging entitlement. Could you please confirm if the given entitlement supports CPSearchTemplate template as there is some confusion here.
I tried using the template by referring to the below link, https://developer.apple.com/documentation/carplay/cpsearchtemplate
Here is the snippet,
class SearchCPView: UIResponder, CPSearchTemplateDelegate {
var searchTemplate: CPSearchTemplate = CPSearchTemplate()
override init() {
super.init()
searchTemplate.delegate = self
}
func getSearchTemplate(interfaceController: CPInterfaceController?) -> CPGridTemplate {
let searchGridButton = CPGridButton(titleVariants: [CarplayButtonTitles.search], image: UIImage(named: ImagesConstants.CarPlay.searchGrid) ?? UIImage(), handler: {[self] _ in
guard let controller = interfaceController else { return }
controller.pushTemplate(self.searchTemplate, animated: true) { status, error in
print(status)
}
})
let gridTemplate = CPGridTemplate(title: "", gridButtons: [searchGridButton])
return gridTemplate
}
func searchTemplate(_ searchTemplate: CPSearchTemplate, selectedResult item: CPListItem) async {
print(item)
}
func searchTemplate(_ searchTemplate: CPSearchTemplate, updatedSearchText searchText: String) async -> [CPListItem] {
print(searchText)
return [CPListItem(text: "", detailText: "")]
}
}
On push, I am getting an exception, *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unsupported object <CPSearchTemplate: 0x30056df00> <identifier: 28, userInfo: (null), tabTitle: (null), tabImage: (null), showsTabBadge: 0> passed to pushTemplate:animated:completion:. Allowed classes: {( CPTabBarTemplate, CPActionSheetTemplate, CPAlertTemplate, CPGridTemplate, CPPointOfInterestTemplate, CPInformationTemplate, CPContactTemplate, CPListTemplate )}'
No, the charging entitlement does not allow usage of CPSearchTemplate
. Please see the table with the list of supported templates by entitlement, on page 15 of the developer guide: https://developer.apple.com/carplay/documentation/CarPlay-App-Programming-Guide.pdf