---
title: Step 3. Handling IdpCollector nodes
description: Your app must handle the IdpCollector node type that DaVinci sends when a user attempts to authenticate using an external IdP.
component: sdks
version: latest
page_id: sdks:davinci:use-cases/social-login/ios/03_handling_idpcollector_nodes
canonical_url: https://docs.pingidentity.com/sdks/latest/davinci/use-cases/social-login/ios/03_handling_idpcollector_nodes.html
revdate: Tue, 25 Mar 2025 11:00:37 +0100
keywords: ["DaVinci", "Flows", "Tutorial", "Source Code", "Integration", "SDK", "iOS"]
---

# Step 3. Handling IdpCollector nodes

Your app must handle the `IdpCollector` node type that DaVinci sends when a user attempts to authenticate using an external IdP.

When encountering an `IdpCollector` node type, call `idpCollector.authorize()` to begin authentication with the external IdP:

```swift
public class SocialButtonViewModel: ObservableObject {
    @Published public var isComplete: Bool = false
    public let idpCollector: IdpCollector

    public init(idpCollector: IdpCollector) {
        self.idpCollector = idpCollector
    }

    public func startSocialAuthentication() async → Result<Bool, IdpExceptions> {
        return await idpCollector.authorize()
    }

    public func socialButtonText() → some View {
        let bgColor: Color
        switch idpCollector.idpType {
        case "APPLE":
            bgColor = Color.appleButtonBackground
        case "GOOGLE":
            bgColor = Color.googleButtonBackground
        case "FACEBOOK":
            bgColor = Color.facebookButtonBackground
        default:
            bgColor = Color.themeButtonBackground
        }
        let text = Text(idpCollector.label)
            .font(.headline)
            .foregroundColor(.white)
            .padding()
            .frame(width: 300, height: 50)
            .background(bgColor)
            .cornerRadius(15.0)

        return text
    }
}
```

The `idpCollector.authorize()` method returns a `Success` result when authentication with the external IdP completes successfully. If not, it returns `Failure` and `IdpExceptions`, which shows the root cause of the issue.

```swift
Task {
    let result = await socialButtonViewModel.startSocialAuthentication()
    switch result {
    case .success(_):
        onNext(true)
    case .failure(let error): //<- Exception
        onStart()
    }
}
```

The result resembles the following:

![Example iOS app with social sign-on options.](../../../_images/davinci-social-sign-on-ios-example.png)
