【问题标题】:Intercom.io Custom Attributes for Swift aren't workingSwift 的 Intercom.io 自定义属性不起作用
【发布时间】:2015-10-17 13:39:57
【问题描述】:

我正在尝试将 Intercom.io 的自定义属性实现到我的 iOS 应用程序中。我在 XCode 7、Swift 2 和 iOS 9 中。

这是我的代码:

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])
}

我已成功提交“姓名”和“电子邮件”,但我的“custom_attributes”不起作用。根据对讲机的文档,我认为我的语法是正确的: https://docs.intercom.io/Install-on-your-mobile-product/configuring-intercom-for-ios

但我是 Swift 新手,没有使用 Obj-C 的经验。

同样重要的是要注意我的事件正在正确报告。

Intercom.logEventWithName(eventName)

我的语法有什么问题吗?还是别的什么?请帮忙!

【问题讨论】:

    标签: ios swift swift2 intercom intercom-ios


    【解决方案1】:

    原来有两个问题:

    1) 对讲文档错误,自定义属性不需要“custom_attributes”标签

    2) 我的 URL 格式是 NSURL 而不是字符串,因此整个对象都被拒绝了

    现已修复!感谢对讲机的 Dale 的支持

    代码很简单:

    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)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-10-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-22
      • 2018-12-20
      相关资源
      最近更新 更多