4D for iOS: Easily interact with Apple Native apps

With 4D for iOS, we are always thinking about mobile-friendly features. The primary purpose is to help developers provide the best user experience for their mobile applications. And that’s why, with 4D v19 R3, we’re shipping action input controls.

What is an input control?

As a reminder, with formatters using iOS code available in the gallery, you can easily interact with native iOS apps from your mobile phone. For example, you can automatically dial a phone number by clicking on a phone number field or open the Safari App by simply clicking on a URL.

Action input controls follow the exact same logic. Using them, you will add some sorts of modules in your action forms to interact with Apple native apps. Several ones are already available in the gallery such as :

  • phoneContact: to search for a contact phone number directly from the Apple Contact app
  • emailContact: to search for a contact email directly from the Apple Contact app
  • currentLocation and currentLocationAddress: to fill the current location of the app user with coordinates (latitude and longitude) and addresses automatically.

They were designed to make your users’ lives easier by opening up new perspectives through smooth interactions with the iOS environment.

And best of all, you are totally free to create your own input controls, integrate them in your mobile projects, and share them with the community!

How does this work?

To use them in your mobile projects, you’ll need to include them in your database for formatters or custom list and detail forms. To do this, create a special “inputControls” folder, download the input control that suits you best from the gallery, unzip it and drag it into the inputControls folder.

This action input control will then be available and selectable in the Action section, in the parameter properties, depending on the type of your action parameter.

Here is an example

In our example, we are going to update a contact phone number and an email. The novelty here is that we are going to get data from the Apple Contact app. So, in that case, we simply use the phoneContact and the emailContact action input controls available in the gallery.

How it looks on the user’s app

The user will just have to select the editContact action from the action menu to display the action form in the mobile app. From there, the action input controls will then give him the ability to select a phone number and an email from the Apple Contact app.


So as you can see, action input controls are another great way to interact with Apple Native apps and add nice interaction in your mobile apps.

How it looks in the project editor


Then, we need to create the edit action in the On Mobile App Action database method to get our example to work.

edit action 4D code

Here is an example of the 4D code in the On Mobile App Action database method, for the edit preset action, using the  MobileAppServer component:

#DECLARE($request : Object)->$response : Object
$response:=New object("success"; False)

Case of 
 : ($action.name="editContact") // edit@

  var $entity; $status : Object   

  For each ($key; $request.parameters)
  End for each

  $status:=$entity.save()  // save the entity

  If ($status.success)
    $response.success:=True  // notify App that action success
    $response.dataSynchro:=True  // notify App to refresh the selection
    $response.statusText:="Failed to edit"  // $status.statusText
  End if 
End case 

As a reminder, the MobileAppServer component, which is built in 4D, gives you access to various utility methods to speed up your 4D mobile app backend coding.

Don’t hesitate to give us feedback on the 4D forum, and check out the documentation for more details!

David Azancot
• 4D for iOS Product Owner •David Azancot joined the 4D Product team as a Product Owner in 2017. He's in charge of writing the user stories and translating them into functional specifications. His role also includes making sure that feature implementations meet customers' needs.David graduated with an MBA in Marketing, Internet and Mobility from the Leonard De Vinci Institute and began his career in 2011 with a mobile start-up company, later acquired by Madvertise (a mobile marketing group). Passionate about mobile interfaces, he was the natural choice to develop interactive mobile ad formats for the group in 2015. In parallel, David has been developing his own iOS and Android applications since 2012.