哪个版本的SendGrid与AFNetworking 3.0兼容?
问题描述:
在我的应用程序中,我通过SendGrid(0.2.0)发送电子邮件。 Sendgrid在网络2.0上正常工作,但由于某种原因,我不得不将网络版从2.0更新到3.0。但是现在SendGrid给出了错误。所以我通过一个pod更新它。哪个版本的SendGrid与AFNetworking 3.0兼容?
荚错误 - 分析依赖 无法满足以下要求:
-
AFNetworking (~> 3.0)
通过Podfile
-
AFNetworking (~> 2.0)
要求SendGrid (0.3.0)
内容Podfile的要求:
[!] '来源'https://github.com/CocoaPods/Specs.git '
平台:IOS, '8.0'
目标 '项目名' 做
荚 '火力地堡/核心'
荚 '火力地堡/消息'
荚 'AFNetworking', '〜> 3.0'
荚' SendGrid','〜> 0.3.0'
end
有人可以告诉我如何解决这个问题吗?
谢谢!
答
要定制SendGrid
有一点要注意。
- 您必须手动添加
sendGrid
没有豆荚。 - 使用Pod添加AFNetworking 3.0。
现在,SendGrid
有一个方法:
- (void)sendWithWeb:(SendGridEmail *)email successBlock:(void(^)(id responseObject))successBlock failureBlock:(void(^)(NSError *error))failureBlock
那你有没有办法像编辑如下
- (void)sendWithWeb:(SendGridEmail *)email successBlock:(void(^)(id responseObject))successBlock failureBlock:(void(^)(NSError *error))failureBlock
{
NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST"
URLString:self.baseURL
parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
for (int i = 0; i < email.imgs.count; i++)
{
UIImage *img = [email.imgs objectAtIndex:i];
NSString *filename = [NSString stringWithFormat:@"image%d.png", i];
NSString *name = [NSString stringWithFormat:@"files[image%d.png]", i];
NSLog(@"name: %@, Filename: %@", name, filename);
NSData *imageData = UIImagePNGRepresentation(img);
[formData appendPartWithFileData:imageData name:name fileName:filename mimeType:@"image/png"];
}
}
error:nil];
AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
NSURLSessionUploadTask *uploadTask;
uploadTask = [manager
uploadTaskWithStreamedRequest:request
progress:^(NSProgress * _Nonnull uploadProgress) {
// This is not called back on the main queue.
// You are responsible for dispatching to the main queue for UI updates
dispatch_async(dispatch_get_main_queue(), ^{
//Update the progress view
});
}
completionHandler:^(NSURLResponse * _Nonnull response, id _Nullable responseObject, NSError * _Nullable error) {
if (error) {
NSLog(@"Error: %@", error);
failureBlock(error);
} else {
NSLog(@"%@ %@", response, responseObject);
successBlock(responseObject);
}
}];
[uploadTask resume];
}
这样你必须编辑方法。 根据您的要求做其他的更改。
注意
那不是测试代码。它的例子。
+0
谢谢你,哟很多@Piyush Patel。 – sarita
只是更新Pod版本的'SendGrid'与最新版本,像'pod'SendGrid','〜> 0.3.0'' –
@PiyushPatel,我已经做了同样的方式,如你所说。但是pod错误仍然存在。 – sarita
只需用最新版本更新SendGrid的波德版本,像豆荚“AFNetworking”,“〜> 2.0” – Wos