Plumb5 SDK for iOS Devices

The document details steps required to integrate Plumb5 SDK into your application for iOS devices. For any questions or queries please email us at support@plumb5.com

Getting Started

Before you can begin working with Plumb5SDK on iOS, you need to download the Plumb5 SDK for iOS and ensure that you have an APP key.

Step1 : Get the latest version of Xcode

To build a project using Plumb5 SDK for iOS, you need Xcode version 8.3.2 or later

Step2: Obtain the APP Key

Register with www.plumb5.com to obtain your APP Key. If you have been provided with an APP key, you can use that instead. Please write to support@plumb5.com for any help.

The iOS Framework is available for download at

http://www.plumb5.com/P5-IOS-sdk.zip

Step 3:

  • Download “Plumb5SDK.framework”
  • Unpack the source files.
  • Launch Xcode and either open an existing project, or create a new project. If you're new to iOS, create a Single View Application, and disable Use Storyboards and enable Use Automatic Reference Counting.
  • Drag and drop the “Plumb5SDK.framework” in to your xcode project, When prompted, ensure Copy items into destination group's folder is selected.
  • Now Select the project file.
  • Add Plumb5SDK.framework under Embedded Binaries.
  • Select your project from the Project Navigator, and choose your Deployment target
  • Open the Build Phases tab, and within Link Binary with Libraries, add the following frameworks: Plumb5SDK.framework
  • Select Target, go to general and add Plumb5SDK.framework into embedded binaries

Step 4: Your project shall have podfile, if you don’t have go to the following url to setup the pod project

If you don't already have the CocoaPods tool, install it on macOS by running the following command from the terminal. For details, see the : www.guides.cocoapods.org/using/getting-started.html

Execute the following command on the terminal in project directory

  • cd <Space> Project Directory and hit enter.
  • Pod <Space> init
  • Now go to the project folder.
  • Find the pod file under the created project
  • Add the following lines into your podfile above of target ‘Your project Name’ do
    • pod 'Alamofire', '~> 4.2.0'
    • pod 'ReachabilitySwift'
    • pod 'SugarRecord/CoreData'
    • pod 'SugarRecord/CoreData+iCloud'
  • Save the pod file.

Open a terminal and go to the directory containing the pod file cd < Project Path >

Execute the “Pod install” command. This will install the APIs specified in the podfile, along with any dependencies they may have  $ pod install

Step 5: Add the following lines in your info.plist file

<key> NSLocationAlwaysUsageDescription<key>

<string> App needs Location<string>

<key> NSLocationWhenInUseUsageDescription<key>

<string> NSLocationAlwaysUsageDescription<string>

Privacy - Location always usage description    String    App needs Location

Privacy - Location When in Use Usage Description    String    App needs Location

It will prompt the user requesting permission to access current location.

Step 6: Add the Plumb5 SDK in your project

1. Add the following lines in to your appdelegate file

“didFinishLaunchingWithOptions” method

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?)-> Bool { let appKey = "p5m1a2i3sdk3610"
let version = "1.00"
P5SDKManager.initP5SDK(key: appKey, version: version) return true }

Declaration

public class func initP5SDK(key: String, version: String)

Description

This method will kick start the Plumb5 SDK Manager analytics session

@param key, version

@return void

Parameters

Key      String value

version      String value

Declared in

P5SDKManager.swift

2. It is required to pass the following user information to uniquely identify the user. The user information is tagged against the device id, enabling real time analytics and engagement.

P5SDKManager.registerUser(name: "name", email: "userid@gmail.com", phoneNumber: "987654321", extraParam: "extra")

Declaration

public class func registerUser(name: String, email: String, phoneNumber: String, extraParam: String)

Description

User registration, this method will push user information along with the device id

@param name,email,phoneNumber,extraParam

@return void

Parameters

name String value

email String value with valid email

phoneNumber String value with valid phoneNumber

extraParam String value

Declared in

P5SDKManager.swift

Top