34
Copyright @ NIFTY Corporation All Rights Reserved ニフティクラウド mobile backend IoTの良い関係 ニフティクラウド mobile backend エヴァンジェリスト 中津川篤司

ニフティクラウド Mobile backendとio tの良い関係

Embed Size (px)

Citation preview

Page 1: ニフティクラウド Mobile backendとio tの良い関係

Copyright @ NIFTY Corporation All Rights Reserved

ニフティクラウドmobile backendとIoTの良い関係

ニフティクラウド mobile backend

エヴァンジェリスト 中津川篤司

Page 2: ニフティクラウド Mobile backendとio tの良い関係

Copyright @ NIFTY Corporation All Rights Reserved

自己紹介

2

@moongift

fb.me/moongift.fan

中津川 篤司株式会社MOONGIFT 代表取締役ニフティクラウド mobile backend

          エヴァンジェリスト

2004年1月よりオープンソース・ソフトウェアを毎日紹介するブログ MOONGIFT を運営。

http://www.moongift.jp/

Page 3: ニフティクラウド Mobile backendとio tの良い関係

Copyright @ NIFTY Corporation All Rights Reserved

ニフティクラウド mobile backnendについて

3

@niftycloud_mb

fb.me/niftycloudmb

ニフティクラウド mobile backendニフティ株式会社の提供するmBaaS

スマートフォン/Webアプリのバックエンド(サーバサイド)の仕組みを一括提供

http://mb.cloud.nifty.com/

Page 4: ニフティクラウド Mobile backendとio tの良い関係

Copyright @ NIFTY Corporation All Rights Reserved

mBaaSとは?

4

スマートフォン/Webアプリのバックエンド(サーバサイド)の仕組みを一括提供

 → mobile Backend as a Serviceの略

Page 5: ニフティクラウド Mobile backendとio tの良い関係

Copyright @ NIFTY Corporation All Rights Reserved

アプリとサーバの現状

5

Page 6: ニフティクラウド Mobile backendとio tの良い関係

Copyright @ NIFTY Corporation All Rights Reserved

アプリとサーバの現状

6

Page 7: ニフティクラウド Mobile backendとio tの良い関係

Copyright @ NIFTY Corporation All Rights Reserved

アプリとサーバの現状

7

アプリ サーバ

・認証 ・結果

・データ(テキスト/バイナリ) ・プッシュ通知

だいたい同じ

Page 8: ニフティクラウド Mobile backendとio tの良い関係

Copyright @ NIFTY Corporation All Rights Reserved

サーバに求められるもの

8

・安定性 ・セキュリティ対策 ・定期的なアップデート

絶対に落ちないこと! 高速に動き続けること! クラックされないこと!

Page 9: ニフティクラウド Mobile backendとio tの良い関係

Copyright @ NIFTY Corporation All Rights Reserved

mBaaSに置き換えてみる

9

アプリ

・認証 ・結果

・データ(テキスト/バイナリ) ・プッシュ通知

ニフティクラウド mobile backend

アプリの開発に集中!

Page 10: ニフティクラウド Mobile backendとio tの良い関係

Copyright @ NIFTY Corporation All Rights Reserved

ニフティクラウド mobile backendの主な機能

10

プッシュ通知 データ ストレージ

ファイル ストレージ

SNS連携 認証 位置情報 検索

Page 11: ニフティクラウド Mobile backendとio tの良い関係

Copyright @ NIFTY Corporation All Rights Reserved

対応プラットフォーム

11

Objective-C(2014年12月より64bit対応)

Android

JavaScript(2014年12月よりnodeサポート!)

Unity

Page 12: ニフティクラウド Mobile backendとio tの良い関係

Copyright @ NIFTY Corporation All Rights Reserved

Web API

12

RESTfulなAPI

・データの追加、更新、削除、検索 ・バイナリファイルの追加、更新、削除、検索 ・認証 ・プッシュ通知の追加、更新、削除、検索

https://github.com/moongift/ncmb-ruby-client

Page 13: ニフティクラウド Mobile backendとio tの良い関係

Copyright @ NIFTY Corporation All Rights Reserved

本題

13

IoT と mBaaS をいかに組み合わせるか?

Page 14: ニフティクラウド Mobile backendとio tの良い関係

Copyright @ NIFTY Corporation All Rights Reserved

IoTデバイスの問題点1

14

