Cross-platform set of libraries with a Unified API
Cordova Plugins
Why would you need to make a definitive choice?
Cross-platform APIs for all your common client-server infrastructure tasks.
Send push notifications to any device, regardless of platform or network (APNs, GCM, SimplePush).
Integrate with your existing security and authentication infrastructure.
Secure offline support and synchronization.
aerogear-ios-cookbook | aerogear-js-cookbook | aerogear-android-cookbook
AeroGear Unified API makes it easier
Pipes in JavaScript
// Create the 'Pipe' for '/developer/' endpoint
var developerPipe = AeroGear.Pipeline([{
name: "developers",
settings: {
baseURL: "rest/"
}
}]).pipes.developers;
// Read
developerPipe.read({
success: function(data) {
...
$("#developers").html(buildDevRows());
},
error: function (error) {
console.log(error);
}
});
Persistence abstraction
From aerogear-js-cookbook
Store in JavaScript
// Create an IndexedDB store name "recipes"
// IndexedDB needs to be opened, see "auto" setting
// If IndexedDB is not supported in your browser, fall back
var dm = AeroGear.DataManager({
name: 'recipes',
type: 'IndexedDB',
settings: {
auto: true
}
});
app.agStore = dm.stores.recipes;
...
// Add an id to the data
data.id = uuid.v4();
// Here we are calling the stores "save" method.
app.agStore.save( data ).then( function( data ) {
app.renderRecipeList( data );
app.home();
});
Going further with AeroDoc backend example on how to use Sender API.
Client side: Register at first start-up of the app
public class RegisterActivity extends Activity {
public void registerDeviceOnPushServer(String alias) {
try {
PushConfig config = new PushConfig(new URI(UNIFIED_PUSH_URL), GCM_SENDER_ID);
config.setVariantID(VARIANT_ID);
config.setSecret(SECRET);
config.setAlias(alias);
config.setCategories(Arrays.asList("lead"));
PushRegistrar registrar = registrations.push("registrar", config);
registrar.register(getApplicationContext(), new Callback() {
@Override
public void onSuccess(Void data) {
}
@Override
public void onFailure(Exception e) {
Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_SHORT).show();
}
});
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
Test sending push messages:
Server side and Client side:
Seamless integration with Pipe
Some people call it a dance, it's more a discussion
Bob wants to grant access to Shootn'Share mobile app to upload images to GoogleDrive
OAuth2 Configuration with Objective-C
// start up the authorization process
AGAuthorizer* authorizer = [AGAuthorizer authorizer];
_restAuthzModule = [authorizer authz:^(id config) {
config.name = @"restAuthMod";
config.baseURL = [[NSURL alloc] initWithString:@"https://accounts.google.com"];
config.authzEndpoint = @"/o/oauth2/auth";
config.accessTokenEndpoint = @"/o/oauth2/token";
config.clientId = @"873670803862-g6pjsgt64gvp7r25edgf4154e8sld5nq.apps.googleusercontent.com";
config.redirectURL = @"org.aerogear.Shoot:/oauth2Callback";
config.scopes = @[@"https://www.googleapis.com/auth/drive"];
}];
[_restAuthzModule requestAccessSuccess:^(id response) {
_token = response;
} failure:^(NSError *error) {
}];
Shoot'nShare
Another cookbook recipe: ProductInventory
Disclaimer: this recipe is still Pull Requests server side and iOS client
Try it, comment on it, contribute!
No secret, Unified APIs is the success...
See Password Manager recipe which is available in iOS, Android and JavaScript
cordova create food
cordova platform add android
cordova build
cordova run