IOS APP String Command for Function with API

I have made an android app that has the following function and I am using it to call a function and then put in a string command so when the function equals a string my code will run.

Now I am trying to make an iOS app and having trouble finding a similar function that will do this for iOS. I found a function for iOS bellow but it is not working and I dont think it does the same as the Android function.

Any help would be really helpful. I am not a programmer I am a NOOB to all this especially with iOS.

Android CODE

public void callFunction(String coreName, String function, Bundle args, String responseType) {
	BaseFunctionValueReceiver Receiver = new BaseFunctionValueReceiver(handler, 
			FunctionResponse.REQUEST_TYPE_VARIABLE, coreName, responseType); 
	
	SimpleSparkApiService.post(ctx, new String[] { "devices", coreName, function },
			args, Receiver, null);
}

	Bundle args = new Bundle();
			args.putString("params", "colder");
			api.callFunction(device.id, "setTemp", args,"setTemperature");
			//api.getVariableString(device.id, "lampStatus", "showTemperature");

iOS Code

- (void) makeSparkRequest {
 
    NSString *sparkApi = @"https://api.spark.io/v1/devices";
    NSString *deviceId = @"<YOUR_DEVICE_ID>";
    NSString *functionName = @"<YOUR_FUNCTION_NAME>"; // registered to cloud using Spark.function("FUNCTION_NAME", FUNCTION);
    NSString *accessToken = @"<YOUR_ACCESS_TOKEN>";
    
    NSURL *url = [NSURL URLWithString: [NSString stringWithFormat:@"%@/%@/%@\?access_token=%@", 
        sparkApi, 
        deviceId, 
        functionName, 
        accessToken]
    ];
    
    NSLog(@"%@", url);
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
    
    [request setURL:url];
    [request setHTTPMethod:@"POST"];
    [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    
    NSError *error;
    NSURLResponse *response;
    NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
    
    // ... do something with returned data
 
}

I would not really recommend using the ‘official’ app as template, especially if you are a starter.
It has already become a beast with its own logic, has some dependencies on third-party frameworks and is not up-to-date anymore, although it is a good example.
Maybe you’ll take a look at the answers here.

If you want multi-platform capabilities, why not design a web-app? Not only can it be accessed by anything with an internet connection, but it’s only going to be useful when you’ve got an internet connection anyhow. Then you don’t have to go through the hassle of creating multiple apps on multiple platforms, with different programming languages/tools.
If you’re determined to built a platform specific app regardless, then you’d best wait for a tiny bit. I believe an iOS SDK is in the works, meant to be released around the shipping time of the Photon. That should make it a lot easier to develop for iOS.

Thanks for the responses. I figured out how to get the function called with my string parameter. @Moors7 I already have the Android functioning the way I want and the iOS is getting there. I wouldn’t mind making a web-app. Is there is a template web-app out there that has similar functionality to the mobile apps?

Glad you hear you’ve got it working!
There isn’t really a webversion of the Tinker app, but that shouldn’t be that much of a problem. The main reason the Tinker app was made, was to connect your Cores using TI’s SmartConfig. Other than that, the app provides little usability, apart from controlling some pins. If it’s the SmartConfig you’re after, there’s a Java applet that you should be able to use. Everything you can do with the app, you should be able to recreate with a web-app.
There are some web-apps you can look at which provide log-in, function and variables functionalities. I’ve personally used this one a lot, since it’s proven to be very useful, especially while testing:


I tried to recreate the above by using the SparkJS library, mainly to test that out. You can see/use the page here. When you right-click for the source, you can see all the code/files.

What exactly are you trying to make?