Installation

ContactsManager offers two installation approaches. For production applications, we strongly recommend the Full Installation approach with server-side token generation.

1. Fast Installation (Client Only)

Swift Package Manager

Add the ContactsManager package to your Swift project by adding it as a dependency in your Package.swift file:

dependencies: [
    .package(url: "https://github.com/arpwal/contactsmanager-ios.git", from: "<latest-version>")
]

SDK Initialization (Development Only)

import ContactsManager

// Create user information
let userInfo = UserInfo(
    userId: "user123",
    fullName: "John Doe",
    email: "john@example.com",
    phone: "+1234567890"
)

// Initialize with API key and user info (NOT RECOMMENDED for production)
try await ContactsService.shared.initialize(
    withAPIKey: "your-api-key",
    token: nil, // Will generate token client-side with security warning
    userInfo: userInfo,
    options: ContactsManagerOptions(
        verboseLogging: true,
        autoSyncEnabled: true
    )
)

This is the secure, production-ready approach that sets up your server first to manage user creation and token generation.

Step A: Server Setup

Set up your backend to create users and generate authentication tokens for the ContactsManager SDK.

Installation

pip install contactsmanager

The Python SDK is open source and available on GitHub: github.com/arpwal/contactsmanager-py

Create User (First Time Setup)

from contactsmanager import ContactsManagerClient, UserInfo, DeviceInfo

# Initialize the client
client = ContactsManagerClient(
    api_key="your-api-key",
    api_secret="your-api-secret", 
    org_id="your-org-id"
)

# Create user info
user_info = UserInfo(
    user_id="user-123",
    full_name="John Doe",
    email="john@example.com",  # Optional but recommended
    phone="+1234567890",       # Optional but recommended
    avatar_url="https://...",  # Optional
    metadata={"key": "value"}  # Optional
)

# Create device info (optional)
device_info = DeviceInfo(
    device_name="iPhone 15",
    os_version="iOS 17.5",
    app_version="1.0.0"
)

# Create/update user and get token (first time or when user data changes)
response = client.create_user(
    user_info=user_info,
    device_info=device_info,
    expiry_seconds=86400  # 24 hours
)

# Use the token for client SDK initialization
token = response.token
user_data = response.user  # Created/updated user information

Generate Token (Subsequent Logins)

# For subsequent logins, generate a new token for existing users
token_data = client.generate_token(
    user_id="user-123",
    device_info={"device_name": "iPhone 15", "os_version": "iOS 17.5"},
    expiration_seconds=86400  # 24 hours
)

# The token to be used in client SDK initialization
token = token_data["token"]

Step B: Client Setup

Install and initialize the ContactsManager SDK in your client application using the token from your server.

Swift Package Manager

Add the ContactsManager package to your Swift project by adding it as a dependency in your Package.swift file:

dependencies: [
    .package(url: "https://github.com/arpwal/contactsmanager-ios.git", from: "<latest-version>")
]

Or in Xcode:

  1. Go to File > Swift Packages > Add Package Dependency
  2. Enter the repository URL: https://github.com/arpwal/contactsmanager-ios.git
  3. Specify a minimum version of <latest-version> from the repository
  4. Click Next and complete the integration
import ContactsManager

// Initialize the SDK with server-generated token (RECOMMENDED)
try await ContactsService.shared.initialize(
    withToken: "server-generated-token",
    options: ContactsManagerOptions(
        verboseLogging: false,
        autoSyncEnabled: true
    )
)

This is the recommended approach: The token should be generated by your server using the steps above. The SDK will automatically fetch user information from the server using the token, ensuring data consistency and security.

Next Steps