2015-10-17 77 views
0

我正在嘗試爲我的iOS應用程序實現Intercom.io的自定義屬性。我在XCode中7,斯威夫特2和iOS 9Intercom.io Swift的自定義屬性無法正常工作

這裏是我的代碼:

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) 

我的語法有什麼問題嗎?還是其他什麼?請幫忙!

回答

4

原來有兩個問題:不需要定製

1)內線文檔錯誤的,「custom_attributes」標籤屬性

2)我的URL格式是NSURL,而不是字符串,因此整個對象是被拒絕

已修復!由於戴爾從內線的支持

的代碼很簡單:

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) 
相關問題