I have a couple questions about hybrid development using the Salesforce.com Mobile SDK:

  1. Can I mix javascript and Objective-c code?
  2. In a hybrid-local app can I render visualforce?
  3. Can native iOS apps render visualforce?

1 Answer 1

  1. The local version of an app lives on your phone. In the Salesforce Mobile SDK, these files live in the www folder. They can include your own HTML pages and JavaScript. Basically anything you can build to run in a browser today. MobileSDK apps are built on top of Apache's Cordova, which provides the views (in Obj-C and communication from the view to the app controllers and logic in Obj-C.
  2. Hybrid-local apps can't actually serve up Visualforce but your Hybrid local app can point to a Visualforce page. For example, you could have a hybrid local app that started out in your app's local files, allowed users to navigate through an app locally but then at some point pointed users through an authentication flow, whereby they then arrived on a public Visualforce page as authenticated. the MobileSDK offers a JavaScript API for communicating to the native portion of your app to do things like store authentication credentials.
  3. Native iOS apps can't render Visualforce, since at that point the app wouldn't be native anymore. One of the definitions of a native app is that the UI is fully contained within your app and not derived from the web. Visualforce pages will always be served up from Salesforce.
  • So for your answer to 1, the javascript is essentially compiled in to Obj-C? Therefore outside of the www folder, you could create objective-c code, view controllers for example which are completely independent of the javascript.
    – user8560
    Aug 4, 2014 at 18:49
  • No, it's not compiled, it runs in a cordova view which is essentially a stripped down mobile browser window.
    – greenstork
    Aug 4, 2014 at 18:53
  • so I could not mix objective c code and js/html5?
    – user8560
    Aug 4, 2014 at 18:56
  • Yes, you absolutely can mix code, but HTML/JS does not run in Obj-c, it just runs inside of a web view window that obj-c is responsible for serving up. You can have a local part of your app and a web portion, if that's what you mean by mix. The local portion runs in a cordova web view, which is like running on a mobile browser, referencing local files. The web view runs on some server elsewhere, referencing external files.
    – greenstork
    Aug 4, 2014 at 18:57
  • 1
    I should qualify, you cannot mix native UI with hybrid UI. Hybrid apps all run web applications, with browser-based UI whereas native apps have native UI. Whether it's hybrid local or hybrid remote, the browser is ultimately responsible for the UI.
    – greenstork
    Aug 4, 2014 at 19:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .