In your HTML5 plugin for Apollo Apps, you can use methods that allow you to access a certain number of "advanced" features of the application or terminal.

The majority of these methods send a JavaScript callback indicating the success or failure of the method.

1. Method : authenticate

You may request that users identify themselves to access a feature, through an "authenticate" method call. In this instance, you may specify which services (Facebook or Twitter) you wish to use for authentication.

Arguments in the URL: 

  • services: possible values: all (by default) |facebook|twitter 
  • skip: possible values:: YES (by default, allows the user to abandon the login process) | NO (force the user to log in) 


If the value "all" is given for the services parameter, a transparent design is added to plugin view to ask the user through which service they wish to authenticate. If the parameter skip is not given (or set to YES), a button will allow the user to abandon the login. If the value is NO, the user will be forced to choose a service to log in.

If the user is already logged in to the app through at least one of the services in the application, the login action will be transparent.

When the authentication process is finished, two callbacks can be called: 

  • gbDidSuccessAuthentication ( socialUser ) 

- gbDidFailAuthentication ( errorMessage )

Example of an authentication request through one of the services (without distinction)
<a href="apollochurchapps://authenticate?services=all">S'authentifier</a>

Example of an authentication request through Facebook only:
<a href="apollochurchapps://authenticate?services=facebook">S'authentifier via Facebook</a>

Example of an authentication request via one of the services (without distinction, authentication mandatory):
<a href="apollochurchapps://authenticate?services=all&skip=NO">S'authentifier</a>

2. Callback : gbDidSuccessAuthentication

The callback gbDidSuccessAuthentication is called if the authentication succeeded. The parameters regarding the user are stored as a callback parameter, via a dictionary.

The method to be implemented must contain a parameter:
- socialUser: a dictionary containing the information pertaining to the authenticated user (the format is described in the following)

Format of the dictionary in the parameter socialUser:

