Query for username in Salesforce iOS SDK

前端 未结 5 1236
生来不讨喜
生来不讨喜 2021-01-22 16:27

I have an iOS app using the latest Salesforce iOS SDK. It authenticates users through a webview using oAuth2.0 on the Salesforce site so I do not capture the username in my app

5条回答
  •  执笔经年
    2021-01-22 16:35

    FOR SWIFT

    To display full name and chatter profile picture of logged in user in UILabel and UIImageView using Salesforce Mobile SDK 4 you need to first create @IBOutlets

    @IBOutlet weak var yourtextLabel: UILabel!
    @IBOutlet weak var profileImage: UIImageView!
    

    Then all you need is the following in your viewDidLoad()

    yourtextLabel.text = SFAuthenticationManager.sharedManager().idCoordinator.idData.displayName
    
    let imageURL = SFAuthenticationManager.sharedManager().idCoordinator.idData.pictureUrl
    let image =  UIImage(data: NSData(contentsOfURL: imageURL!)!)
    profileImage.image = image
    

提交回复
热议问题