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?
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.
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
Related
I'm working on an iOS app where I need to open Google Maps to navigate to a location. I'm using the Scheme for iOS comgooglemaps:\\
Here is my code :
guard let url = URL(string: "comgooglemaps://?saddr=&daddr=\(latitude),\(longitude)&directionsmode=\(travelMode)"), UIApplication.shared.canOpenURL(url) else {
return
}
UIApplication.shared.open(url)
But the problem is, once on Google Maps, the route is not showing on the map and Google Maps is loading forever if Google Maps wasn't already started. I'm using iOS 14.4.1.
This happen using the current user location and I need it
Edit for Universal Link: That's an idea too and I forgot to precise that I test it but there is a bug too. When the user doesn't accept location on Google Maps, instead of asking to complete the form for the origin point and set the destination, Google Maps return a totally blank form. On Android, the destination is set.
As per documentation, you can also use https:// links, as Maps support universal links. This seems to work fine, even while the comgooglemaps:// url fails to load directions. Check docs for information on individual parameters. Here's an example matching your query:
https://www.google.com/maps/dir/?api=1&destination=\(latitude),\(longitude)&travelmode=\(travelMode)
I am trying to create an iPhone app that records not only the app's screen but if put into the background it records everything on the screen, including other apps. This is how recording from "Control Center" works. The difference is I want to get access to the video immediately without user intervention, with the user's consent of course.
I've implemented code using ReplayKit2 on iOS 12 that uses an embedded Broadcast Upload Extension. I have not found any examples online that work like this.
I posted the code on Bitbucket: https://bitbucket.org/breelig/replaykitbroadcasttofile/src/master/
The closet similar question I found on SO is: ReplayKit stops screen recording in background mode of the application or outside the app?
Update
Based on the good responses by #KaneCheshire and #AndreyA. below and other random sources I was able to develop a solution that works. Please see the code in my BitBucket link above.
From the docs:
Apps on a user’s device can share the recording function, with each
app having its own instance of RPScreenRecorder. Your app can record
the audio and video inside of the app, along with user commentary
through the microphone
The only other way to record the screen is through a Broadcast Upload Extension, which requires the user to initiate it through Control Centre.
I've faced almost the same problem that you did and it's absolutely lacking any kind of guides or documentation.
The way I resolved this problem to myself is setting nil to my preferred extensions, so it makes RPSystemBroadcastPickerView to show all of them including system screen video capture:
override func viewDidLoad() {
super.viewDidLoad()
let broadcastPicker = RPSystemBroadcastPickerView(frame: CGRect(x: 100, y: 100, width: 80, height: 80))
broadcastPicker.preferredExtension = nil
view.addSubview(broadcastPicker)
}
Also I've found one thing that I've figured out to be useful - this Twilio lib and its example - https://github.com/twilio/video-quickstart-swift/tree/master/ReplayKitExample - These guys have made a decent work in area of video/audio capturing and we can try to use their experience.
You can find your exactly preferedExtension here:
When you add pickerView.preferredExtension exactly the Bundle Identifier, your app will be showed on the Recording App List. Hope this helps!
I'm trying to find a way to know if Streetview is available for a specific latitude and longitude before showing it to the user. This is my current code that correctly shows a Streetview if it's available or shows a black screen. I want to basically remove the black screen situation.
https://gist.github.com/speakerbug/33f267fd3a90dbd3ca07eae5b6c7c8f5
Not sure how to do it in Maps SDK for iOS, but you can check existence of panorama using Street View Image Metadata web service.
For example, the following web service request
https://maps.googleapis.com/maps/api/streetview/metadata?location=41.391073%2C2.180614&key=YOUR_API_KEY
will return
{
"copyright":"© Rodrigo Bastias",
"date":"2017-03",
"location":{
"lat":41.3910524,
"lng":2.1806449
}, "pano_id":"CAoSK0FGMVFpcE5OVHRRTERHX1lzRF93XzRZb2YyajJwaXFXUkFRQzg5THJuOTg.",
"status":"OK"
}
I have made a classic "find-my-car-app" which saves a map location and navigates back there. I now want to implement a share button, to send a saved location via iMessage.
I have set up a MFMessageComposeViewController, in order to send a message body with the coordinates.
Using the URL method like: http://maps.apple.com/?ll=40.730610,-73.935242" does work, and opens the Maps app. What I'm missing is the map thumbnail in the message.
When sharing my location from iMessage or Maps, I get a nifty little map preview with the red pin in the message.
Copying the iMessage link on the Mac shows, that it's sent as a VCF card, but I found no way of sending a link in VCF format via iMessage.
Does anybody know how to get that map preview working?
Hope my question is clear enough!
Thanks
Use this to create a VCF file: https://gist.github.com/naturaln0va/e1fed3f1d32ecf951aac
Than:
MFMessageComposeViewController ().addAttachmentURL(Global.locationVCardURLFromCoordinate(coordinate: CLLocationCoordinate2D(latitude: 30, longitude: 40))!, withAlternateFilename: "vCard.loc.vcf")
Please tell me what is the default map location when it simply add to the view.
I added mapview like this
MKMapView *mapView = [[MKMapView alloc] initWithFrame:CGRectMake(0, self.searchBar.frame.size.height, 320, 180)];
mapView.mapType=MKMapTypeStandard;
mapView.delegate=self;
[self.view addSubview:mapView];
what location will show on map ?
Is this according to device coordinates or by other
Thanks
After done so googling and reading apple map doc.
I found the solution the default location is the device local that is International in Settings -> general ->International->ResionFormat-> select your country.
map will focus according to this setting.
I think the system makes a call and Apple's servers return this info.
I've made a little test with simulator (Extra info: I'm in Spain):
Test 1
Turn off internet access
iOS simulator > Reset content and settings
Build and run app w/mapview
Turn on internet access
Little scroll on map (just for change region a little and begin with map tiles downloading)
United states is being displayed on screen
Test 2 (wihtout turning off internet)
iOS simulator > Reset content and settings
Build and run app w/mapview
Spain is being displayed on screen
I don't think that Apple's getting user location without consent. It could be a request for default location IP based as a part of operative system.
I'm pretty sure it's lat/long 0, 0 which is somewhere in the ocean above Africa. You see this as a bug in a surprising number of apps which don't set the lat long and you end up seeing a map showing just blue - the sea.
Suggest you just test it!
No answer seems to be correct, at least with iOS8. Apple does not provide documented information on the default region of a mapView, but I believe that MapKit makes a request to the Apple server to get the current country code. In fact, if you try to turn off Internet connection and open a viewcontroller with a simple map just allocated and added as subview to the main view, the debugger will display this message:
Could not determinates current country code: Error Domain = GEOErrorDomain Code = 2 "The operation could not be completed. (GEOErrorDomain error -2.)
There's something unknown that gets the current country code and shows that country as initial region in a mapview. This "current country code" is not related with the user location, as the message is also shown by disabling location services (unless Apple takes the user's location without user authorization, which is impossible). Maybe it uses the IP address of the Internet connection to make IP tracert. I will try to use a proxy to verify.