I am developing a Siri based payment system application. I realized Siri and her work fine. But I am adding contacts in a static way. But my requirement is that I get contact from my server, than I have to save it in my extension. Please suggest me how to do this. I am using a piece of code. My AppDelegate.swift
import UIKit import Payment import Intents @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
My contact class inside the payment system
import Intents public struct Contact { private static let nameFormatter = PersonNameComponentsFormatter() public let nameComponents: PersonNameComponents public let emailAddress: String public var formattedName: String { return Contact.nameFormatter.string(from: nameComponents) } public init(givenName: String?, familyName: String?, emailAddress: String) { var nameComponents = PersonNameComponents() nameComponents.givenName = givenName nameComponents.familyName = familyName self.nameComponents = nameComponents self.emailAddress = emailAddress } } public extension Contact { static let sampleContacts = [ Contact(givenName: "Anne", familyName: "Johnson", emailAddress: " anne.johnson@example.com "), Contact(givenName: "Maria", familyName: "Ruiz", emailAddress: " maria.ruiz@example.com "), Contact(givenName: "Mei", familyName: "Chen", emailAddress: " mei.chen@example.com "), Contact(givenName: "Gita", familyName: "Kumar", emailAddress: " gita.kumar@example.com "), Contact(givenName: "Bill", familyName: "James", emailAddress: " bill.james@example.com "), Contact(givenName: "Tom", familyName: "Clark", emailAddress: " tom.clark@example.com "), Contact(givenName: "Juan", familyName: "Chavez", emailAddress: " juan.chavez@example.com "), Contact(givenName: "Ravi", familyName: "Patel", emailAddress: " ravi.patel@example.com "), ] }
I cannot make contact from AppDelgate. Please suggest me.