Want your app to enable the next generation of phone calls? Look no further!
By utilizing PicUP patented technology, PicUP client SDK enables rich digital communication over phone calls. PicUP Client iOS SDK is a Swift library for iOS that is part of PicUP Optimization & Personalization Platform for Phone Calls ©.
Your app needs to have Contacts permission from the user, as described here:
NSContactsUsageDescription
key to your app’s Info.plist
file, with a string that describes what your app does with the user’s contacts.CNContactStore().requestAccess(for: CNEntityType.contacts) {...}
to request contacts access. (If you don't, the SDK will request access when you initialize it.)Add the following line to your Podfile:
pod 'PicUPSDKv3'
Then run:
pod install
Navigate to the Swift packages section in your project, add a new package, enter
https://github.com/PicupMobile/IOS.PicupSDKv3
and click "Next".
Download the latest version from here and extract it. Copy SDKFramework/PicUPSDKv3.framework to your project by drag and dropping it into Xcode project navigator. When asked, choose to Copy items if needed:
Initialize the SDK by calling register()
:
import PicUPSDKv3
// ...
PicUpSDK.shared.register(
clientName,
clientPhoneNumber: userPhoneNumber, // hashed - see below
organizationCode: organizationCode, // from management console
securityCode: securityCode, // from management console
uuid: persistentUniqueString, // e.g. push token
completion: { result in
// ...
}
)
Arguments:
clientName
String with name of the client organization.
clientPhoneNumber
Hashed representation of the actual phone number. Used as an opaque identifier in the management console. To create the hash, you can use the code below.
For iOS 13 or later:
import CryptoKit
func hashedRepresentation(phoneNumber: String) -> String? {
guard let phoneNumberData = phoneNumber.data(using: .utf8) else { return nil }
let digest = SHA256.hash(data: phoneNumberData)
return Data(digest).base64EncodedString()
}
For earlier versions of iOS you can use CryptoSwift:
import CryptoSwift
func hashedRepresentation(phoneNumber: String) -> String? {
guard let phoneNumberData = phoneNumber.data(using: .utf8) else { return nil }
return phoneNumberData.sha256().base64EncodedString()
}
organizationCode
From the web management console.
securityCode
From the web management console.
uuid
Persistent unique string, like firebase token or UIDevice.current.identifierForVendor?.uuidString
.
completion
Called when the registration is complete, with a PicUpResult
parameter that contains optional error data.
By default, the SDK does nothing if the app didn't acquire the user's permission to access Contacts.
You can let the SDK handle requesting permissions from the user when necessary, by changing its permissionMode
:
PicUpSDK.shared.permissionMode = .internal
PicUpSDK.shared.disableService()
PicUpSDK.shared.enableService()
PicUpSDK.shared.clearData()
link |
Stars: 0 |
Last commit: 2 weeks ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco