问题描述
我正在尝试将Intercom.io的自定义属性实现到我的iOS应用中.我正在使用XCode 7,Swift 2和iOS 9.
I'm trying to implement custom attributes for Intercom.io into my iOS app. I'm in XCode 7, Swift 2 and 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在您的移动产品/iOS上配置对讲机
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
但是我是Swift新手,没有Obj-C的经验.
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)对讲文档错误,自定义属性不需要"custom_attributes"标签
1) Intercom documentation wrong and "custom_attributes" tag not needed for custom attributes
2)我的URL格式是NSURL而不是字符串,因此整个对象都被拒绝了
2) my URL formats were NSURL and not Strings and therefore the whole object was getting rejected
立即修复!感谢对讲机的Dale的支持
Fixed now! Thanks to Dale from Intercom for the support
代码很简单:
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)
这篇关于Swift的Intercom.io自定义属性不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!