小型=小バッテリー  常時電源が使えるとは限らない 小さなメモリ/ストレージ  蓄積したデータを廃棄?

Page 15: ニフティクラウド Mobile backendとio tの良い関係

Copyright @ NIFTY Corporation All Rights Reserved

よくない利用

15

IoTデバイスデスクトップ スマートフォン

Webサーバ

Page 16: ニフティクラウド Mobile backendとio tの良い関係

Copyright @ NIFTY Corporation All Rights Reserved

よくない利用

16

デスクトップ スマートフォン

Page 17: ニフティクラウド Mobile backendとio tの良い関係

Copyright @ NIFTY Corporation All Rights Reserved

mBaaSを使った例

17

IoTデバイス

デスクトップ スマートフォン

ニフティクラウド mobile backend

SDK REST API

IoTデバイス

Page 18: ニフティクラウド Mobile backendとio tの良い関係

Copyright @ NIFTY Corporation All Rights Reserved

IoTの問題2

18

IoTデバイスに何かあった時、通知したい 今ならプッシュ通知がスムーズ  → APNs、GCMに接続する必要あり  → デバイストークンの管理

Page 19: ニフティクラウド Mobile backendとio tの良い関係

Copyright @ NIFTY Corporation All Rights Reserved

よくない利用

19

IoTデバイス スマートフォンAPNs/GCM

Page 20: ニフティクラウド Mobile backendとio tの良い関係

Copyright @ NIFTY Corporation All Rights Reserved

20

IoTデバイス スマートフォンAPNs/GCM

mBaaSを使った例

ニフティクラウド mobile backend

Page 21: ニフティクラウド Mobile backendとio tの良い関係

Copyright @ NIFTY Corporation All Rights Reserved

プッシュ通知を使った例

21

Page 22: ニフティクラウド Mobile backendとio tの良い関係

Copyright @ NIFTY Corporation All Rights Reserved

22

IoTデバイス

スマートフォン APNs/GCM

mBaaSを使った例

ニフティクラウド mobile backend

プッシュ作成サーバ

Page 23: ニフティクラウド Mobile backendとio tの良い関係

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/

Page 24: ニフティクラウド Mobile backendとio tの良い関係

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

Page 25: ニフティクラウド Mobile backendとio tの良い関係

Copyright @ NIFTY Corporation All Rights Reserved

IoTの問題3

25

M2M(Machine to Machine)とは言うけど そもそもプロトコルを合わせられない…

Page 26: ニフティクラウド Mobile backendとio tの良い関係

Copyright @ NIFTY Corporation All Rights Reserved

良くない利用

26

IoTデバイス IoTデバイス

プロコトルの違い 仕様のすりあわせ NAT越の必要あり

Page 27: ニフティクラウド Mobile backendとio tの良い関係

Copyright @ NIFTY Corporation All Rights Reserved

27

mBaaSを使った例

IoTデバイス IoTデバイスニフティクラウド mobile backend

M2C2M

Page 28: ニフティクラウド Mobile backendとio tの良い関係

Copyright @ NIFTY Corporation All Rights Reserved

28

mBaaSを使った例

IoTデバイス IoTデバイスニフティクラウド mobile backend

Page 29: ニフティクラウド Mobile backendとio tの良い関係

Copyright @ NIFTY Corporation All Rights Reserved

M2C2Mの例

29

お父さんいまどこメーター

via http://qiita.com/kazunori279/items/

7dbbb525ab0cf6d5d9b5

Page 30: ニフティクラウド Mobile backendとio tの良い関係

Copyright © NIFTY Corporation All Rights Reserved. ‹#›

料金プラン

Page 31: ニフティクラウド Mobile backendとio tの良い関係

Copyright © NIFTY Corporation All Rights Reserved. ‹#›

Basicプラン200万!

200万!

5GB!

月額無料

Page 32: ニフティクラウド Mobile backendとio tの良い関係

Copyright © NIFTY Corporation All Rights Reserved. ‹#›

mikan 最速の英単語 リスニングもマスター

https://www.youtube.com/watch?v=5ujG-0zrtrw

Page 33: ニフティクラウド Mobile backendとio tの良い関係

Copyright © NIFTY Corporation All Rights Reserved. ‹#›

開発で困ったら?

bit.ly/ncmb-community

Page 34: ニフティクラウド Mobile backendとio tの良い関係

Copyright @ NIFTY Corporation All Rights Reserved

@niftycloud_mb

https://fb.me/niftycloudmb