Mobile SDK / Endpoint APIs

These FAQs briefly summarise key points regarding using Composr's Mobile SDK to develop mobile apps for your Composr site.

For more information, check out these tutorials:

While covered in the "Themeing" category, you should also check out this tutorial:
Question What is Composr Mobile SDK?
Answer Composr Mobile SDK (CMS SDK) is a toolkit designed for experienced iOS and Android developers to build mobile apps that integrate with a Composr-powered website. It offers both Composr-specific integrations and a collection of standalone utilities for building apps, providing a common base between iOS and Android akin to the PHP and Composr APIs, enabling easier code porting while maintaining a native experience.
Question How can I obtain Composr Mobile SDK?
Answer The iOS/Android SDK can be found on GitLab at: Composr ecosystem / Composr Mobile SDK · GitLab.

To connect to a Composr site, you will need to install the composr_mobile_sdk addon, which is not bundled. This addon provides scripting to generate app assets from the Composr site.
Question What is the purpose of the Composr Mobile SDK Toolkit?
Answer The Toolkit, part of the composr_mobile_sdk addon, aids in mirroring Composr website resources into a mobile app. It includes tools for generating iOS/Android string resources from language files and exporting theme images in a directory structure suitable for iOS/Android app image assets.
Question How do I access the server-side API for my mobile app?
Answer The server-side API can be accessed via HTTP calls to http://yourbaseurl/data/endpoint.php. Results are returned in JSON format. The API utilizes endpoints with a 'hook' name and a 'hook type' categorization. Both REST-style and GET-parameter style requests are supported, with the latter recommended for simplicity.
Question How does authentication work with the server-side API?
Answer Authentication is handled automatically using cookies, similar to regular website requests. If cookies are not feasible, the response parameters device_auth_member_id_cn/device_auth_pass_hashed_cn/device_auth_member_id_vl/device_auth_pass_hashed_vl from the login endpoint can be resent as POST parameters in subsequent requests.
Question What are some of the default endpoints available in the server-side API?
Answer Default endpoints cover various functionalities, including:
  • Account: join, login, lost_password, setup_push_notifications
  • Misc: contact_us
  • Content: commandr_fs

Specific details on parameters and response data for each endpoint can be found in the documentation.
Question What other approaches exist for mobile integration with Composr?
Answer Other approaches, in various stages of development, include:
  • Tapatalk: A third-party forum app with an official Composr addon, offering a high-quality "out-of-the-box" Composr app experience.
  • Further Composr Mobile SDK development: Plans and issues relating to the SDK's evolution can be found on the Composr tracker, driven by commercial projects and feature sponsorship.
Question What are some key concepts related to mobile app development with Composr?
Answer Essential concepts include:
  • SDK (Software Development Kit): An API implementation, typically as a library.
  • API (Application Programming Interface): A set of rules for software interaction.
  • JSON (JavaScript Object Notation): A common language for structured data transfer over REST.
  • REST (Representational State Transfer): An architectural style for web services.
  • Push notification: A notification sent to a mobile device.
Question How do I set up Composr Mobile SDK in my iOS and Android projects?
Answer iOS (Xcode):
  • Create a new project or open an existing one.
  • Add a Prefix Header file (.pch) if you don't have one, following the provided instructions.
  • Add required frameworks to your project's Build Phases.
  • Add the CMS SDK to your project, then remove references to unwanted files.
  • Set the header search path to the CMS SDK folder in build settings.
  • Add a compiler option for the JsonKit library.
  • Import CMS_SDK.h in your .pch file.

Android (Eclipse):
  • Create a new project or open an existing one.
  • Import CMS SDK into your workspace as an Android project.
  • Ensure "Is Library" is checked in the CMS SDK's "Android" properties tab.
  • Add CMS SDK as a dependent library in your project's properties.
  • Clean and rebuild your project.
Question What are the key classes and utilities provided by Composr Mobile SDK?
Answer CMS SDK provides several classes with utility functions mirroring PHP and Composr APIs, including:
  • CMS_Arrays: Array operations (e.g., implode, explode, list_to_map).
  • CMS_Strings: String manipulation (e.g., strip_tags, html_entity_decode, strpos).
  • CMS_Langs: Localization functions (e.g., do_lang).
  • CMS_Preferences: User preference management.
  • CMS_Timestamps: Timestamp functions (e.g., get_timezoned_date_time, time).
  • CMS_HTTP: Web service interactions (e.g., rawurlencode, json_decode, http_get_contents).
  • CMS_Users: User data and permission checks (e.g., has_page_access, is_staff).
  • CMS_Flow: App flow control (e.g., access_denied, attach_message).
  • CMS_Forms: Form building and management.
  • CMS_Database: SQLite database access and manipulation.
  • CMS_Notification: Push notification handling.
  • CMSNetworkManager: Network request execution and response handling.