Swift 3 Send Location as iMessage - ios

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")

Related

Url scheme for making WhatsApp call programmatically from iOS app (voice call VOIP)?

I have referred How can I place a WhatsApp call from an iOS app? which states that this feature is currently not available in iOS and as per WhatsApp FAQ Share Extension (Custom URL Scheme) it has still not mentioned any schema for placing a call, document it has mentioned:
Placing a WhatsApp call(voice call VOIP)
To make a WhatsApp call, simply open the chat with the person you want to call and tap Call in the top right corner.
Whatsapp FAQ Here
But placing a WhatsApp call from android is possible, Which I could not find in iOS.But placing WhatsApp call feature is available from phone contacts.
So my doubt is whether it is currently available in iOS to place a WhatsApp (voip)voice call from my iOS app?
If possible can you please suggest me with url schema(if available) for this just like place a chat from my app like this #"whatsapp://send?text=Hello%2C%20World!" as I couldn't find this?
I have google it and searched a lot on stackoverflow and https://faq.whatsapp.com
Seems like currently, video call from contact book feature is limited to OS level only.
But you can open particular contact then user has to manually tap on video call button.
This is regardless of phone no is stored in contact book or not. ( You can directly open )
I have tried this in Swift 3 code.
if #available(iOS 10.0, *) {
UIApplication.shared.open(NSURL(string: "whatsapp://send?phone=+91phonenumber")! as URL)
} else {
UIApplication.shared.openURL(NSURL(string: "whatsapp://send?phone=+91phonenumber")! as URL)
}
https://faq.whatsapp.com/en/iphone/23559013
Hope this helps you to figure out further way

Close Google Map directions in ionic

I want to show directions from my current location to an address in my app.
I can successfully open the directions by using:
Get directions
But once open I cannot return to my app. Is there a way to close the map again?
*note I appreciate this will only work correctly on iOS, I will handle android separately.
you should be able to do it with comgooglemaps-x-callback:
https://developers.google.com/maps/documentation/ios/urlscheme#specify_a_callback_url
this example opens Google Maps on iOS with a call back to chrome:
comgooglemapsurl://maps.google.com/maps?f=d&daddr=Tokyo+Tower,+Tokyo,+Japan&sll=35.6586,139.7454&sspn=0.2,0.1&nav=1&x-source=Chrome&x-success=googlechrome://?resume=true

How to open Apple Maps from another app

My company created an app that sends location deals in an app inbox. I want to send directions in the appmail so that if someone clicks on 'Click here for directions' it will automatically open directions from current location to the requested point in the Apple Maps app.
When I email the URL to myself and open it with AppMail, it works perfect.
When I send the URL via AppMail, it opens the URL in safari via GoogleMaps.
This is the URL I'm using.
>>Click Here for Directions<<
You need to change:
http://maps.apple.com/?...
To one of:
http://maps.apple.com/maps?...
or
http://maps.google.com/maps?...
The apple.com URL is technically the correct one, but the google URL is the only one that will work properly on older versions of iOS, and new versions of iOS also support it as well (although I don't know how long that will last).

iOS How should I open phonebook through coding

I am doing one project in that I am sending messages to multiple user.
When I am composing message I took one textfield for enter contact. When I click on contact textfield I want to open phone contact (like In Phone default compose message view how the all contacts appears when user click on "To") view.
In Android development we can open the phone contacts bye using "contact intent" I want to create like the same.
By using ABAddressBook I am able to fetch all contacts. But I dont want to create custom phonebook contact. So please help me that is there any default method to get default phone contacts controller in iOS.
For example how we directly open the setting page by using
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"prefs://"]];
this . I want the something like this to open the phone contact and once i finished any action(i.e selected any contact number) then it will get back to my app
Use the ABPeoplePickerNavigationController: https://developer.apple.com/library/ios/documentation/ContactData/Conceptual/AddressBookProgrammingGuideforiPhone/Chapters/UI_Controllers.html#//apple_ref/doc/uid/TP40007744-CH5-SW1

Register to support location document type in iOS app

I am trying to find out the LSItemContentTypes to be have a location in the maps app share to my app.
As an example of what I require is:
searching for a location in maps
tapping on the pin
tap on the info button
Share in the top right
This only provides Messages, Mail, Twitter and Facebook.
Does anyone know if this is a public document UTI type? And if so what is the identifier?
I have tried com.apple.maps, public.contact, public.url, public.vcard and I can't see anything applicable on https://developer.apple.com/library/ios/documentation/Miscellaneous/Reference/UTIRef/Articles/System-DeclaredUniformTypeIdentifiers.html

Resources