Multiple Physical Locations for AppClip

431 views Asked by At

I am developing an AppClip that detects the user's physical location to display the app clip. Apple mentioned a piece of code here:

 func location(from url:URL) -> CLRegion? {
   let coordinates = CLLocationCoordinate2D(latitude: 37.334722,
                                            longitude: 122.008889)
   return CLCircularRegion(center: coordinates,
                                   radius: 100,
                                   identifier: "Apple Park")
 }

My question is, is it possible to add multiple locations since my app needs several museums' location to display the AppClip?

2

There are 2 answers

1
Liaz Kamper On BEST ANSWER

Something basic to understand - App Clips are totally not dependant on location services.

More than that - an App Clip doesn't have access to the device location. The App Clip CANNOT ask 'where am I?'.

The App Clip CAN ask 'Am I at this location?' - just to make sure the QR code for the Boston branch is indeed scanned in Boston.

The experiences are not triggered by location - the only location base for the experiences is a location set in Apple Maps. As you as can spread locations in the Apple Maps for your customers, all of their experiences will show up.

The code you quoted is how to define the radius in which App Clip asks 'Am I in this radius?'

If you define separate QR code for example for each museum:

https://museums.com/nyc/123 https://museums.com/london/356 https://museums.com/paris/789

You should use the URL to understand which radius you should define in the quoted code.

0
Gereon On

Yes, you can have multiple locations, each with an individual app clip URL. This example code does not in fact extract any info from the app clip URL, as that is highly app-specific.

In a real world scenario, you would have something like

 https://example.com/appclip/location/42

as your app clip url, with different IDs for each of your locations.

Your code would then need to figure out the coordinates for location id 42 and use those to check against the user's current location