Download - ニフティクラウド Mobile backendとio tの良い関係
Copyright @ NIFTY Corporation All Rights Reserved
ニフティクラウドmobile backendとIoTの良い関係
ニフティクラウド mobile backend
エヴァンジェリスト 中津川篤司
Copyright @ NIFTY Corporation All Rights Reserved
自己紹介
2
@moongift
fb.me/moongift.fan
中津川 篤司株式会社MOONGIFT 代表取締役ニフティクラウド mobile backend
エヴァンジェリスト
2004年1月よりオープンソース・ソフトウェアを毎日紹介するブログ MOONGIFT を運営。
http://www.moongift.jp/
Copyright @ NIFTY Corporation All Rights Reserved
ニフティクラウド mobile backnendについて
3
@niftycloud_mb
fb.me/niftycloudmb
ニフティクラウド mobile backendニフティ株式会社の提供するmBaaS
スマートフォン/Webアプリのバックエンド(サーバサイド)の仕組みを一括提供
http://mb.cloud.nifty.com/
Copyright @ NIFTY Corporation All Rights Reserved
mBaaSとは?
4
スマートフォン/Webアプリのバックエンド(サーバサイド)の仕組みを一括提供
→ mobile Backend as a Serviceの略
Copyright @ NIFTY Corporation All Rights Reserved
アプリとサーバの現状
5
Copyright @ NIFTY Corporation All Rights Reserved
アプリとサーバの現状
6
Copyright @ NIFTY Corporation All Rights Reserved
アプリとサーバの現状
7
アプリ サーバ
・認証 ・結果
・データ(テキスト/バイナリ) ・プッシュ通知
だいたい同じ
Copyright @ NIFTY Corporation All Rights Reserved
サーバに求められるもの
8
・安定性 ・セキュリティ対策 ・定期的なアップデート
絶対に落ちないこと! 高速に動き続けること! クラックされないこと!
Copyright @ NIFTY Corporation All Rights Reserved
mBaaSに置き換えてみる
9
アプリ
・認証 ・結果
・データ(テキスト/バイナリ) ・プッシュ通知
ニフティクラウド mobile backend
アプリの開発に集中!
Copyright @ NIFTY Corporation All Rights Reserved
ニフティクラウド mobile backendの主な機能
10
プッシュ通知 データ ストレージ
ファイル ストレージ
SNS連携 認証 位置情報 検索
Copyright @ NIFTY Corporation All Rights Reserved
対応プラットフォーム
11
Objective-C(2014年12月より64bit対応)
Android
JavaScript(2014年12月よりnodeサポート!)
Unity
Copyright @ NIFTY Corporation All Rights Reserved
Web API
12
RESTfulなAPI
・データの追加、更新、削除、検索 ・バイナリファイルの追加、更新、削除、検索 ・認証 ・プッシュ通知の追加、更新、削除、検索
https://github.com/moongift/ncmb-ruby-client
Copyright @ NIFTY Corporation All Rights Reserved
本題
13
IoT と mBaaS をいかに組み合わせるか?
Copyright @ NIFTY Corporation All Rights Reserved
IoTデバイスの問題点1
14
小型=小バッテリー 常時電源が使えるとは限らない 小さなメモリ/ストレージ 蓄積したデータを廃棄?
Copyright @ NIFTY Corporation All Rights Reserved
よくない利用
15
IoTデバイスデスクトップ スマートフォン
Webサーバ
Copyright @ NIFTY Corporation All Rights Reserved
よくない利用
16
デスクトップ スマートフォン
Copyright @ NIFTY Corporation All Rights Reserved
mBaaSを使った例
17
IoTデバイス
デスクトップ スマートフォン
ニフティクラウド mobile backend
SDK REST API
IoTデバイス
Copyright @ NIFTY Corporation All Rights Reserved
IoTの問題2
18
IoTデバイスに何かあった時、通知したい 今ならプッシュ通知がスムーズ → APNs、GCMに接続する必要あり → デバイストークンの管理
Copyright @ NIFTY Corporation All Rights Reserved
よくない利用
19
IoTデバイス スマートフォンAPNs/GCM
Copyright @ NIFTY Corporation All Rights Reserved
20
IoTデバイス スマートフォンAPNs/GCM
mBaaSを使った例
!
ニフティクラウド mobile backend
Copyright @ NIFTY Corporation All Rights Reserved
プッシュ通知を使った例
21
Copyright @ NIFTY Corporation All Rights Reserved
22
IoTデバイス
スマートフォン APNs/GCM
mBaaSを使った例
!
ニフティクラウド mobile backend
プッシュ作成サーバ
Copyright @ NIFTY Corporation All Rights Reserved
プッシュ作成サーバ
23
require 'sinatra/base' require 'ncmb'
class Server < Sinatra::Base get '/' do NCMB.initialize application_key: ENV['APPLICATION_KEY'] || "", client_key: ENV['CLIENT_KEY'] || "" @push = NCMB::Push.new @push.immediateDeliveryFlag = true @push.target = ['ios'] @push.message = params["m"] @push.deliveryExpirationTime = "3 day" if @push.save status 201 body '' else status 403 body '' end end end
https://github.com/moongift/push_server/
Copyright @ NIFTY Corporation All Rights Reserved
MQTTに対応させる場合
24
require 'mqtt' require 'uri' require 'ncmb'
# Create a hash with the connection parameters from the URL uri = URI.parse ENV['CLOUDMQTT_URL'] || 'mqtt://localhost:1883' conn_opts = { remote_host: uri.host, remote_port: uri.port, username: uri.user, password: uri.password, }
MQTT::Client.connect(conn_opts) do |c| NCMB.initialize application_key: ENV['APPLICATION_KEY'] || "", client_key: ENV['CLIENT_KEY'] || "" loop do # The block will be called when you messages arrive to the topic c.get(ENV['TOPIC']) do |topic, message| @push = NCMB::Push.new @push.immediateDeliveryFlag = true @push.target = ['ios'] @push.message = message.force_encoding('utf-8') @push.deliveryExpirationTime = "3 day" @push.save end end end
https://github.com/moongift/push_server_mqtt
Copyright @ NIFTY Corporation All Rights Reserved
IoTの問題3
25
M2M(Machine to Machine)とは言うけど そもそもプロトコルを合わせられない…
Copyright @ NIFTY Corporation All Rights Reserved
良くない利用
26
IoTデバイス IoTデバイス
プロコトルの違い 仕様のすりあわせ NAT越の必要あり
Copyright @ NIFTY Corporation All Rights Reserved
27
mBaaSを使った例
IoTデバイス IoTデバイスニフティクラウド mobile backend
M2C2M
Copyright @ NIFTY Corporation All Rights Reserved
28
mBaaSを使った例
IoTデバイス IoTデバイスニフティクラウド mobile backend
Copyright @ NIFTY Corporation All Rights Reserved
M2C2Mの例
29
お父さんいまどこメーター
via http://qiita.com/kazunori279/items/
7dbbb525ab0cf6d5d9b5
Copyright © NIFTY Corporation All Rights Reserved. ‹#›
料金プラン
Copyright © NIFTY Corporation All Rights Reserved. ‹#›
Basicプラン200万!
200万!
5GB!
月額無料
Copyright © NIFTY Corporation All Rights Reserved. ‹#›
mikan 最速の英単語 リスニングもマスター
https://www.youtube.com/watch?v=5ujG-0zrtrw
Copyright © NIFTY Corporation All Rights Reserved. ‹#›
開発で困ったら?
bit.ly/ncmb-community
Copyright @ NIFTY Corporation All Rights Reserved
@niftycloud_mb
https://fb.me/niftycloudmb