GoodBarber's Online Help
Other methods
In your HTML5 plugin for GoodBarber, 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.
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 GoodBarber app.
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="goodbarber://share?text=Hello%20from%20my%20plugin%20!">Partager un texte</a>
Example of a share module with text and a link :<a href="goodbarber://share?text=Hello%20from%20my%20plugin%20!&link=http%3A%2F%2Fwww.goodbarber.com">Partager un texte et un lien</a>
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="goodbarber://getmedia">Capturer ou choisir une photo</a>
Example of a method call getmedia (opens the camera)<a href="goodbarber://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="goodbarber://getmedia?type=video&source=library">Choisir une vidéo</a>
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
Callback : gbDidFailGetMedia
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.
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 )
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
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
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 )
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
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)
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
},
"attribs" : {
"[FIELD_ID_FROM_BACKOFFICE]" : {
"name" : Titre du champ correspondant renseigné dans le backoffice,
"value" : Valeur du champ correspondant renseignée par l'utilisateur
}
}
}
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
Method : print
The method print allows you to print the content of the current plugin page. This method does not require any arguments.