Developing Hybrid Remote Apps
You can easily convert the FileExplorer SDK sample (github.com/forcedotcom/SalesforceMobileSDK-Shared/tree/master/samples/fileexplorer), which is a hybrid local app, into a hybrid remote app. To convert the app, you redefine the main HTML page as a Visualforce page that is delivered from the server. You can then bundle the CSS and JavaScript resources with the app so that they’re stored on the device.
Let’s start by creating the Visualforce page.
-
In your Salesforce Developer Edition org, create a Visualforce page named “FileExplorer” with the following attributes.
-
Copy the contents of the
samples/fileexplorer/FileExplorer.htmlfile into the FileExplorer Visualforce page. -
Delete the
<!DOCTYPE html>directive at the top of the inserted content. -
Save your work.
Next, create a hybrid remote app to contain the sample code.
-
cdto the directory where you want to develop your app. The only requirement is that this directory cannot already contain a subdirectory named “fileexplorer”. -
In a Terminal window or command prompt, run
forcehybrid createwith the following values:Platform: ios,androidApplication type: hybrid_remoteApplication name: fileexplorerPackage name: com.salesforce.fileexplorerOrganization name: Acme Apps, Inc.Start page: apex/FileExplorerOutput directory: < press RETURN> -
In a text editor, open
fileexplorer/www/bootconfig.jsonand change the following properties as follows:These settings configure your app to be a hybrid remote app.
-
Return to your Terminal window or command prompt, and then type:
Done! To run the Android target, import the <my_app_directory>/fileexplorer/platforms/android folder into Android Studio and run the app. Or, to run the iOS target, import the <my_app_directory>/fileexplorer/platforms/ios/fileexplorer.xcworkspace file into Xcode and run the app. When you test this sample, be sure to log in to the organization where you created the Visualforce page.
Beginning with version 5.0, Mobile SDK followed Apple’s mandate and deprecated the UIWebView class in favor of WKWebView.
To comply with the App Store’s upcoming policy of rejecting apps that use UIWebView, Mobile SDK 8.1 removes all references to that class. As a result, you can no longer use localhost in Mobile SDK hybrid remote apps.