{
    "serviceType" : "facebook" | "twitter",
    "id" : identifiant de l'utilisateur sur le service,
    "profileUrl" : url de profil de l'utilisateur,
    "username" : nom d'utilisateur (username),
    "name" : nom (real name) de l'utilisateur,
    "profilePictureUrl" : url de la photo de profil,
    "gender" : genre ("male" | "female"),
    "birthdate" : date de naissance,
    "language" : langue parlée par l'utilisateur,
    "location" : localisation de l'utilisateur renseignée sur le service,
    "nbConnections" : nombre de connexions de l'utilisateur (amis ou followers),

3. Callback : gbDidFailAuthentication

The callback gbDidFailAuthentication is called if the authentication fails (typically if the user has not consented to the authentication).

The method to be implemented must contain a parameter:
- errorMessage: a message describing the cause of the authentication failure

4. Method : share

You may use the share method to make sharing content in the social networks easy for your users, directly from the sharing module integrated into your Apollo Apps app.

Arguments passés dans l'URL : 

  • text : le texte à partager (doit être URL encodé) 
  • link : (optionnel) le lien à partager (doit être URL encodé) 


 Arguments in the URL:  

  • text: the text to be shared (must be URL encoded) 
  • link (optional): the link to be shared (must be URL encoded- 

Example of a share module with text:
<a href="apollochurchapps://share?text=Hello%20from%20my%20plugin%20!">Partager un texte</a>

Example of a share module with text and a link :
<a href="apollochurchapps://share?text=Hello%20from%20my%20plugin%20!&link=http%3A%2F%2Fwww.apollochurchapps.com">Partager un texte et un lien</a>

5. Method : getmedia

The getmedia method allows you to call a terminal to obtain a photo or a video. You may restrict the type of content that you wish to obtain via this method, as well as the source (direct capture or choice in the albums).

Arguments in the URL : 

  • type : possible values : photo (by default) | video 
  • source : possible values : all (by default) | camera | library 


If the value of the parameter source is left empty or set to "all" (default value), a menu will ask the user to choose if they wish to take a photo (or video) directly, or if they wish to choose one from an album. The value of the parameter type is transparent to the user: the user can only choose the corresponding media in the selection menu.

When the authentication process is finishes, two callbacks can be called: 

  • gbDidSuccessGetMedia ( data, src )
  • gbDidFailGetMedia ( errorMessage ) 


Example of a method call getmedia: (asks the user for a photo, distinct from the camera)
<a href="apollochurchapps://getmedia">Capturer ou choisir une photo</a>

Example of a method call getmedia (opens the camera)
<a href="apollochurchapps://getmedia?type=photo&source=camera">Prendre une photo</a>

Example of a method call getmedia (request to choose a video from an album):
<a href="apollochurchapps://getmedia?type=video&source=library">Choisir une vidéo</a>

6. Callback : gbDidSuccessGetMedia

The callback gbDidSuccessGetMedia is called if the media retrieval was successful.

The method to implement must comprise two parameters:
- data: the raw image or video data
- src: the pathway to the resource on the drive

7. Callback : gbDidFailGetMedia

Le callback gbDidFailGetMedia est appelé si la capture du media a échoué.

La méthode à implémenter doit comporter un paramètre :
- errorMessage : un message décrivant la cause de l'échec

The callback gbDidFailGetMedia is called if the media retrieval failed.

The method to be implemented must contain a parameter:
- errorMessage: a message describing the reasons for failure. 

8. Method : getlocation

The method getlocation allows you to call the terminal to obtain the user's geolocation data. This method does not require any arguments.

It may send one of two callbacks:
- gbDidSuccessGetLocation ( lat, long )
- gbDidFailGetLocation ( errorMessage )

9. Callback : gbDidSuccessGetLocation

The callback gbDidSuccessGetLocation is called if the geolocation of the user succeeded.

The method to be implemented must contain two parameters:

- lat: latitude of the user
- long: longitude of the user

10. Callback : gbDidFailGetLocation

The callback gbDidFailGetLocation is called if the geolocation of the user failed.

The method to be implemented must contain a parameter:
- errorMessage: a message describing the reason of the failure

11. Method : gettimezoneoffset

The method gettimezoneoffset allows you to call the terminal to get the time difference between UTC time and local time, in minutes.

It will send one callback :
- gbDidSuccessGetTimezoneOffset ( offset )

12. Callback : gbDidSuccessGetTimezoneOffset

The callback gbDidSuccessGetLocation is called when the difference is got.

The method to be implemented must contain this parameter:

- offset: time difference between UTC time and local time, in minutes

13. Method : getuser

The method getuser allows you to call the terminal to obtain all the user's informations. This method does not require any arguments.

It may send one of two callbacks:
- gbDidSuccessGetUser ( user )
- gbDidFailGetUser (errorMessage)

14. Callback : gbDidSuccessGetUser

The callback gbDidSuccessAuthentication is called if an user is logged in the app. The parameters regarding the user are stored as a callback parameter, via a dictionary.

The method to be implemented must contain a parameter:
- user: a dictionary containing the information pertaining to the authenticated user (the format is described in the following)

Format of the dictionary in the parameter socialUser:

{
    "userId" : identifiant de l'utilisateur sur le service,
    "userName" : nom d'utilisateur (username),
    "displayName" : nom (real name) de l'utilisateur,
    "email" : " email de l'utilisateur,
    "photoUrl" : url de la photo de profil,
    "location" : localisation de l'utilisateur renseignée sur le service,
    "description" : description de l'utilisateur,     "socialAccounts" : {
        "facebook" : url du compte facebook de l'utilisateur,
        "twitter" : url du compte twitter de l'utilisateur
    },
    "internAttribs" : {
        "[FIELD_ID_FROM_BACKOFFICE]" : {
            "name" : Titre du champ correspondant renseigné dans le backoffice,
            "value" : Valeur du champ correspondant renseignée par l'utilisateur
        }
    }

15. Callback : gbDidFailGetUser

The callback gbDidFailGetUser is called if there's no user logged in the app.

The method to be implemented must contain a parameter:

  • errorMessage: a message describing the reason of the failure
Did this answer your question?