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.
1<apex:page docType="html-5.0" showHeader="false" sidebar="false">2<!-- Paste content of FileExplorer.html here, but remove the “<!DOCTYPE html>” directive -->3</apex:page>
Copy the contents of the samples/fileexplorer/FileExplorer.html file 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.
cd to 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 create with the following values:
Platform:
ios,android
Application type:
hybrid_remote
Application name:
fileexplorer
Package name:
com.salesforce.fileexplorer
Organization name:
Acme Apps, Inc.
Start page:
apex/FileExplorer
Output directory:
<press RETURN>
In a text editor, open fileexplorer/www/bootconfig.json and 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:
1cordova prepare
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.
Using localhost in Hybrid Remote Apps for iOS
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.
We've Moved
Welcome to the new home of the Mobile SDK Developer Guide! For now, the Japanese guide can be found in PDF form.