Intercom.io Custom Attributes for Swift aren't

2019-06-05 15:51发布

I'm trying to implement custom attributes for Intercom.io into my iOS app. I'm in XCode 7, Swift 2 and iOS 9.

Here's my code:

class func updateUser(user: User) {
    Intercom.updateUserWithAttributes([
        "name": user.name,
        "email": user.email
    ])

    let userAttributes = ([
        "role": "customer",
        "phone": user.phone,
        "First Name": user.firstName,
        "Last Name": user.lastName,
        "Referral Code": user.referralCode,
        "Avatar Pic": user.avatarURL,
        "Profile Pic": user.profilePicURL
    ])

    Intercom.updateUserWithAttributes(["custom_attributes": userAttributes])
}

I am successfully submitting "name" & "email" but my "custom_attributes" aren't working. I think my syntax is correct according to the Intercom's documentation: https://docs.intercom.io/Install-on-your-mobile-product/configuring-intercom-for-ios

But I'm a Swift newbie and have no experience with Obj-C.

Also important to note that my events are reporting properly through.

Intercom.logEventWithName(eventName)

Is there anything wrong with my syntax?? Or anything else? Please help!

1条回答
对你真心纯属浪费
2楼-- · 2019-06-05 16:21

Turns out there were two issues:

1) Intercom documentation wrong and "custom_attributes" tag not needed for custom attributes

2) my URL formats were NSURL and not Strings and therefore the whole object was getting rejected

Fixed now! Thanks to Dale from Intercom for the support

the code is simply:

let userAttributes = [
        "name": user.name,
        "email": user.email,
        "role": "customer",
        "phone": user.phone,
        "first_name": user.firstName,
        "last_name": user.lastName,
        "referral_code": user.referralCode,
        "avatar_pic": user.avatarURLString,
        "profile_pic": user.profilePicURLString
    ]

Intercom.updateUserWithAttributes(userAttributes)
查看更多
登录 后发表回答