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();
}