使用SDWebImage加载图像时如何传递Authtoken

时间:2018-11-30 12:00:52

标签: ios swift sdwebimage

我的代码是

self.imgProfile.sd_setImage(with: URL(string: "imageURL"), placeholderImage: UIImage(named: "ic_UserDefault"))

我正在使用默认的图像延迟加载功能对图像进行加载。

豆荚:豆荚“ SDWebImage”(目标C)

1 个答案:

答案 0 :(得分:2)

您需要在请求class AppDelegate:NSObject, UIApplicationDelegate, UNUserNotificationCenterDelegate{ func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { let center = UNUserNotificationCenter.current() center.delegate = self // Don't forgot to set delegate //To get permissions from user: let options: UNAuthorizationOptions = [.alert, .sound, .badge]; center.requestAuthorization(options: options) { (granted, error) in if !granted { print("Something went wrong") } } return true } } 共享实例的httpHeader中设置令牌的值,

快速实施

SDWebImageDownloader

客观的C示例

SDWebImageDownloader.shared()?.setValue(value: String!, forHTTPHeaderField: String!)

登录后,您应该配置[[SDWebImageDownloader sharedDownloader] setValue:"Value" forHTTPHeaderField:"Token"]; ,以传递您收到的AuthToken