I am trying to integrate Uber SDK with my current iOS app.
I have Xcode :- 8.1 iOS :-10.1 and swift version :- 3.0
I have done setup for "Carthage" for Uber integration.
i am calling requestRide method and its always giving ride=nil
let parameterBuilder = RideParametersBuilder()
parameterBuilder.setProductID("a1111c8c-c720-46c3-8534-2fcdd730040d")
let pickupLocation = CLLocation(latitude: 37.770, longitude: -122.466)
parameterBuilder.setPickupLocation(pickupLocation, nickname: "California Academy of Sciences")
let dropoffLocation = CLLocation(latitude: 37.791, longitude: -122.405)
parameterBuilder.setDropoffLocation(dropoffLocation, nickname: "Pier 39")
let ridesClient = RidesClient()
ridesClient.requestRide(parameterBuilder.build(), completion: { ride, response in
}
Please help me.
i stuck here not able to execute my project. any suggestion will be useful for me.
Thanks in advance.
Related
This is my custom location set inside the iOS 10.0 iPhone 6 and iOS 11.2 iPhone 6 simulators.
And this is the code by which I am trying to open the iPhone's inbuilt Apple Map and show the directions from user's (above set) current location to the provided destination locations.
let regionDistance: CLLocationDistance = 1000
let coordinates = CLLocationCoordinate2D(latitude: 26.025860999999999, longitude: 56.089238999999999)
let regionSpan = MKCoordinateRegionMakeWithDistance(coordinates, regionDistance, regionDistance)
let options = [MKLaunchOptionsMapCenterKey: NSValue(mkCoordinate: regionSpan.center),
MKLaunchOptionsMapSpanKey: NSValue(mkCoordinateSpan: regionSpan.span),
MKLaunchOptionsDirectionsModeKey: MKLaunchOptionsDirectionsModeDriving] as [String : Any]
let placemark = MKPlacemark(coordinate: coordinates, addressDictionary: nil)
let mapItem = MKMapItem(placemark: placemark)
mapItem.name = "Federal Electricity & Water Authority"
mapItem.openInMaps(launchOptions: options)
but this is not working for at all. It's showing me the error like below,
Note:
I have given the location access permission to the default Map
application.
All 4 MKLaunchOptionsDirectionsModeKey is not showing
the direction.
Tested it on the Simulator and a real device and it is not working in either place.
Setting destination coordinates like this doesn't help. let coordinates = CLLocationCoordinate2D(latitude: 26.025861, longitude: 56.089239)
Please help!
As Indrajeet commented, the directions in iPhone's Apple Map is limited to the countries which are listed in this URL.
So in my case, UAE is not listed currently.
Will update this answer in future once UAE will be listed.
Google Maps does not load the map on iPhone. However when I connect the iPhone to Xcode and execute the project, it loads the map correctly.
This is my code:
let camera = GMSCameraPosition.camera(withLatitude: -33.868, longitude: 151.2086, zoom: 14)
let mapViewtest = GMSMapView.map(withFrame: .zero, camera: camera)
let marker = GMSMarker()
marker.position = camera.target
marker.snippet = "Hello World"
//marker.appearAnimation = kGMSMarkerAnimationPop
marker.map = mapViewtest
view = mapViewtest
The console shows me this but I do not know if it has something to do with the issue:
CoreData: annotation: Failed to load optimized model at path
'/var/containers/Bundle/Application/33FC89CC-DC52-4212-A361-F54DD2AC3CD9/App_name.app/GoogleMaps.bundle/GMSCacheStorage.momd/StorageWithTileProto.omo'
EDIT
The problem is that the map doesn't appear, but markers appear correctly
Run app on Iphone connected to xcode
Run app whitout xcode
check your apikey again.
even if you use a wrong apikey, map will be show on a simulator, but doesn't work on device.
I'm trying to create a custom CLPlacemark using the Intents framework.
I'm importing 'Intents' at files beginning.
I found this solution:
let waypointLocation = CLLocation(latitude: 50.00, longitude: 8.00)
let waypointName = "Some Name"
let w1 = CLPlacemark.init(location: waypointLocation,
name: waypointName,
postalAddress: nil)
Unfortunately the above code gives me the following error message:
Ambiguous reference to member 'init(placemark:)'
Any ideas what's wrong?
Documentation:
init(location:name:postalAddress:) https://developer.apple.com/reference/corelocation/clplacemark/2132103-init
Just found out that in iOS 12 / Xcode 10 you also have to include the Contacts framework, as the postaladdress param has the class CNPostalAddress required for this initializer
import Intents
import Contacts
By subclassing CLPlacemark it is possible to use the Intents frameworks protocol init(location:name:postalAddress).
Somewhere in your project:
class MyPlacemark: CLPlacemark {}
Your code to create a custom CLPlacemark:
let placeLocation = CLLocation(latitude: 50.00, longitude: 8.00)
let placeName = "Some name"
let customPlacemark = MyPlacemark(location: w1Location, name: w1Name, postalAddress: nil)
You need to use
init(location:name:postalAddress);
The placemarkWithLocation call is objective-C not swift hence why it is throwing that error message.
In the documentation you will see a language selection on the right hand side. init(location:name:postalAddress is the swift call you will need to create a new place mark.
It's quite easy to add an annotation to a MapKit view which is inside your app.
theMap: MKMapView!
let pa = MKPointAnnotation()
pa.title = "title!!" etc
theMap.addAnnotation(pa)
But how the heck do you make the Maps App add an annotation??
Here's exactly how to open the Maps App to a certain address..
func appleMapApp() {
quickAddressText = "123 Smith St 90210"
let bottomText = "This shows at BOTTOM Of Maps App screen."
let g = CLGeocoder()
g.geocodeAddressString(quickAddressText) { placemarks, error in
if let found = placemarks?.first, let lok = found.location {
let p = MKPlacemark(coordinate: lok.coordinate, addressDictionary: nil)
let mapItem = MKMapItem(placemark: p)
mapItem.name = bottomText
mapItem.openInMaps(launchOptions: showing(location: lok))
}
}
}
// convenient function...
func showing(location: CLLocation, meters m: CLLocationDistance = 1000)->[String : Any]? {
let cr = MKCoordinateRegionMakeWithDistance(location.coordinate, m,m)
let options = [
MKLaunchOptionsMapCenterKey: NSValue(mkCoordinate: cr.center),
MKLaunchOptionsMapSpanKey: NSValue(mkCoordinateSpan: cr.span)
]
return options
}
That's great - but how the heck do you pass in a MKPointAnnotation to the actual Maps app??
(Again - it's easy to add a MKPointAnnotation on a map view inside your own app.)
Any ideas? Is it actually possible??
I think openInMaps limits you only to the five possible launch options. But I wonder if you could get Apple Maps to open in the original way, openURL and maps.apple.com/maps, as shown in this SO question. With the newest iOS versions, though, it seems you also need to register the URL you're using in your info.plist under "URL Types ... URL Schemes" or "LSApplicationQueriesSchemes". You might be able to pass an annotation as a parameter with the URL.
I am working on an app for iOS 7 and I need to find the location of the user and then check to see what other users are also at that same location. I need it to update as soon as the user opens the app as well as update every so often and will display the users at the same location. I have looked at the available examples, but there doesn't seem to be enough on this using Parse. Can anyone give me any help on how to go about doing this, or if anyone knows of some examples similar to what I'm trying to do I would greatly appreciate it. Thanks in advance!
You need to break your problem down and tackle the various pieces -
Obtain the user's location when the app opens and periodically
The Location and Maps programming guide is a good starting point. You can use CLLocationManager to obtain your initial location and you can register for the significant location change event to get updates periodically, even when your app isn't running. Apple has example code plus there are plenty of other examples out there - Just search using "Core Location examples"
Store the user's location in your Parse database
There are examples and documentation on Parse.com showing how to do this. You can also provide a web service that allows your app to query the database for other users at the same location
Identify other users at the same location when your app isn't running
You can use Parse background jobs to trawl your database, match user locations and send push notifications to your users. Again there are examples on Parse.com showing how to set up background jobs and push notifications
this may help this will get your current location then save to parse, its just a matter of querying parse to pull the data down
func locationManager(manager: CLLocationManager!, didUpdateLocations
locations: [AnyObject]!) {
var userLocation : CLLocation = locations[0] as! CLLocation
var latitude = userLocation.coordinate.latitude
var longitude = userLocation.coordinate.longitude
var latDelta : CLLocationDegrees = 0.01
var lonDelta : CLLocationDegrees = 0.01
var span : MKCoordinateSpan = MKCoordinateSpanMake(latDelta,
lonDelta)
var location : CLLocationCoordinate2D = CLLocationCoordinate2DMake(latitude, longitude)
var region : MKCoordinateRegion = MKCoordinateRegionMake(location, span)
self.mapView.setRegion(region, animated: true)
let testObject = PFObject(className: "User")
let currentPoints = PFGeoPoint(latitude: latitude, longitude: longitude)
testObject.setValue(currentPoints, forKey: "currentLocation")
testObject.saveInBackgroundWithBlock { (success: Bool, error: NSError?) -> Void in
if (success) {
dispatch_async(dispatch_get_main_queue()) {
println("added to parse")
}
} else {
println(error)
}
}
}