我得到了解决方案,我正在使用来自 git hub 的 AFNetworking 库,我正在使用以下链接中给出的库
https://github.com/lognllc/LogNMagento
一些基本步骤
=> 在您的应用程序中导入 LogNMangento 应用程序
=> 在 magento.h
- (void)settingLogin:(completionBlock) completionBlock;
=> 在 magento.m 中
- (void)settingLogin:(completionBlock)completionBlock
{
standardUserDefaults = [NSUserDefaults standardUserDefaults];
array =[standardUserDefaults objectForKey:@"Prefs"];
client = [[MagentoClient alloc] initWithBaseURL:[NSURL URLWithString:[array objectAtIndex:0]]];
[client setDefaultHeader:@"SOAPAction" value:@"urn:Mage_Api_Model_Server_HandlerAction"];
[client registerHTTPOperationClass:[SoapRequestOperation class]];
[SoapRequestOperation addAcceptableStatusCodes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(200, 301)]];
[client setDefaultHeader:@"Content-Type" value:@"text/xml; charset=utf-8"];
[client postPath:@"login" parameters:@{@"username":[array objectAtIndex:1], @"apiKey": [array objectAtIndex:2] } success:^(AFHTTPRequestOperation *operation, id responseObject) {
sessionID = responseObject;
completionBlock(sessionID);
} failure:^(AFHTTPRequestOperation *operationData, NSError *error) {
NSLog(@"Response is not get");
sessionID = FAILED_SESSION;
completionBlock(sessionID);
}];
}
=> 在你的课上叫这个
[Magento.service settingLogin:^(NSString *session) {
if(session){
NSLog(@"Session %@",session);
if(![session isEqualToString:@"NULL"])
{
[self.view hideToastActivity];
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
[self.navigationController pushViewController:self.viewController animated:YES];
}
else
{
[self.view hideToastActivity];
[self.view makeToast:@"Please Check Store Info"];
session=nil;
}
}
else{
}
}];
}
else
{
[self.view makeToast:@"Please insert data"
duration:1.0
position:@"bottom"
];
}
是的,还可以在基本网址中对 magento.m 的 INIT 进行一些更改