3

How can I call a method in Salesforce from iOS?

I am wanting to call submitToIntegration(application__c app) :

public without sharing class blogic_Application {

    public static boolean poachTriggerFirstRun = true;
    public static boolean syncllTriggerFirstRun = true; 

    public static string submitToIntegration(application__c app){
        return submitToIntegration(app,false);
    }
}

I assume I will be using some variation of this method within the Salesforce iOS SDK:

  • (id)requestWithMethod:(SFRestMethod)method path:(NSString *)path queryParams:(NSDictionary *)queryParams

Also, what do I need to do the salesforce code to make it visible to iOS?

Thanks

  • Can you give an example of what you tried doing that didn't work? Salesforce has pretty thorough documentation of what you need to do to get the basic SDK calls working. – Michael Welburn Oct 17 '13 at 19:08
  • 1
    Welcome to SFSE, Tyler. Have you read any of the documentation on creating/consuming web services in Salesforce? Salesforce provides standard SOAP and REST-based services or you can create custom ones, as necessary. – Mike Chale Oct 17 '13 at 19:09
  • Here's a good starting location: wiki.developerforce.com/page/Mobile_SDK – Mike Chale Oct 17 '13 at 19:10
1

You can use the webservice keyword in Apex Code to generate a file that can export a WSDL, which then becomes a simple generic "WSDL-driven development in iOS" question, or you can use @RestResource on a class, which turns this question into a simple "Accessing REST resources in iOS" question. Either way, there doesn't appear to be anything in the mobile toolkit that specifically addresses calling functions directly (executeAnonymous isn't part of the SDK, so there's no direct means of calling the function).

  • can you point me to sample code that does this? – Tyler Harrington Oct 17 '13 at 19:48
  • I was hoping you had enough experience with this, as my experience with iOS (or even Objective-C) is woefully limited because I've never been able to afford a $1000+ computer system in one go (i.e. any decently powerful Mac). However, I'll take a stab at it and see if I can come up with anything. – sfdcfox Oct 17 '13 at 20:29
  • @sfdcfox I think you can abstract that snippet of code he wrote (it is static after all) and then write a REST Resource that simply calls it. – Michael Welburn Oct 18 '13 at 3:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.