avimobilelib 0.0.3 copy "avimobilelib: ^0.0.3" to clipboard
avimobilelib: ^0.0.3 copied to clipboard

Library for accessing the AVI API.

avimobilelib #

Library for accessing the AVI API.

For more information regarding AVI and its services, visit aviapp.mx

Initializing the library #

Avi avi = Avi(context);
avi.init(
    // API Key
    "12345abcde",
    // Secret
    "abcde12345",
    // Sandbox flag
    true,
    // Google API key for Google Maps and Google Places (must be included in the Android manifest)
    "AIzaxxxxxxxxxxxxxxxxxx"
);

Once the library is initialized you can recover the Avi abject by the static shared property.

Avi avi = Avi.shared;

Checking for an existing session #

Avi.shared.getSession().then((aviUser) {    
    if(aviUser != null)
    {
        // A session exists
    }
    else
    {
        // No session
    }
});

Login a user #

Create the AviUser object with the user credentials

AviUser aviUser = AviUser();
aviUser.name = "Alex";
aviUser.lastName = "Del Piero";
aviUser.email = "alex@delpiero.com";
aviUser.telephone = "1234567890";

Pass that AviUser object to the login method

Avi.shared.login(aviUser).then((aviUser) {
  if (aviUser != null)
  {
    // Login successful
  }
});

Logout current user #

Avi.shared.logout().then((ok) {
  if (ok)
  {
    // Logout successful
  }
});

Show the AVI widget #

The AVI widget handles the request of services, cancellations of services and tracking of running services (A user must be logged in).

Avi.shared.showMainWidget();