🔧 Troubleshooting

Troubleshooting Guide

Solutions to common issues when integrating ProtectMyAPI.

🔧

Quick tip: Most issues are caused by testing on simulators/emulators. Always test on a real device.


Attestation Issues

”Attestation failed”

Symptoms:

  • SDK returns attestationFailed error
  • Requests are blocked
  • Works in development, fails in production

Causes & Solutions:

iOS-specific causes:

CauseSolution
Testing on SimulatorUse a real iPhone/iPad — Simulator has no Secure Enclave
App Attest not enabledAdd App Attest capability in Xcode
Bundle ID mismatchVerify Bundle ID matches dashboard exactly
Team ID incorrectCheck Apple Developer Portal for correct Team ID
Device is jailbrokenUse a non-jailbroken device
Debug buildTest with a release/TestFlight build

Check App Attest capability:

  1. Open Xcode
  2. Select your target
  3. Go to Signing & Capabilities
  4. Ensure App Attest is listed

”App not found”

Symptoms:

  • Error code: APP_NOT_FOUND
  • SDK fails to initialize

Solutions:

  1. Verify App Token:

    // Check this matches your dashboard exactly
    ProtectMyAPI.shared.configure(appId: "app_abc123...")
  2. Check organization:

    • Ensure you’re looking at the correct organization in dashboard
    • App tokens are organization-specific
  3. Verify app exists:

    • Go to Dashboard → Apps
    • Confirm your app is listed

”Security violation detected”

Symptoms:

  • Error during SDK initialization
  • App crashes or blocks requests

Causes:

ViolationMeaning
Jailbreak detectediOS device is jailbroken
Root detectedAndroid device is rooted
Emulator detectedRunning in simulator/emulator
Debugger attachedApp is being debugged
Tampering detectedApp binary was modified

Solutions:

For development/testing only:

// iOS - Development only!
let config = ProtectMyAPIConfiguration(
    appId: "app_...",
    environment: .development,
    allowJailbrokenDevices: true,  // ⚠️ Never in production
    allowSimulator: true            // ⚠️ Never in production
)
// Android - Development only!
val config = ProtectMyAPIConfiguration(
    appId = "app_...",
    environment = Environment.DEVELOPMENT,
    allowRootedDevices = true,  // ⚠️ Never in production
    allowEmulator = true        // ⚠️ Never in production
)
🚨

Never disable security in production! These settings are for development only.


API & Secret Issues

”Secret not found”

Symptoms:

  • Error code: SECRET_NOT_FOUND
  • API calls fail with auth errors

Solutions:

  1. Check secret name:

    • Names are case-sensitive
    • Verify spelling matches exactly
  2. Verify secret exists:

    • Go to Dashboard → Secrets
    • Confirm the secret is listed
  3. Check organization:

    • Secrets are organization-specific
    • Ensure you’re in the correct org
  4. Check service binding:

    • Go to API Services
    • Verify secret is linked to the endpoint

”Endpoint not found”

Symptoms:

  • Error code: ENDPOINT_NOT_FOUND
  • 404 responses

Solutions:

  1. Verify the slug:

    // The slug must match exactly
    ProtectMyAPI.shared.request(endpoint: "openai-chat")
  2. Check service exists:

    • Go to Dashboard → API Services
    • Verify the endpoint is created
  3. Check app linking:

    • Go to Apps → Your App → Linked Services
    • Verify the endpoint is linked

”Rate limited”

Symptoms:

  • Error code: RATE_LIMITED
  • HTTP 429 responses

Solutions:

CauseSolution
ProtectMyAPI limitUpgrade your plan
Provider limitCheck your provider’s rate limits
Per-device limitImplement client-side throttling

Handling rate limits:

catch ProtectMyAPIError.rateLimited(let retryAfter) {
    // Wait and retry
    try await Task.sleep(nanoseconds: UInt64(retryAfter) * 1_000_000_000)
    // Retry the request
}

“Invalid API key” (from provider)

Symptoms:

  • Error from OpenAI/Anthropic/etc.
  • “Invalid authentication” or “Incorrect API key”

Solutions:

  1. Update the secret:

    • Go to Dashboard → Secrets
    • Edit the secret with the correct key
    • Keys cannot be viewed, only replaced
  2. Verify key format:

    • OpenAI: sk-...
    • Anthropic: sk-ant-...
    • Google: AIza...
  3. Check key permissions:

    • Some providers have project-specific keys
    • Ensure the key has required scopes

Network Issues

”Network error”

Symptoms:

  • Requests timeout
  • Connection refused
  • SSL errors

Solutions:

CauseSolution
No internetCheck device connectivity
Firewall blockingWhitelist api.protectmyapi.com
SSL pinning issueUpdate SDK to latest version
Proxy interferenceDisable debugging proxies

Check connectivity:

// iOS
if !NetworkMonitor.shared.isConnected {
    showAlert("No internet connection")
    return
}

“Timeout”

Symptoms:

  • Requests take too long
  • Error code: TIMEOUT

Solutions:

  1. Increase timeout:

    let config = ProtectMyAPIConfiguration(
        appId: "app_...",
        timeout: 60.0  // Increase from default 30s
    )
  2. Check API endpoint:

    • Some AI APIs are slow (image generation)
    • Consider async/polling patterns
  3. Check network quality:

    • Test on better connection
    • Implement retry logic

SDK Issues

”SDK not initialized”

Symptoms:

  • Crash when making requests
  • Error: “SDK not initialized”

Solutions:

Initialize early in app lifecycle:

// iOS - In App init or AppDelegate
@main
struct MyApp: App {
    init() {
        ProtectMyAPI.shared.configure(appId: "app_...")
    }
}
// Android - In Application class
class MyApp : Application() {
    override fun onCreate() {
        super.onCreate()
        ProtectMyAPI.initialize(this, "app_...")
    }
}

“SDK version outdated”

Symptoms:

  • Deprecation warnings
  • Features not working

Solutions:

Update to the latest SDK:

// Swift Package Manager
// Update to latest in Xcode: File → Packages → Update to Latest
// Gradle
implementation("com.protectmyapi:android-sdk:1.0.0") // Update version
# Flutter - pubspec.yaml
dependencies:
  protectmyapi: ^1.0.0  # Update to latest

Dashboard Issues

”Cannot create app”

Solutions:

  1. Check you have Admin or Owner role
  2. Verify required fields are filled
  3. Bundle ID/Package Name must be unique
  4. Try refreshing the page

”Cannot see apps/secrets”

Solutions:

  1. Check you’re in the correct organization
  2. Verify your role has permissions
  3. Try logging out and back in
  4. Clear browser cache

”Changes not saving”

Solutions:

  1. Check for validation errors
  2. Refresh the page
  3. Try a different browser
  4. Check your internet connection

Still Stuck?