WARNING: YES... AUTH, SERVER-KEY headers etc are not included, YET.....
For registering a push application (see shared gist details), I want the following REST API for adding that "generic" push app:
Submit a HTTP POST against /registry/applications/
, with a body like this (yes... API key headers are missing):
{
"description":"just a test",
"name":"TestApp"
}
A cURL example looks like:
curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"description":"just a test", "name":"TestApp"}' http://localhost:8080/registry/applications
The 201
response looks like:
{"id":"a325b21f6c744df185b8bea25d56045c"}
Submit a HTTP POST against /registry/applications/a325b21f6c744df185b8bea25d56045c/iOS
, with a body like:
{
"appleId":"com.yo.ur.app",
"cert":"CERT_UPLOAD_VAL",
"passphrase": "top-secret"
}
The 201
response looks like:
{"id":"ec24e09537bf4ef5b5db02bbb3b9d0e5"}
Submit a HTTP POST against /registry/applications/a325b21f6c744df185b8bea25d56045c/android
, with a body like:
{
"google-api-key": "dsdsaadsadsdasadsdsa"
}
The 201
response looks like:
{"id":"dcd7a464403447ee9f4ea9bcbd06f849"}
Submit a HTTP POST against /registry/applications/a325b21f6c744df185b8bea25d56045c/web
, with a body like:
{
"channels":[
"com.news.feed",
"notifications"
]
}
The 201
response looks like:
{"id":"a943b58c80c0402790ea98ebb83a4110"}
To avoid that more apps are using the above notifications
(or com.news.feed
) channel, we should prefix the desired channels with the ID for the (mobile) web. The (server) internal name would be like:
a943b58c80c0402790ea98ebb83a4110.notifications
a943b58c80c0402790ea98ebb83a4110.com.news.feed
Of course... the Web View needs to have it's ID ...
When the notifier API does the following:
notifier.sub("com.news.feed"......);
This translates internally to something like ID+channelname. e.g.:
notifier.sub("a943b58c80c0402790ea98ebb83a4110.com.news.feed"......);
Note: The tokens are submitted from the CLIENT APP - on the device
Information we have on the DEVICE:
- device token (or registrationID, how it's called in Android)
- the APP ID / package namespace
Things we DO NOT know:
- Push-APP ID (the logical construct on the server)
- Mobile APP ID (the logical construct on the server)
If we use the URL
from below, the client SDK needs to submit these things.....
Submit a HTTP POST against /registry/device/PUSH-APP-ID/MOBILE-APP-ID
, with a body like:
{
"token": "blah",
"os": "Android"
}
HOWEVER.... IMO there is a slight risk using the IDs here, on the URL.... Perhaps we should submit them, from the device, as a header ? (and require TLS?)
X-AG-PUSHAPP: 1234
X-AG-MOBILE: 456454
with those header, now submit a HTTP POST against /registry/device/
, with a body like:
{
"token": "blah",
"os": "Android"
}
On a successful "registration", we do get a 201
response.....
There is no real concept of an installation
, but you can count connected clients.
TODO: Need to find a way to give a unique ID for a (mobile) web client, regardless of its connections to the channels...
This allows to register one PushApp, with a batch of mobile apps (several paid, free etc versions)
Submit a HTTP POST against /registry/applications/
, with a body like this
{
name: "My Content Sharing app",
description: "A never been there app, to share content",
// add two iOS apps (paid and free)
ios: {
[
{apple-ID: "com.my.paid",
cert: "certval1",
passphrase: "passphrase1"},
{apple-ID: "com.my.free",
cert: "certval2",
passphrase: "passphrase2"}
]
},
// add two Android apps (paid and free)
android: {
[
{"google-api-key": "key1"},
{"google-api-key": "key2"}
]
},
// add one web app, with one channel
web: {
"channels":[
"my-notifications"
]
}
}
For this convenience API the 201 Response could look like:
{
"id":"PushAppKey"
"apps":[
{"iOS-ID":"adda213213"},
{"iOS-ID":"24da213213"},
{"android-ID":"454dda213213"},
{"android-ID":"g52234213213"},
{"web-ID":"og2352234213213"},
]
}
Here are the routes for that....:
// register Push Applications:
rm.post("/registry/applications", new Handler<HttpServerRequest>() {
public void handle(final HttpServerRequest request) {
request.dataHandler(new Handler<Buffer>() {
public void handle(Buffer buffer) {
PushApplication pushApp = (PushApplication) Json.decodeValue(buffer.toString(), PushApplicationImpl.class);
// store it.......
JsonObject response = new JsonObject().putString("id", pushApp.getApplicationKey());
request.response.end(response.toString());
}
});
}
});
// Register Mobile Apps:
rm.post("/registry/applications/:key/:variant", new Handler<HttpServerRequest>() {
public void handle(final HttpServerRequest request) {
......
I like the idea of using headers for the IDs rather than on the URL.
👍