iosswiftiphoneapple-appclips

how to retrieve location data in App Clip


Is it possible to prompt for and retrieve a users location inside of an App Clip? If so, how could it be done? I tried using CLocation Manager, but it seems to not be supported inside of App Clips. Are there any workarounds?


Solution

  • You can't use Core Location to access the user's location in an app clip. This is to protect the user's privacy.

    You can embed a code in your app clip url and then, when launched, use that code to obtain an expected location.

    Once you have the expected location you can use it to create a CLCircularRegion with a radius of up to 500m.

    You can then confirm that the url that launched your app was acquired inside the region.

    Apple has more detail and some sample code available on their developer site