Upgrade to Pro — share decks privately, control downloads, hide ads and more …

MBaaS で巨人の肩に乗る #awscasual

Naoya Ito
November 01, 2013

MBaaS で巨人の肩に乗る #awscasual

Naoya Ito

November 01, 2013
Tweet

More Decks by Naoya Ito

Other Decks in Technology

Transcript

  1. .#BB4Ͱ
    ڊਓͷݞͷ্ʹ৐Δ
    !OBPZB@JUP

    View full-size slide

  2. ࣗݾ঺հ
    •  ޷͖ͳήʔϜ
    –  θϊϒϨΠυ
    –  ελʔΫϥϑτ
    •  ࠓ΍͍ͬͯΔήʔϜ
    –  ''
    –  Ϟϯελʔϋϯλʔ
    –  %BSL4PVMT8JOEPXT൛
    •  ࠓޙͷ༧ఆ
    –  (0%&"5&3
    –  υϥΰϯΫΤετ຾ΕΔ༐ऀͱڹ͖ͷໍ༑
    –  %BSL4PVMT**

    View full-size slide

  3. .#BB4ར༻ࣄྫ

    View full-size slide

  4. ϓογϡ௨஌

    View full-size slide

  5. ͸ͯͳϒοΫϚʔΫ QVTIICGBWDPN
    1BSTF "1/αʔόʔ
    8FC)PPL
    )5513&45"1*
    /PEFKTPO)FSPLV

    View full-size slide

  6. 1BSTF3&45"1*
    curl  -­‐X  POST  \  
       -­‐H  "X-­‐Parse-­‐Application-­‐Id:  "..."  \  
       -­‐H  "X-­‐Parse-­‐REST-­‐API-­‐Key:  "..."  \  
       -­‐H  "Content-­‐Type:  application/json"  \  
       -­‐d  '{  
                   "data":  {  
                       "where":  {  "owner":  "naoya"  }  
                       "alert":  "Hello,  World!"  
                   }  
               }'  \  
       https://api.parse.com/1/push  
     
    ϓογϡ௨஌ʹ·ͭΘΔ໘౗ͳՕॴ͸Ϋϥ΢υଆͰ΍ͬͯ͘
    ΕΔ ྫ"1/αʔόͱͷ઀ଓҡ࣋

    View full-size slide

  7. ༨ஊͦͷଞ
    •  5FTU'MJHIUςετΞϓϦͷνʔϜ΁ͷ഑෍
    •  #VH4FOTFΫϥογϡϨϙʔτ
    •  (PPHMF"OBMZUJDTGPSJ04ΞΫςΟϏςΟղੳ
    •  /FX3FMJDϞχλϦϯά
    •  5SBWJT$*ܧଓతΠϯςάϨʔγϣϯ
    #VH4FOTF

    View full-size slide

  8. #BB4͕͖ͯΔŋŋŋΒ͍͠

    View full-size slide

  9. .
    #BB4
    •  ೥ԯԁࢢ৔ˠ೥
    ԯࢢ৔
    –  IUUQXXXNBSLFUTBOENBSLFUTDPN1SFTT3FMFBTFTCBBTBTQ

    View full-size slide

  10. ओཁͳϓϨΠϠʔ
    •  1BSTF
    •  ,JOWFZ
    •  4UBDL.PC
    •  "QQDFMFSBUPS
    "$4

    •  ŋŋŋ

    View full-size slide

  11. ͜ͷลΈ͓͖ͯ·͠ΐ͏
    ʰϞόΠϧΞϓϦͷόοΫΤϯυ 8FC"1*
    ʹಛԽͨ͠αʔϏεͷ·ͱΊʱͷͦͷޙ ೥൛

    IUUQBLJTVUFDPNXFCBQJIUNM

    View full-size slide

  12. .#BB4ͷఏڙ͢Δ΋ͷ
    •  Ϣʔβొ࿥ɾ؅ཧɾೝূ
    •  ϝοηʔδϯά ϓογϡ௨஌

    •  Ϋϥ΢υετϨʔδ
    –  ϑΝΠϧετϨʔδ
    –  ΦϒδΣΫτετϨʔδ
    •  Ϋϥ΢υ্Ͱͷܭࢉॲཧ
    •  ՝ۚ *O"QQ1VSDITF

    •  ར༻෼ੳ
    •  Ґஔ৘ใɺιʔγϟϧͳͲͷίϯςΩετ

    View full-size slide

  13. ͜ͷ͋ͨΓ͕ఆ൪
    •  Ϣʔβొ࿥ɾ؅ཧɾೝূ
    •  ϝοηʔδϯά ϓογϡ௨஌

    •  Ϋϥ΢υετϨʔδ
    •  Ϋϥ΢υ্Ͱͷܭࢉॲཧ
    •  ՝ۚ *O"QQ1VSDITF

    •  ར༻෼ੳ
    •  Ґஔ৘ใɺιʔγϟϧͳͲͷίϯςΩετ

    View full-size slide

  14. .#BB4ͷయܕతͳελοΫ
    όοΫΤϯυαʔϏε܈
    8FC"1*
    J044%, "OESPJE4%,
    ؅ཧίϯιʔϧ
    μογϡϘʔυ

    Ϋϥ΢υετϨʔδ
    ͦͷଞݴޠຖ
    ϥΠϒϥϦ
    *BB4 ओʹ"84

    View full-size slide

  15. ։ൃͷ࣮ࡍ
    •  J04"OESPJEΞϓϦ͔Β
    – 8FC"1*Λந৅Խͨ͠4%,Λ࢖͏
    •  8FCΞϓϦέʔγϣϯ͔Β
    – 8FC"1* ͍͍ͩͨ+40/PWFS)551
    Λ
    ୟ͘

    View full-size slide

  16. ྫ1BSTF4%,ͰετϨʔδ
    #  RubyMotion  
    query  =  PFQuery.queryWithClassName("User")  
    query.whereKey("screenname",  equalTo:"ito")  
    query.limit  =  10  
    query.findObjectsInBackgroundWithBlock(  
       lambda  do  |objects,  error|  
           if  not  error  
               objects.each  do  |user|  
                   puts  user["name"]  
               end  
           end  
       end  
    )

    View full-size slide

  17. ྫ1BSTFͰ3&45"1*
    curl  -­‐X  POST  \  
       -­‐H  "X-­‐Parse-­‐Application-­‐Id:  "..."  \  
       -­‐H  "X-­‐Parse-­‐REST-­‐API-­‐Key:  "..."  \  
       -­‐H  "Content-­‐Type:  application/json"  \  
       -­‐d  '{  
                   "data":  {  
                       "where":  {  "owner":  "naoya"  }  
                       "alert":  "Hello,  World!"  
                   }  
               }'  \  
       https://api.parse.com/1/push  
     

    View full-size slide

  18. Ϣʔβʔొ࿥ͱ͔໘౗Ͱ͢Ͷ
    •  *%ύεϫʔυͷόϦσʔγϣϯ
    •  ύεϫʔυͷϋογϡԽ
    •  ϝʔϧΛૹΓຊਓ֬ೝ
    •  αʔόʔͷετϨʔδ΁อଘ
    •  ŋŋŋ

    View full-size slide

  19. 1BSTFͳΒ
    user  =  PFUser.user  
    user.username  =  "naoya"  
    user.password  =  "******"  
    user.email  =  [email protected]  
    user.signUpInBackgroundWithBlock(  
       lambda  do  |succeeded,  error  |  
           if  !error  
               puts  "success"  
           end  
       end  
    )  

    View full-size slide

  20. ݱࡏͷϩάΠϯϢʔβ
    user  =  PFUser.currentUser  

    View full-size slide

  21. ϩάΠϯը໘࡞ΔͷΊΜͲ͍͘͞
    1'-PH*O7JFX$POUSPMMFS

    View full-size slide

  22. 5XJUUFSϩάΠϯ͍ͤͨ͞
    PFTwitterUtils.logInWithBlock(  
       lambda  do  |user,  error|  
           if  !user  
               NSLog("キャンセル")  
               return  
           elsif  user.isNew  
               NSLog("Twitterアカウントで初めてログイン")  
           else  
               NSLog("Twitterアカウントでログイン")  
           end  
       end  
    )  

    View full-size slide

  23. ʮԿ͜ΕΊͬͪΌศརʂʂʯ

    View full-size slide

  24. ϓογϡ௨஌
    #  Push  Notification  を有効に  
    #  ParseのKVS  に  deviceToken  ó  user_id  のマッピングを保持  
    PFInstallation.currentInstallation.tap  do  |install|  
       install.setDeviceTokenFromData(deviceToken)  
       install.setObject(@user_id,  forKey:"owner")  
       install.saveInBackground  
    end

    View full-size slide

  25. 1BSTF3&45"1*
    #  REST  API  で、push通知を端末に送るよう  Parse  に指令  
    curl  -­‐X  POST  \  
       -­‐H  "X-­‐Parse-­‐Application-­‐Id:  "..."  \  
       -­‐H  "X-­‐Parse-­‐REST-­‐API-­‐Key:  "..."  \  
       -­‐H  "Content-­‐Type:  application/json"  \  
       -­‐d  '{  
                   "data":  {  
                       "where":  {  "owner":  "naoya"  }  
                       "alert":  "Hello,  World!"  
                   }  
               }'  \  
       https://api.parse.com/1/push  
     

    View full-size slide

  26. ͸ͯͳϒοΫϚʔΫ QVTIICGBWDPN
    1BSTF "1/αʔόʔ
    8FC)PPL
    )5513&45"1*
    /PEFKTPO)FSPLV

    View full-size slide

  27. #BDLHSPVOE+PCTͱ͔΋͍͍

    View full-size slide

  28. ͜ͷลΈͯͶ
    IUUQXXXTMJEFTIBSFOFULUTVKJDIBOQBSTFDPN

    View full-size slide

  29. Ͱ΋ɺ͓ߴ͍ΜͰ͠ΐ͏ʁ

    View full-size slide

  30. 1BSTFͷՁ࣮֨ࡍ
    •  ສ"1*ίʔϧ݄·Ͱແྉ
    – ༡ͼখن໛ͳΒे෼ແྉʹऩ·Δ

    •  )#'BW
    – ࠓͷͱ͜Ζແྉ࿮Ͱؒʹ߹ͬͯΔ
    •  ఔ౓
    –  SFREBZ͘Β͍͕ͩ୯ௐ૿Ճͯ͠
    ΔͷͰকདྷతʹ͸ŋŋŋ

    View full-size slide

  31. ,JOWFZͷྉۚମܥ
    ΞΫςΟϒϢʔβʔ਺ج४Ͱ՝ۚ

    View full-size slide

  32. 1BSTFͷ͕͍͍͜͜
    •  ந৅౓͕ͪΐ͏Ͳྑ͍
    –  ߴ͗ͣ͢ɺ௿͗ͣ͢
    –  4%,΍"1*ઃܭ͕σϕϩούͷۤ௧ΛΑ͘෼͔ͬͯΔ

    •  1'2VFSZͱଞαʔϏεͱͷ࿈ܞ
    –  42-෩໰͍߹Θ͕ͤεΩʔϚϨε%#ʹՄೳ
    •  4%,Ͱ΋ɺ3&45"1*Ͱ΋XIFSFMJNJU
    –  Ϣʔβʔొ࿥ϓογϡ௨஌ొ࿥ʹ෇ਵ͢Δσʔλϕʔε
    Λશͯ1'2VFSZͰ໰͍߹Θͤ
    •  εέʔϥϏϦςΟΞϕΠϥϏϦςΟ
    –  ·ͬͨ͘ؾʹͤͣ࢖͍͑ͯΔ

    View full-size slide

  33. .#BB4ͷ࣮ࡍ
    •  Ұ౓׳ΕΔͱපΈ͖ͭʹ
    •  ͜Ε͚ͩͰશͯͷόοΫΤϯυ͕࿫͑Δ
    –  ཁ݅ʹΑΔ΋ɺ͋Δఔ౓ͷن໛Ͱ͸೉ͦ͠͏
    –  ผ్*BB41BB4ʹஔ͍ͨΞϓϦέʔγϣϯͱ
    ૊Έ߹Θͤ
    •  ϨΠςϯγ
    –  ϞόΠϧΞϓϦέʔγϣϯͰ͸ؾʹͳΒͳ͍͜ͱ
    ͕ଟ͍
    •  εέʔϥϏϦςΟ
    –  લड़ͷͱ͓Γ

    View full-size slide

  34. .#BB4ͷ͕͜͜ෆ҆
    •  ந৅౓ߴΊϩοΫΠϯ
    – ଞαʔϏε΁ͷ৐Γ׵͑ίετ͕ߴ͍
    – 4%,
    – σʔλ͕͢΂ͯಠࣗσʔλϕʔεʹŋŋŋ
    •  "NB[PO4/4ʹൺ΂ͯྉۚʹׂߴײ

    View full-size slide

  35. ͦͷ΄͔ɺ͍͍ͱ͜Ζ
    •  ϞόΠϧΞϓϦͷόοΫΤϯυσβΠϯΛ
    Ͳ͏͢΂͖͔ͷࢀߟʹͳΔ
    – J04"OESPJE4%,ͷ"1*σβΠϯ
    – όοΫΤϯυαʔϏεͷػೳΠϯλϑΣʔ
    ε

    View full-size slide

  36. "NB[PO4/4.PCJMF1VTI
    •  "84ͷϓογϡ௨஌αʔϏε
    •  .#BB4΄Ͳͷػೳॊೈ͞͸ͳ͍͕ͱʹ
    ͔͍҆͘
    – 64%ສ"1*ϦΫΤετ

    View full-size slide

  37. "NB[PO4/4ʹ͍ͭͯৄ͘͠͸

    View full-size slide

  38. "84ͱ.#BB4ͷରൺ
    Ϋϥ΢υετϨʔδ
    •  4
    •  %ZOBNP%#
    •  3%4

    Ϣʔβʔೝূ
    •  -PHJOXJUI"NB[PO ඇ"84

    •  "NB[PO*". ˞

    ϓογϡ௨஌ "NB[PO4/4.PCJMF1VTI
    Ϋϥ΢υܭࢉ
    •  &MBTUJD.BQ3FEVDF
    •  3FETIJGU
    ΞφϦςΟΫεɺҐஔ৘ใɺ՝ۚͳͲ
    ͷ෇Ճػೳ
    ˞*".ͷιʔγϟϧαʔϏεೝূ (PPHMF'BDFCPPL
    Ͱ"84֤αʔϏεͷ"$-ઃఆ͕Մೳ "84
    4FDVSJUZ5PLFO4FSWJDF*".3PMFͰ࣮ݱ͞ΕΔ

    View full-size slide

  39. ࣮ࡍͷͱ͜Ζ
    •  "84ͱ.#BB4ͷؔ܎"84ͱ
    1BB4ͷؔ܎
    – ࣗ෼Ͱؤுͬͯ૊Έ߹ΘͤΔͷ͕"84
    – ༗ػతʹͭͳ͛ͯʮαʔϏεʯʹ࢓্͛ͯΔ
    Δͷ͕1BB4.#BB4
    •  ଟ͘ͷ.#BB4αʔϏεͷཪ͕"84ͳͷ΋Α͘ࣅ
    ͍ͯΔ

    View full-size slide

  40. ྫ͑͹ϓογϡ௨஌Λ"84Ͱ΍Δͱŋŋŋ
    •  Ұ෦ࣗ෼Ͱ؅ཧ͢Δඞཁ
    – ϓογϡج൫͸"84͕΍ͬͯ͘ΕΔ
    – σόΠετʔΫϯͷ؅ཧ͕ඞཁ
    •  ΞϓϦέʔγϣϯϢʔβʔͷ*%ͱσόΠετʔΫ
    ϯͷϚοϐϯά͸"NB[PO͸΍Βͳ͍
    –  ྫ!OBPZB@JUP㱻EFGDF
    •  ʮొ࿥ظ͕ؒҰϲ݄Ҏ಺ͷਓʹͷΈϓογϡŋŋŋʯ
    ͱ͔͢Δ৔߹͸ͦͷͨΊͷσʔλϕʔεΛ4΍
    3%4ʹࣗ෼Ͱผ్࣋ͭඞཁ

    View full-size slide

  41. 1BSTFͳΒ
    •  ֤Ϣʔεέʔε͕༗ػతʹܨ͕͍ͬͯΔ
    – σόΠετʔΫϯΛ1BSTFʹ༬͚Δࡍʹϝ
    λσʔλΛ෇༩Ͱ͖Δ
    – σόΠετʔΫϯ͸ࣗ෼ͷΫϥ΢υετϨʔ
    δʹอଘ͞ΕΔ
    – ͦͷϝλσʔλΛجʹ1'2VFSZͰݕࡧՄ
    – 4%,͔ΒͰ΋8FC"1*͔ΒͰ΋ΫΤϦՄ

    View full-size slide

  42. .#BB4ͷจ຺Ͱ͸ŋŋŋ
    •  ͱͬͯ΋͍͚҆Ͳ෦඼ͳ"84
    •  ͦΕʹൺ΂ΔͱׂߴͰϩοΫΠϯ͞ΕΔ
    ͚ͲʮαʔϏεʯͳ#BB4
    – ˞ݴ͏΄Ͳߴ͘͸ͳ͍Ͱ͢

    View full-size slide

  43. 044#BB4
    •  )FMJPT
    –  1BSTFͷϞσϧʹ͍ۙ
    •  J044%,
    •  3VCZͰॻ͔ΕͨόοΫΤϯυαʔϏε
    •  -PPQ#BDL
    –  4USPOH/PEF
    –  ྑͦ͞͏ɺͰ΋Α͘Έͯͳ͍͔ΒΘ͔Γ·ͤΜ
    •  %FQMPZE
    –  .#BB4ͱ͍͏ΑΓ#BB4 ˞

    –  "1*όοΫΤϯυ ϞόΠϧʹ΋࢖͑Δ

    ˞'JSFCBTFͱ͔ʹ͍ۙͷ͔΋

    View full-size slide

  44. $  helios  new  app  
    %  cd  app  
    %  tree  
    .  
    ├──  Gemfile  
    ├──  Procfile  
    ├──  README.md  
    └──  config.ru
    #  config.ru  
    require  'bundler'  
    Bundler.require  
     
    app  =  Helios::Application.new  {  
       service  :data,  model:  Dir['*.xcdatamodel*'].first  if  
    Dir['*.xcdatamodel*'].any?  
       service  :push_notification  
       service  :in_app_purchase  
       service  :passbook  
    }  
     
    run  app

    View full-size slide

  45. %  helios  server  
     
    #  or  
     
    %  git  push  heroku  master  

    View full-size slide

  46. #  プッシュ通知の登録  (iOS側):  Orbiter  というiOSライブラリを使う  
    url  =  NSURL.URLWithString(  
       "http://***.herokuapp.com/push_notification"  
    )  
    orbiter  =  Orbiter.alloc.initWithBaseURL(url,  credential:nil)  
    orbiter.registerDeviceToken(deviceToken,    
       success:  lambda  {    
           |responseObject|    NSLog("Registration  Success")  },  
       failure:  lambda  {  |error|  NSLog("Error:  %@",  error)  }  
    )
    #  REST  API  で  helios  server  にプッシュ通知を依頼  
    curl  -­‐X  POST  -­‐d  'payload={"aps"  :  {"alert":"Hello,  Helios!!"}}'  
    http://***.herokuapp.com/push_notification/message  

    View full-size slide

  47. )FMJPTͷ࣮ࡍ
    •  3BDLΞϓϦJ04ϥΠϒϥϦ
    •  )FSPLV3FBEZ
    •  "'/FUXPSLJOHͷNBUUU͞Μ࡞Ϟ
    δϡʔϧ܈ͷάϧʔ
    – IPVTUPO DVQFSUJOP EVCBJ WFOJDF
    •  ࣮༻ੑ
    – Μʔɾɾɾ

    View full-size slide

  48. ·ͱΊ
    •  .#BB4ศརͰ͢
    –  1BSTF,JOWFZ͋ͨΓ͕ਓؾɺ͔ͭయܕతͳ
    ϞσϧέʔεͬΆ͍
    –  ͚ͲɺϩοΫΠϯ͞Ε·͢
    •  "84͸෦඼ɺ.#BB4͸αʔϏε
    –  ϩοΫΠϯΛආ͚Δʹ͸"84Λ૊Έ߹Θ࣮ͤͯ
    ૷͢Δํ͕͍͍
    •  044.#BB4
    –  ੝Γ্͕͖ͬͯͯΔͷ͔ɺͲ͏ͳͷ͔
    –  ·༷ͩࢠݟɺͱ͍͏ͱ͜Ζ

    View full-size slide