Skip to content

Instantly share code, notes, and snippets.

@matzew
Last active December 14, 2015 20:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save matzew/3e7e6218d6cea94f65ad to your computer and use it in GitHub Desktop.
Save matzew/3e7e6218d6cea94f65ad to your computer and use it in GitHub Desktop.
Server API for the "Application Abstraction"

Server API for the "Application Abstraction"

On the server the DEVELOPER (or Admin) creates a logical abstraction for a "Push enabled" Application. This logical unit has different mobile views/versions (e.g. a concrete iOS(or Android) application:

/**
 * Server side abstraction of a "AeroGear Unified Push" application.
 * 
 *  This representation can be configured to have several/different/multiple mobile
 * applications, to receive messages.
 *  
 */
 

// TODO: Name it ServerApplication?
// TODO: Name it PushApplication?
// TODO: Name it ServerPushApplication?
public interface Application {

    // some name/desc....
    void setName(String name);
    String getName();
    void setDescription(String descriptiom);
    String getDescription();
    
    /**
     * Returns the App-Key, generated by the AG server. The App-Key is used to send messages
     * to a server application, which broadcasts them to the (desired) mobile application
     * that are associated with the app
     */
    // app id key, generated by the AG server
    String getApplicationKey();

    /**
     * List of all mobile variations for this server side abstraction
     * (e.g. one iOS app and/or one Android app)
     */
    List<? extends MobileApplication> getMobileApplications();
    
    /**
     * Adds a new {@link MobileApplication} to the server abstraction;
     * @param mobileApp
     */
    void addMobileApplication(MobileApplication mobileApp);

    /**
     * Removes a {@link MobileApplication} to the server abstraction;
     */
    void removeMobileApplication(MobileApplication mobileApp);
    
}

The server side aspect has different mobile views, that are (in an abstract way) represented by the MobileApplication type:

/**
 * Abstraction of a mobile application (e.g. iOS, Android Application or Mobile Web(JS)).
 * 
 * One instance of this type represents EXACTLY one application
 * (e.g. Twitter-iOS What's App-Android)
 */
public interface MobileApplication {
    /**
     * Returns a generated ID to represent this mobile application.
     * The ID can be used to send messages to a single mobile app
     * (e.g. only iOS users receive a push message)
     */
    // really needed ?
    String getMobileAppId();
    
    /**
     * Returns complete list of all installed instances of
     * this mobile application 
     */
    List<MobileApplicationInstance> getInstances();
    void addInstance(MobileApplicationInstance instance);
    void removeInstance(MobileApplicationInstance instance);
    
}

The iOS specific version:

/**
 * An iOS version of the mobile app....
 */
public interface iOSApplication extends MobileApplication {

    /**
     * The exported .p12 file from the Apple Developer portal.
     * The file is required for establishing an APNs connection.
     */
    void setCertificate(String pathToP12File);
    
    /**
     * Passpharase for the {@link setCertificate}.
     * The pass phrase is required for establishing an APNs connection;
     */
    void setPassphrase(String topsecret);
    
}

The Android specific version:

/**
 * An Android version of the mobile app....
 */
public interface AndroidApplication extends MobileApplication {
    
    /**
     * API key, from the Google API console. Required to submit
     * messages to the Google Cloud Messaging System.
     */
    void setGoogleAPIKey(String apiKey);

}

Each of the concrete mobile applications (e.g. iOS version/view) has several installations, on real devices. Every installed application is represented by the MobileApplicationInstance type:

/**
 * Each instance represents exactly one installation, per phone
 */
public interface MobileApplicationInstance {

    /**
     * The device token (iOS) or registration-id (Android), generated by
     * operating system of the phone 
     */
    void setDeviceToken(String token);
    String getDeviceToken();

}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment