After digging around in the Salesforce MobileSDK for Android, it seems clear that both of my problems are due to design decisions within the Android version of the SDK.
For #1, suppressing the login page title bar probably could be accomplished by changing an AndroidManifest.xml
(possibly the app's; certainly the MobileSDK plugin's), except that the code assumes that title bar is present, and causes a null pointer exception if it isn't. So you'll have to modify the code.
First, update the plugin's manifest (plugins/com.salesforce/src/android/libs/SalesforceSDK/AndroidManifest.xml
), and find:
<!-- Login activity -->
<activity android:name="com.salesforce.androidsdk.ui.LoginActivity"
android:theme="@style/SalesforceSDK.ActionBarTheme" />
and change android:theme
to "@android:style/Theme.Black.NoTitleBar.Fullscreen"
. Next, open:
app/plugins/com.salesforce/src/android/libs/SalesforceSDK/src/com/salesforce/androidsdk/ui/LoginActivity.java
find the onCreate
and comment out these two lines:
// We'll show progress in the window title bar
getWindow().requestFeature(Window.FEATURE_PROGRESS);
getWindow().requestFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
Finally, find method loadingLoginPage
, and replace ab.setTitle(loginUrl);
with:
if (ab!=null) {
ab.setTitle(loginUrl);
}
You'll need to rebuild the sdk; cordova
doesn't seem to do so for me. I use the following:
cd platforms/android
ant debug # or ant release for release version
For #2, serving files from localhost inside the login view, it looks like the app's main web view is an instance of SalesforceDroidGapActivity
which has support for localhost urls (via SalesforceIceCreamWebViewClient
), but the login page is an instance of LoginActivity
which extends AccountAuthenticatorActivity
, and has no localhost support. Dropping in one for the other doesn't look practical either. I think the login view should have access to file://
urls, but I'm not sure if the cordova js file and plugins would be accessible via such a file url; I'll update this post if I learn more.
Best Answer
It is possible to use Mobile SDK along with Communities. There is a detailed tutorial available for it here.
If you use the Mobile SDK, your app can launch your community login page in a WebView for authentication purposes.
For Android, you would specify the community login URL in
res/xml/servers.xml
file in your application project. For example:For iOS, you set the Custom Host in your app’s iOS settings bundle. If you’ve configured this setting, it will be used as the default connection. Add the following key-value pair to your
<appname>-Info.plist
file:There is no way to bypass this process. Once you are authenticated, you can use the REST wrappers provided by Mobile SDK to invoke any API that you want.
If you do not want to use the Mobile SDK, you need to handle the Community auth and REST handling by yourself.