We have a companion app to our Web App that we are about to distribute. My question is this:
Our customers sign up and pay for an annual subscription for our services (travel planning service) via our website. They can then access and use the services via our site, but we are also planning to add a free companion app that ties into CarPlay (although approved) as well as full functionality of our web app.
From what I've read in the Distribution Manual, it seems as though I can release this as a free app and still take payment via our primary web app according to section:
3.1.3(f) Free Stand-alone Apps: Free apps acting as a stand-alone companion to a paid web based tool (e.g. VoIP, Cloud Storage, Email Services, Web Hosting) do not need to use in-app purchase, provided there is no purchasing inside the app, or calls to action for purchase outside of the app.
My question is, am I reading this correctly?
Post
Replies
Boosts
Views
Activity
Hello, I'm somewhat new to CarPlay integration and am having an issue. I have ready through Apple's CarPlay Programming Guide, reviewed their code samples and have exhausted my searches online to help find a solution to my problem.
I have been unable to get a basic map to display on my CarPlay map utilizing the following:
import CarPlay
class CarPlaySceneDelegate: UIResponder, CPTemplateApplicationSceneDelegate {
var interfaceController: CPInterfaceController?
var window: CPWindow?
func templateApplicationScene(_ templateApplicationScene: CPTemplateApplicationScene, didConnect interfaceController: CPInterfaceController) {
self.interfaceController = interfaceController
let mapTemplate = CPMapTemplate()
mapTemplate.mapDelegate = self
interfaceController.setRootTemplate(mapTemplate, animated: true, completion: { success, error in
if let error = error {
debugPrint("Error: \(error)")
} else {
print("CarPlay Map Should Be Displayed")
}
})
let trip = CPTrip(origin: MKMapItem(placemark: .init(coordinate: CLLocationCoordinate2D(latitude: 0.0, longitude: 0.0))), destination: MKMapItem(placemark: .init(coordinate: CLLocationCoordinate2D(latitude: 0.0, longitude: 0.0))), routeChoices: [])
mapTemplate.startNavigationSession(for: trip)
}
}
extension CarPlaySceneDelegate: CPMapTemplateDelegate {
func mapTemplate(_ mapTemplate: CPMapTemplate, panWith direction: CPMapTemplate.PanDirection) {
// Handle panning
}
func mapTemplate(_ mapTemplate: CPMapTemplate, startedTrip trip: CPTrip, using routeChoice: CPRouteChoice) {
// Handle trip start
}
}
I have my CarPlay Entitlements setup, I have my CarPlay Navigation App set in my signing and capabilities and my app icon displays properly on CarPlay (both in simulator and inside of my vehicle). However, as mentioned I only get a white screen.
Now, if I utilize the following code, I will get my map to display, however I lose functionality such as panning the map. I'm sure that I am missing something simple on the above example and appreciate any guidance that you may have.
func createMapTemplate(destination: TripDetails?, destinationBL: BucketListItems?, route: MKRoute, window: UIWindow) -> CPMapTemplate {
mapTemplate = CPMapTemplate()
mapTemplate.mapDelegate = self
trip = nil
let startLocation = CLLocation(latitude: location.coordinate.latitude, longitude: location.coordinate.longitude)
let startMapItem = MKMapItem(placemark: MKPlacemark(coordinate: startLocation.coordinate))
startMapItem.name = "Starting Location"
let endMapItem = MKMapItem(placemark: MKPlacemark(coordinate: route.polyline.points()[route.polyline.pointCount - 1].coordinate))
endMapItem.name = destination?.campgroundName != nil ? destination!.campgroundName : destinationBL!.name
// Create the hosting controller for the SwiftUI view
let mapViewController = UIHostingController(rootView: CarPlayMapView(templateManager: self))
window.rootViewController = mapViewController
window.makeKeyAndVisible()
let routeChoice = createCPRouteChoice(from: route)
trip = CPTrip(origin: startMapItem, destination: endMapItem, routeChoices: [routeChoice])
mapTemplate(mapTemplate, selectedPreviewFor: trip!, using: routeChoice)
mapTemplate.showTripPreviews([trip!], textConfiguration: nil)
return mapTemplate
}
I am trying to migrate some of my mapkit code to the Map Server API. My JWT is fine and I can use that within the API Playground just fine. However, when I try to implement a test using PHP and cURL to get my Map token, I receive a 401 Not Authorized Error. My code is below:
<?php
$URL="https://maps-api.apple.com/v1/token";
$accesstoken = "<MY TOKEN HERE>";
$authorization = 'Authorization: Bearer'.$accesstoken;
$headers = [];
$ch = curl_init($URL);
curl_setopt($ch, CURLOPT_HTTPHEADER, [$authorization]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HEADERFUNCTION,
function($curl, $header) use (&$headers)
{
$len = strlen($header);
$header = explode(':', $header, 2);
if (count($header) < 2) // ignore invalid headers
return $len;
$headers[strtolower(trim($header[0]))][] = trim($header[1]);
return $len;
}
);
$result=curl_exec($ch);
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); //get status code
curl_close ($ch);
print_r($headers);
echo($result);
echo($status_code);
?>
Now the exact response that I am receiving is:
Array ( [date] => Array ( [0] => Thu, 18 Apr 2024 18:32:15 GMT ) [content-type] => Array ( [0] => application/json;charset=utf8 ) [content-length] => Array ( [0] => 51 ) [connection] => Array ( [0] => keep-alive ) [cache-control] => Array ( [0] => max-age=0 ) [x-rid] => Array ( [0] => c9507281-bc32-46ac-be3b-dc59e97e7fed ) [strict-transport-security] => Array ( [0] => max-age=31536000; includeSubDomains; ) )
{"error":{"message":"Not Authorized","details":[]}}
401
Any help getting this to work would be appreciated.