iOS How should I open phonebook through coding - ios

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

Related

iOS CNContat : Contact's authorization status in today extension is different to main app's

I have developed a today extension using Contacts framework.
After allowing to access contacts in the main app (I touched down "OK" button on a alert that explaining "ABC app" would like to access your contacts), I checked CNAuthorizationStatus is CNAuthorizationStatusAuthorized.
But, when I logged the status on today extension, the value is CNAuthorizationStatusNotDetermined.
Why this problem is occurred? And how can I fix it?

How to open specific contact's chat screen in WhatsApp from our app?

I wanted to integrate below functionality:
I am passing one contact number of a user. If that contact number already exists, directly opens that user's chat screen when I press on WhatsApp button in my app.
If that contact does not exist in the address book, then first, store this contact in the address book and then open that contact's chat screen in WhatsApp (with refreshing contacts so I will get the name of that person on WhatsApp chat screen).
I have done below task:
If contact does not exist, then it first stored in the address book and then move to WhatsApp. If I press the WhatsApp button again for the second time, then it checks that contact if it exists or not. If it's already saved, then fetch its record identifier and passed with WhatsApp URL scheme.
The main problem is that it just moves to WhatsApp's contact list, but does not open specific chat screen of the user.
Note: This thing works perfectly in Android, so I hope that it's also possible to integrate into iOS/Swift app.
Check out whats app Custom URL Scheme
https://www.whatsapp.com/faq/en/iphone/23559013
There is no URL Scheme registered for specific chat screen of user.
Simply Append with ABID with your whatsapp url scheme and call this its worked.
ABID stands for the Address book Record ID,the code below works to get the AB Record ID. It is sensitive to the use of delimeters in the URL itself.
To send a note to a specific user use this - urlstring format: whatsapp://send?abid=12&text=Hello%20World - note the use of & to mark the second parameter.
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person
{
ARecordID = (ABRecordID)ABRecordGetRecordID(person);
....
whatsapp_string = [NSString stringWithFormat:#"whatsapp://send?abid=%d&text=%#;",ARecordID, "hello"];
....
}

Send Message to user on Whatsapp from app without opening Whatsapp

Suppose I have few forms that needs to be filled by the user including contact number. After filling of all the forms, I want that contact number should receive a message including some greetings or some text or image clicked to use in the form. The message should be delivered as a simple SMS and also on WhatsApp. All this needs to be done without opening WhatsApp. Is it possible? If yes then how?
Thanks in advance.
I don't think this can be possible.
Yes you can set body of message using 'MFMessageComposeViewController' that involves user-interaction that means without user tapping simple message cant be sent otherwise spams could easily be written.
As far as send message via whatsApp, without opening whatsApp I guess you can only open application
NSURL *whatsAppURL = [NSURL URLWithString:#"Whatsapp://location?id=1"];
if ([[UIApplication sharedApplication] canOpenURL:whatsAppURL]) {
[[UIApplication sharedApplication] openURL:whatsAppURL]]];
}
Every application has it's Own 'Sandbox' a File System that can not be access outside boundary of that app.
And on iOS 9 you have to add "Whatsapp" under a proper key in your info.plist iOS 9 not opening Instagram app with URL SCHEME
I think you should use UIActivityViewController but you need to customise it for WhatsApp and there is open source here he prepared everything :)

Uber Deeplinking on iOS

I am trying to generate a deep link that will open the app, set pickup location to current location and dropoff address to Uber's HQ.
Here is what I have:
uber://?action=setPickup&pickup=my_location&dropoff[formatted_address]=1455%20Market%20St%2C%20San%20Francisco%2C%20CA%2094103
Unfortunately, no destination address is being pre-filled once in the app.
Hey I was running into the same problem and this is the way I got it to work. First, you need to add your client id to the url. So in your case change
uber://?action=setPickup&pickup=my_location&dropoff[formatted_address]=1455%20Market%20St%2C%20San%20Francisco%2C%20CA%2094103
to
uber://?client_id=YOUR_CLIENT_ID&action=setPickup&pickup=my_location&dropoff[formatted_address]=1455%20Market%20St%2C%20San%20Francisco%2C%20CA%2094103
where YOUR_CLIENT_ID is the client id given to you by Uber.
To get a client id you must register your app with Uber at https://developer.uber.com/.
Hope this helps!
The dropoff address will show appear once the user drops a pin to select their pickup location.

application would like to Access the Microphone ios alert [duplicate]

Anyway to custom permission alert view like: Contacts, Photo Album, Push Notifications... before they get access, they will pop up an alert view like this:
How to custom Contacts, photo album, push notifications alert view text?
UPdate:
See the update image above, translate into english:
"To seek for your family and friends, Path needs to transfer your
contacts to our server"
And click OK to get contacts access without any other access permission alert view pops up.
Under iOS 6 and above, these can be setup to show specific messages. Edit your Info.plist by adding a few new entries. The keys all begin with "Privacy - " (the raw keys are NSxxxUsageDescription where xxx is Contacts, Locations, Reminders, PhotoLibrary, or Calendards). The value is the text you wish to display to the user.

Resources