I am using the MKLocalSearchRequest class to allow the user to search for an address in my app.
I dont want the response results to contain businesses. Is there any way I can tell the class/API not to return businesses in the response?
Thanks
Unless you can specify it in the naturalLanguageQuery portion of the MKLocalSearchRequest then it doesn't appear that the MKMapItem actually stores whether it's a business. The Apple documentation does say the phoneNumber should be used for a business but whether that's a guaranteed for all locations is an unknown.
Related
I looked at the API here, but it only mentions that you can get the GMSPlace for the user's current location. Is there any way to create my own custom GMSPlace object or get the GMSPlace for the lat/long I want? I looked at previous solutions but didn't find anything.
As per Google's docs:
Represents a particular physical place. A GMSPlace encapsulates
information about a physical location, including its name,
location, and any other information we might have about it. This
class is immutable.
Apparently there is no way to make your own GMSPlace object from the coordinates, nor there' a method that Google's SDK provide.
What I did before, I search for places, the one that Ajay user above discussed.
So the process is:
Get coordinates.
Reversegeocode to get the string address.
Search the string address using the GooglePlaces autocomplete.
From the first result in #3, the placeId is used to get the GMSPlace object using the lookUpPlaceID method.
Beware though that sometimes it returns a wrong address. I've tried it.
GMSPlace is a class provided by Places SDK which provides information about a specific place. You can not create your own custom object.
EDIT: To find a place other than your current location it provides Autocomplete api which automatically return location suggestions while users type.
I am trying to obtain all related contacts to a selected contact. The way to do this seems to be via mycontact.contactRelations. This gives an array of CNLabeledValue with each of those containing a CNContactRelation as their value. There is then a name property, but it appears nothing else.
The Xamarin documentation for CNContact.ContractRelations seems to suggest I should be able to obtain the corresponding CNContact from a CNContactRelation but I can see no way to do this in objc, other than searching for a contact with a matching name. This may or may not be the contact I'm after, even if they also have a relationship to a contact with the same name as mycontact.
The identifier on the CNLabeledValue seems to refer to the label rather than the related contact, or at least doesn't seem to match the identifier if I select that contact from a CNContactPickerViewController.
Is there a way to obtain the CNContact for the related contact in objc ?
The related names field in Contacts doesn't store linkages, just names. You'll notice this from a user perspective if you go to edit related names in the iOS or OS X Contacts app — it's just a freeform text field. Those apps (and other system apps) will recognize when a related name matches that of another contact (which is why you can ask Siri to call your mother, etc), but they also let you put down names for people you don't have contact info for.
So a CNContactRelation just contains a string, and the only way to find (if there are any) contacts matching a related name is to search the contact store. Use unifiedContactsMatchingPredicate:keysToFetch:error: to search, with a predicate constructed by calling predicateForContactsMatchingName:.
I am building an app in Swift. I would like to make predicate using a phoneNumber (as String) and retrieve the name of that contact -if it exists- from the CNContactStore. I can make a name predicate fairly easily by :
let pred = CNContact.predicateForContactsMatchingName(name: String)
But is there a way to do the same for a PhoneNumber. I can of course fetch the entire CNContactStore, loop through it and retrieve the contact. But I was wondering if there was any better way.
For anyone who sees this post.
In iOS11, Apple introduced this new method to fetch contact with phone number.
https://developer.apple.com/documentation/contacts/cncontact/3020511-predicateforcontacts
See:
https://nshipster.com/ios-12/
In short: you can't create a predicate to filter based on phone number. You have to pull all of the contacts and iterate. NOTE: For any given phone number, it 1) may not exist in contacts, or 2) exist more than once.
Check out this post:
https://forums.developer.apple.com/thread/19329
Twitter provides an API for getting a place object for any given location. As per twitter API documentation at https://dev.twitter.com/docs/api/1/get/geo/search :
"Given a latitude and a longitude pair, an IP address, or a name, this request will return a list of all the valid places that can be used as the place_id when updating a status.".
API returns a place object. I am specifically interested in getting the bounding coordinates for that place which can be a Point or a polygon which is included in place object. I will then use this to check if user's location lies within some other location say New York.
Now, for any user one can fetch his profile using twitter API. API returns a json object which contains user's location which is basically a string e.g, "San Francisco, CA". This location can be passed to geo search api mentioned above to get coordinates for the polygon which defines a user's location.
I am using twitter4j library to do the same. Method 'searchPlaces()' corresponds to
/geo/search API of twitter and takes a GeoQuery object as argument. However, GeoQuery object has only two constructors which take GeoLocation i.e, latitude, longitude information or ip address.
https://github.com/twitter/twitter4j/blob/master/twitter4j-core/src/main/java/twitter4j/GeoQuery.java
As can be seen in GET geo/search API, all parameters all optional. However, providing only two constructors in GeoQuery class forces one to provide either latitude and longitude values or ipaddress. What I have instead is the string for user's location from his profile.
Can someone please help me out with why there is this disparity between twitter4j and twitter API. Also, can someone suggest some other way to find if some twitter user is from New York.
PS: Any attempt to geocode user's location to get lat,long also requires GeoQuery object which again needs lat, long and I don't seem to be able to figure out how this can be done too.
Thanks in Advance.
I encountered this as well. A workaround is:
GeoQuery geo = new GeoQuery((String)null);
geo.setQuery("New York")
I'm quite new to iOS development and I'm currently building my first app.
I'm trying to get a text field to automatically populate the telephone country code for a specific country.
So if for example the user picks "UK" he gets "+44" inserted automatically into that text field.
Currently I'm struggling a way to find how to get the exact country telephone code for the country.
I could create an NSDictionary with all of the countries and country telephone code but I thought there might be a better way.
If your goal is to get the dialling code of the user's current location then you should use HMDiallingCode.
It uses CoreLocation and reverse geocoding to get current country of the user and then retrieve it's dialling code.
I think, you can only get country code for the current Carrier using CoreTelephony framework:
CTTelephonyNetworkInfo *info = [CTTelephonyNetworkInfo new];
CTCarrier *carrier = info.subscriberCellularProvider;
NSLog(#"country code is: %#", carrier.mobileCountryCode);
If you need a full list of codes for all countries, you need to use some online service for querying it.
I'm afraid there is not a better way. My app include a .plist file with the array of countries with name, code, phone code, trunk code, etc for each. You will not get all that info from iOS API.
If you only need the international phone code for a country code, here you are a link with a complete table.