Pataa Set delivery location SDK Implementation Guide
Install SDK
To use the Pataa Autofill iOS SDK, you have two options.
Follow the steps for a Cocoapods install:
In your project root directory run this command on terminal
pod init
then open open podfile and past this in your project podfile
pod 'Address-Autofill-iOS'
then save and run this command on terminal
pod install'
Follow the steps below for a manual install:
Download and unzip the PataaAutoFillSDK
Drag the PataaAutoFillSDK.xcframework inside your project under the main project file.
Embed the framework.
Select your project.xcodeproj file.
Under General, add the PataaAutoFillSDK framework in the Frameworks, Libraries & Embedded Content section.
Integration Steps for Objective-C
Follow the steps below for Objective-C:
Import PataaAutoFillSDK.h to your ViewController.h file.
Import PataaAutoFillSDK.h into every class where you plan to use this SDK.
#import <PataaAutoFillSDK/PataaAutoFillSDK.h>
- Create a UIView on your UIViewController on the storyboard/xib & assign PataaAddAddressView class & create an IBOutlet of that UIView on your ViewController class. Please set the height of UIView 70 for better visibility
- Initialize SDK with your key & app prefix(Team ID) in ViewDidLoad() method.
[objectName initializeSDKWithKey:@"YOUR_API_KEY" withAppPrefix:@"APP_PREFIX"];
Get Pataa Details
Follow the steps below for Objective-C:
To get the details of entered pataa code. Please assign the PataaAddAddressDelegate to your view controller & implement PataaAddAddressDelegate in your ViewController.h file
[objecName setDelegate:self];
After that please implement the delegate methods in your view controller inside a ViewController.m file.
- (void)didReceivedAddPataaDetails:(nullable PAPataaDetail *)pataaDetails withError:(nullable NSError *)error {
}
- (void)didReceivedAddressDetails:(nullable AddressDetails *)addressDetails {
}
In PAPataaDetails, You will get all the details of your pataa & user. To get the pataa details please use the following code:
- (void)didReceivedAddPataaDetails:(nullable PAPataaDetail *)pataaDetails withError:(nullable NSError *)error {
NSLog(@"%@", addressDetails.address1)
NSLog(@"%@", addressDetails.address2)
NSLog(@"%@", addressDetails.address3)
NSLog(@"%@", addressDetails.address4)
NSLog(@"%@", addressDetails.cityName)
NSLog(@"%@", addressDetails.stateName)
NSLog(@"%@", addressDetails.countryName)
NSLog(@"%@", addressDetails.latitude)
NSLog(@"%@", addressDetails.longitude)
}
To get the user details please use the following code:
- (void)didReceivedAddPataaDetails:(nullable PAPataaDetail *)pataaDetails withError:(nullable NSError *)error {
NSLog(@"%@", pataaDetails.user.mobile)
NSLog(@"%@", pataaDetails.user.countryCode)
NSLog(@"%@", pataaDetails.user.firstName)
NSLog(@"%@", pataaDetails.user.lastName)
}
If the user didn’t allow location permission & try to create a pataa then you will get all details in this delegate method.
- (void)didReceivedAddPataaDetails:(nullable PAPataaDetail *)pataaDetails withError:(nullable NSError *)error {
NSLog(@"%@", addressDetails.address1)
NSLog(@"%@", addressDetails.address2)
NSLog(@"%@", addressDetails.address3)
NSLog(@"%@", addressDetails.address4)
NSLog(@"%@", addressDetails.cityName)
NSLog(@"%@", addressDetails.stateName)
NSLog(@"%@", addressDetails.countryName)
NSLog(@"%@", addressDetails.latitude)
NSLog(@"%@", addressDetails.longitude)
}
Follow the steps below for Swift:
To get the details of entered pataa code. Please assign the PataaAddAddressDelegate to your view controller.
objectName.delegate = self
After that please implement the delegate methods in your view controller inside a UIViewController or using an extension.
extension ViewController: PataaAddAddressDelegate {
func didReceivedAddPataaDetails(_ pataaDetails: PAPataaDetail?, withError error: Error?) {
}
func didReceivedAddressDetails(_ addressDetails: AddressDetails?) {
}
}
In PAPataaDetails, You will get all the details of your pataa & user. To get the pataa details please use the following code:
extension ViewController: PataaAddAddressDelegate {
func didReceivedAddPataaDetails(_ pataaDetails: PAPataaDetail?, withError error: Error?) {
if let pataaDetails = pataaDetails, let pataa = pataaDetails.pataa {
print(pataa.pataaCode)
print(pataa.address1)
print(pataa.address2)
print(pataa.address3)
print(pataa.zipcode)
print(pataa.cityName)
print(pataa.stateName)
print(pataa.countryName)
print(pataa.latitude)
print(pataa.longitude)
}
}
func didReceivedAddressDetails(_ addressDetails: AddressDetails?) {
if let addressDetails = addressDetails {
print(addressDetails.address1)
print(addressDetails.address2)
print(addressDetails.address3)
print(addressDetails.zipcode)
print(addressDetails.cityName)
print(addressDetails.stateName)
print(addressDetails.countryName)
print(addressDetails.firstName)
print(addressDetails.lastName)
print(addressDetails.latitude)
print(addressDetails.longitude)
}
}
}
To get the user details please use the following code:
func didReceivedAddPataaDetails(_ pataaDetails: PAPataaDetail?, withError error: Error?) {
if let pataaDetails = pataaDetails, let user = pataaDetails.user {
print(user.countryCode)
print(user.firstName)
print(user.lastName)
print(user.mobile)
}
}
If the user didn’t allow location permission & try to create a pataa then you will get all details in this delegate method.
func didReceivedAddressDetails(_ addressDetails: AddressDetails?) {
if let addressDetails = addressDetails {
print(addressDetails.address1)
print(addressDetails.address2)
print(addressDetails.latitude)
print(addressDetails.longitude)
print(addressDetails.address3)
print(addressDetails.zipcode)
print(addressDetails.cityName)
print(addressDetails.stateName)
print(addressDetails.countryName)
print(addressDetails.firstName)
print(addressDetails.lastName)
print(addressDetails.latitude)
print(addressDetails.longitude)
}
}