Rhodes provides access to the device’s local phone book and stored contacts via the Ruby class RhoContact.
To allow read/modify personal information and contacts enable the pim capability. This is done by adding the following lines to build.yml:
capabilities: - pim
Refer to the PIM Contacts API methods to perform the following functionality.
The Contact Properties lists the contact properties that are supported for all platforms, and additional contact properties supported on Android and iOS.
Example of returning a hash of hashes of all the contacts stored in the phonebook (index):
Rho::RhoContact.find(:all)
Example for Android and iOS of finding the number of contacts in the phonebook:
Rho::RhoContact.find(:first)
It is allowed to pass additional params hash at all platforms. Platforms that has no extended functionality will just skip these
Example of returning a hash of all properties of the contact identified by the provided id (show):
Rho::RhoContact.find(@params['id'])
Example of finding with conditions:
@count = Rho::RhoContact.find(:count, :conditions => {:phone => 'not_nil'}) if @params['offset'] @offset = @params['offset'].to_i else @offset = 0; end @contacts = Rho::RhoContact.find(:all, :per_page => 10, :offset => @offset, :select => ["id", "display_name", "mobile_number"], :conditions => {:phone => 'not_nil'}) @contacts = {} unless @contacts @contacts = @contacts.sort do |x,y| res = 1 if x[1]['display_name'].nil? res = -1 if y[1]['display_name'].nil? res = x[1]['display_name'] <=> y[1]['display_name'] unless res res end
For examples on how to use the API provided by this class, see the view and controller in the /app/Contacts folder in the System API Samples application.
Rhodes provides access to the device’s local calendar and stored events via the Ruby class RhoEvent. Click the links below for detailed information about the methods.
To allow read/modify calendar information enable the calendar capability. This is done by adding the following lines to build.yml:
capabilities: - calendar
Check if the device has a calendar: :::ruby System::get_property(‘has_calendar’)
Example of returning a hash of hashes of all the events stored in the calendar (index): :::ruby Rho::RhoEvent.find(:all)
Example of returning a hash of all the properties of the event identified by the provided id (show): :::ruby Rho::RhoEvent.find(@params[‘id’])
Example of returning a hash of all properties of the events found by specified parameters (index): :::ruby start = Time.utc(2010, ‘jan’, 1, 0, 0, 0) finish = Time.utc(2012, ‘dec’, 31, 23, 59, 59) @@events = Rho::RhoEvent.find(:all, :start_date => start, :end_date => finish, :find_type => ‘starting’, :include_repeating => true)
Create new event in the calendar: :::ruby created_event = Rho::RhoEvent.create!(@params[‘event’])
Update event in the calendar: :::ruby Rho::RhoEvent.update_attributes(@params[‘event’])
Delete event from the calendar: Rho::RhoEvent.destroy(@params[‘id’]))
In Android Device’s, Calendar Event will only be created if the calendar is synced with atleast one mail account.
For examples on how to use the API provided by this class, see the view and controller in the /app/Calendar folder in the System API Samples application.