Weitere ähnliche Inhalte
Ähnlich wie Baa sでお気楽アプリ開発 (20)
Mehr von Yusuke Ohmichi (10)
Kürzlich hochgeladen (11)
Baa sでお気楽アプリ開発
- 15. 具体例
15
• Parseでデータをクラウドに保存するコード
ParseObject gameScore = new ParseObject("GameScore");
gameScore.put("score", 1337);
gameScore.put("playerName", "Sean Plott");
gameScore.put("cheatMode", false);
gameScore.saveInBackground();
テーブル名
ハッシュ構造
(KeyとValue)
同期保存も非同期保存も
Offline保存も可能
- 16. 具体例
16
• Parseでデータをクラウドから取得するコード
ParseQuery<ParseObject> query = ParseQuery.getQuery("GameScore");
query.getInBackground("xWMyZ4YEGZ", new GetCallback<ParseObject>() {
public void done(ParseObject object, ParseException e) {
if (e == null) {
int score = object.getInt("score");
String playerName = object.getString("playerName");
boolean cheatMode = object.getBoolean("cheatMode");
} else {
// something went wrong
}
}
});
保存した時のKey
エラーの時は例外
オブジェクトが入る
- 20. 機能比較
機能
Parse
Mobile Backend Starter
無償利用
◯
◯
Android
◯
◯
iOS / .Net / OS X / Windows 8 /Windows
Phone 8 / Unity / Web(JavaScript)
◯
△(RESTで可能)
RESTful API
◯
△(コードが読めれば)
Push通知
◯
◯
Analytics
◯
☓
File送受信
◯
☓
ユーザ管理 / アクセス制御 ◯
◯(google acount)
Twitter / Facebook連携
◯
☓
サーバサイドロジック △
◯
サーバ側機能拡張 ☓
◯
- 21. MBSの使い所
21
• サーバはGoogle App Engine(GAE)です。MBSは、GAE上で
稼働するオープンソースのサーバアプリケーション+クライアン
トライブラリという形で提供されています。
• すなわち、Parseのように完成形のサーバが稼働しているわけ
ではなく、サーバとして使えるひな形が提供されていることにな
ります。
• 最低限の機能しか搭載されていませんが、GAEさえ使えれ
ば必要に応じて機能拡張可能です。制限はありません。
• Google Cloud Endpointsを使っているのでAndroidだけで
はなく、iOSやWebもサポート可能
- 22. Google Cloud Endpoints
22
• GAEを使ったRPCっぽいことをするフレームワーク
1.Endpointsを使って
サーバコードを書くと
2. http://ホスト/post/(id)
などエンドポイントができて
(RESTful API)
3. 各OS用のクラ
イアントコードを
自動生成できる
- 23. 具体例
23
• MBSのサーバ側のコードの抜粋です
@ApiMethod(path = "CloudEntities/insertAll", httpMethod = "POST")
public EntityListDto insertAll(EntityListDto cdl, User user)
throws UnauthorizedException {
SecurityChecker.getInstance().checkIfUserIsAvailable(user);
return CrudOperations.getInstance().saveAll(cdl, user);
}
@ApiMethod(path = "CloudEntities/{kind}/{id}", httpMethod = "GET")
public EntityDto get(@Named("kind") String kindName,
@Named("id") String id, User user)
throws UnauthorizedException, NotFoundException {
SecurityChecker.getInstance().checkIfUserIsAvailable(user);
return CrudOperations.getInstance().getEntity(kindName, id, user);
}