I use the following function to get the optimal route.
https://wse.ls.hereapi.com/2/findsequence.json?start=25.082621,121.583021&destination1=25.097258,121.517384&destination2=25.041825,121.514988&destination3=25.026060,121.527532&destination4=25.034607,121.488616&destination5=25.063467,121.539141&destination6=25.070833,121.531389&destination7=25.023056,121.505278&destination8=25.093102,121.532366&destination9=25.094807,121.529036&destination10=25.075230,121.560761&destination11=25.093102,121.532366&destination12=25.118899,121.470798&mode=fastest;car&&apiKey=...
And try to use this (HERE SDK FOR IOS (PREMIUM EDITION) V3.17) :
NMARoutingMode *routingMode = [[NMARoutingMode alloc] initWithRoutingType:NMARoutingTypeFastest transportMode:NMATransportModeScooter routingOptions:NMARoutingOptionAvoidHighway];
NMACoreRouter *coreRouter = [[NMACoreRouter alloc] init];
coreRouter.connectivity = NMACoreRouterConnectivityOnline;
[coreRouter calculateRouteWithStops:stops routingMode:routingMode completionBlock:^(NMARouteResult * _Nullable routeResult, NMARoutingError error) {
}];
to bring out NMARouteResult, but it only respond NMARoutingErrorInvalidOperation
How do I solve the problem?
The error indicates that another request is already being processed. Please make sure you are not calling the route calculation until the result of the previous request is returned.
Related
I have a very hard time figuring out how to do this from the iOS app programmatically.
Im using (besides other) the following classes from github:
https://github.com/hybrdthry911/ELStripe
Class: ELCharge.m
+(ELCharge *)charge{
return [[ELCharge alloc]init];
}
(*****************code in between ************************)
//Will attempt to charge either a customer or card. Exactly one must exist
per charge. If multiple or neither exist an exception will be raised.
//Warning: This is the final step it will APPLY A CHARGE TO THE
ACCOUNT.
-(void)createChargeWithCompletion:(ELChargeCompletionBlock)handler{
[ELCharge createCharge:self completion:handler];
}
+(void)createCharge:(ELCharge *)charge completion
(ELChargeCompletionBlock)handler{
NSError *chargeError;
if (![charge validForProcessingWithError:&chargeError]) {
handler(nil,chargeError);
return;
}
if (!chargeError) {
[ELStripe executeStripeCloudCodeWithMethod:#"POST"
prefix:#"charges" parameters:[ELCharge
dictionaryForCreatingCharge:charge] completionHandler:^(id
jsonObject, NSError *error) {
handler([ELCharge
chargeFromParseStripeDictionary:jsonObject],error);
}];
}
}
In the iOS class, I do the following in order to create a test charge:
//create an automatic charge in stripe from an existing customer with card
attached to him
-(void) executeChargeInStripe:(UIButton*)sender
{
ELCharge *charge = [ELCharge charge];
//Assign the charge properties
charge.customerID = #"cus_72xvQI6Q5IC9it";
charge.currency = #"USD";
NSNumber *chargeAmount = [NSNumber numberWithInt:111];
charge.amountInCents = chargeAmount;
//Call ChargeMethod from Github Framework
[ELCharge createCharge:charge completion:^(ELCharge *charge, NSError
*error) {
if (!error) {
//code for normal handling
NSLog(#"Charge has been made successfully");
} else {
// error code handling
NSLog(#"Charge NOT made");
}
}];
}
Im passing this to the following clould code:
Parse.Cloud.define("stripeHTTPRequest", function(request, response)
{
//Check for valid pre/suf/postfixes, if they are not there do not include
them.
var prefix = request.params["prefix"];
var suffix = "";
var postfix = "";
var secondPostfix = "";
if (!isEmpty(request.params["suffix"])) suffix =
'/'+request.params['suffix'];
if (!isEmpty(request.params["postfix"])) postfix =
'/'+request.params['postfix'];
if (!isEmpty(request.params["secondPostfix"])) secondPostfix =
'/'+request.params['secondPostfix'];
//call from parse to stripe done by http request as parse/stripe api
uncomplete
Parse.Cloud.httpRequest(
{
method: request.params["method"],
//Create URL from base url and pre/suf/postfixes
url: 'https://'+STRIPE_API_BASE_URL + prefix + suffix + postfix +
secondPostfix,
headers: {
'Authorization': "Bearer " + STRIPE_SECRET_KEY
},
params:request.params["params"],
success: function(httpResponse)
{
//response text is a json dictionary
response.success(httpResponse.text);
},
error: function(httpResponse)
{
response.error(httpResponse.text);
}
});
});
Im now getting the following error:
Charge NOT made (my error message from the IOS class I created).
Im really surprised that I recieve neither an error in Parse Cloud nor in Stripe.
If for example, I use an already used token instead of the customerID, I have an error in both. So the connection seems to work I assume, maybe there is something which I do wrong in the iOS class.
Thank you!
have you reverted your Parse JavaScript SDK to 1.5.0? Anything past 1.5.0 is no longer supported.
I am trying to use Magento's api using SOAP request in iOS.
I am using SOAPEngine to make requests and retrieve the data.
I am able to login using the following code
self.soap = [[SOAPEngine alloc] init];
self.soap.userAgent = #"SOAPEngine";
self.soap.delegate = self; // use SOAPEngineDelegate
// each single value
[self.soap setValue:#"adminUserName" forKey:#"username"];
[self.soap setValue:#"adminPassword" forKey:#"apiKey"];
// service url without ?WSDL, and you can search the soapAction in the WSDL
[self.soap requestURL:#"http://192.168.1.50/projects/usapool/api/"
soapAction:#"http://192.168.1.50/projects/usapool/api/login"];
but when I try to call the catalog_product.list as mentioned on catalog_product.list API with filters as follows
NSMutableDictionary *filterDictionary = [[NSMutableDictionary alloc] init];
[filterDictionary setValue:#"28" forKey:#"product_id"];
// each single value
[self.soap setValue:sessionId forKey:#"sessionId"];
[self.soap setValue:#"catalog_product.list" forKey:#"resourcePath"];
[self.soap setValue:filterDictionary forKey:#"filters"];
// service url without ?WSDL, and you can search the soapAction in the WSDL
[self.soap requestURL:#"http://192.168.1.50/projects/usapool/api/"
soapAction:#"http://192.168.1.50/projects/usapool/api/call"];
I get the array of all the products and filter is not applied.
Does anybody know how to apply the filters in this case?
I'm writing a native iOS client to interact with a Node.js server using the Socket.IO-objc wrapper. I'm currently able to send individual events to the server just fine. However, the server is using Socket.IO-stream to handle upload file streams, and I need to make my iOS code interact with it somehow. My socket.io wrapper doesn't seem to have any relevant API for accomplishing this. The receiving server.js code is like:
io.sockets.on('connection', function (socket) {
console.log("connection occurring");
ss(socket).on('uploadFile', function (stream, data, callback) {
//...I can't get a 'stream' to this event for it to work with
});
socket.on('passwordLogin', function (data, callback) {
//...I can cause these kind of events just fine
});
//...other event declarations
}
I typically call events in this manner, and it works fine for 'socket.on' declared events:
[_socket sendEvent:#"passwordLogin"
withData:#{...login info...}
andAcknowledge:aCallbackBlock];
I figure I need to expand Socket.IO-objc, unless there is something I'm missing, with something like:
//TODO: Attempt to expand SocketIO to include streams.
- (void) sendEvent:(NSString *)eventName withStream:(NSStream*) stream withData:(id) data andAcknowledge:(SocketIOCallback) function
{
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithObject:eventName forKey:#"name"];
// do not require arguments
if (data != nil) {
[dict setObject:[NSArray arrayWithObject:data] forKey:#"args"];
}
SocketIOPacket *packet = [[SocketIOPacket alloc] initWithType:#"event"];
packet.data = [SocketIOJSONSerialization JSONStringFromObject:dict error:nil];
packet.pId = [self addAcknowledge:function];
//Is this even a valid approach?
packet.stream = stream;//<--NEW BIT
if (function) {
packet.ack = #"data";
}
[self send:packet];
}
I'm pretty lost as to what exactly to do, having never really worked with server communications before. I've followed Apple documentation about the built-in NSStream and CFStream objects, but it doesn't seem to get me any closer to interacting with the server's event. Any help is appreciated, as I'm a bit at my wit's end.
I am trying to upload an image file to the server. I am applying the example from https://github.com/valentinradu/WhiteRaccoon
Here is the code:
UIImage *image = [UIImage imageNamed:#"hotel1.jpg"];
NSData *imageData = UIImageJPEGRepresentation(image, 0);
WRRequestUpload * uploadImage = [[WRRequestUpload alloc] init];
uploadImage.delegate = (id)self;
//for anonymous login just leave the username and password nil
uploadImage.hostname = #"***.***.***.***";
uploadImage.username = #"-------";
uploadImage.password = #"-------";
//we set our data
uploadImage.sentData = imageData;
//the path needs to be absolute to the FTP root folder.
//full URL would be ftp://xxx.xxx.xxx.xxx/space.jpg
uploadImage.path = #"/android_images/image.jpg";
//we start the request
[uploadImage start];
but it gives error -[WRRequestListDirectory stream:handleEvent:] [Line 1004] Unknown error!
am I missing anything. Please help me out.
in the uploadimage.hostname property try skipping the ftp:// part and enter the host address alone for eg: "qwerty.com" instead of "ftp://qwerty.com" , it solved for me, and make sure that the authentication details given are correct. cheers !!
if you are using BlackRaccoon,
Please make one line change in BRRequest.m file.
In - (id)initWithDelegate:(id<BRRequestDelegate>)aDelegate Function.
Change
self.passiveMode = YES;
to
self.passiveMode = NO;
And it will work....
That change worked for me.
I tried with the below code snippet taken from the website after replacing with my namespace and realm. But when i try to run the application, I am receiving the parser error like
Entity: line 1: parser error : Start tag expected, '<' not found
WACloudAccessControlClient *acsClient =
[WACloudAccessControlClient
accessControlClientForNamespace:#“iostest-walkthrough”
realm:#“uri:wazmobiletoolkit”];
[acsClient showInViewController:self
allowsClose:NO
withCompletionHandler:^(BOOL authenticated)
{
if (!authenticated) {
NSLog(#"Error authenticating");
} else {
WACloudAccessToken *token = [WACloudAccessControlClient sharedToken];
NSString *securityToken = [token securityToken];
}
}];
I am not able to understand the issue clearly.
Please guide me with example. Thank you
I would suggest looking at the samples here:
https://github.com/WindowsAzure-Toolkits/wa-toolkit-ios
You can also look at this for getting started:
http://www.wadewegner.com/2011/05/windows-azure-toolkit-for-ios/
My guess is that you didn't #import something you need.