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

MBaaS で巨人の肩に乗る #awscasual

B4afc7d853d7f1cb6a253d3c7183c05a?s=47 Naoya Ito
November 01, 2013

MBaaS で巨人の肩に乗る #awscasual

B4afc7d853d7f1cb6a253d3c7183c05a?s=128

Naoya Ito

November 01, 2013
Tweet

Transcript

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

  2. ͜Μʹͪ͸

  3. ࣗݾ঺հ •  ޷͖ͳήʔϜ –  θϊϒϨΠυ –  ελʔΫϥϑτ •  ࠓ΍͍ͬͯΔήʔϜ – 

    '' –  Ϟϯελʔϋϯλʔ –  %BSL4PVMT8JOEPXT൛ •  ࠓޙͷ༧ఆ –  (0%&"5&3 –  υϥΰϯΫΤετ຾ΕΔ༐ऀͱڹ͖ͷໍ༑ –  %BSL4PVMT**
  4. .#BB4ར༻ࣄྫ

  5. None
  6. ϓογϡ௨஌

  7. None
  8. 1BSTF

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

  10. 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/αʔόͱͷ઀ଓҡ࣋ 
  11. 1BSTFͱ"84

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

    5SBWJT$*ܧଓతΠϯςάϨʔγϣϯ #VH4FOTF
  13. .#BB4

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

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

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

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

  18. .#BB4ͷఏڙ͢Δ΋ͷ •  Ϣʔβొ࿥ɾ؅ཧɾೝূ •  ϝοηʔδϯά ϓογϡ௨஌  •  Ϋϥ΢υετϨʔδ – 

    ϑΝΠϧετϨʔδ –  ΦϒδΣΫτετϨʔδ •  Ϋϥ΢υ্Ͱͷܭࢉॲཧ •  ՝ۚ *O"QQ1VSDITF  •  ར༻෼ੳ •  Ґஔ৘ใɺιʔγϟϧͳͲͷίϯςΩετ
  19. ͜ͷ͋ͨΓ͕ఆ൪ •  Ϣʔβొ࿥ɾ؅ཧɾೝূ •  ϝοηʔδϯά ϓογϡ௨஌  •  Ϋϥ΢υετϨʔδ • 

    Ϋϥ΢υ্Ͱͷܭࢉॲཧ •  ՝ۚ *O"QQ1VSDITF  •  ར༻෼ੳ •  Ґஔ৘ใɺιʔγϟϧͳͲͷίϯςΩετ
  20. .#BB4ͷయܕతͳελοΫ όοΫΤϯυαʔϏε܈ 8FC"1* J044%, "OESPJE4%, ؅ཧίϯιʔϧ μογϡϘʔυ  Ϋϥ΢υετϨʔδ ͦͷଞݴޠຖ

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

  22. 1BSTF

  23. ྫ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   )
  24. None
  25. ྫ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    
  26. Ϣʔβʔొ࿥ͱ͔໘౗Ͱ͢Ͷ •  *%ύεϫʔυͷόϦσʔγϣϯ •  ύεϫʔυͷϋογϡԽ •  ϝʔϧΛૹΓຊਓ֬ೝ •  αʔόʔͷετϨʔδ΁อଘ • 

    ŋŋŋ
  27. 1BSTFͳΒ user  =  PFUser.user   user.username  =  "naoya"   user.password

     =  "******"   user.email  =  i.naoya@gmail.com   user.signUpInBackgroundWithBlock(      lambda  do  |succeeded,  error  |          if  !error              puts  "success"          end      end   )  
  28. None
  29. ݱࡏͷϩάΠϯϢʔβ user  =  PFUser.currentUser  

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

  31. 5XJUUFSϩάΠϯ͍ͤͨ͞ PFTwitterUtils.logInWithBlock(      lambda  do  |user,  error|    

         if  !user              NSLog("キャンセル")              return          elsif  user.isNew              NSLog("Twitterアカウントで初めてログイン")          else              NSLog("Twitterアカウントでログイン")          end      end   )  
  32. None
  33. None
  34. ʮԿ͜ΕΊͬͪΌศརʂʂʯ

  35. ϓογϡ௨஌ #  Push  Notification  を有効に   #  ParseのKVS  に  deviceToken

     ó  user_id  のマッピングを保持   PFInstallation.currentInstallation.tap  do  |install|      install.setDeviceTokenFromData(deviceToken)      install.setObject(@user_id,  forKey:"owner")      install.saveInBackground   end
  36. 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    
  37. ͸ͯͳϒοΫϚʔΫ QVTIICGBWDPN 1BSTF "1/αʔόʔ 8FC)PPL )5513&45"1* /PEFKTPO)FSPLV

  38. #BDLHSPVOE+PCTͱ͔΋͍͍

  39. ͜ͷลΈͯͶ IUUQXXXTMJEFTIBSFOFULUTVKJDIBOQBSTFDPN

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

  41. 1BSTFͷՁ࣮֨ࡍ •  ສ"1*ίʔϧ݄·Ͱແྉ – ༡ͼখن໛ͳΒे෼ແྉʹऩ·Δ  •  )#'BW – ࠓͷͱ͜Ζແྉ࿮Ͱؒʹ߹ͬͯΔ •  ఔ౓

    –  SFREBZ͘Β͍͕ͩ୯ௐ૿Ճͯ͠ ΔͷͰকདྷతʹ͸ŋŋŋ
  42. ,JOWFZͷྉۚମܥ ΞΫςΟϒϢʔβʔ਺ج४Ͱ՝ۚ

  43. 1BSTFͷ͕͍͍͜͜ •  ந৅౓͕ͪΐ͏Ͳྑ͍ –  ߴ͗ͣ͢ɺ௿͗ͣ͢ –  4%,΍"1*ઃܭ͕σϕϩούͷۤ௧ΛΑ͘෼͔ͬͯΔ  •  1'2VFSZͱଞαʔϏεͱͷ࿈ܞ

    –  42-෩໰͍߹Θ͕ͤεΩʔϚϨε%#ʹՄೳ •  4%,Ͱ΋ɺ3&45"1*Ͱ΋XIFSFMJNJU –  Ϣʔβʔొ࿥ϓογϡ௨஌ొ࿥ʹ෇ਵ͢Δσʔλϕʔε Λશͯ1'2VFSZͰ໰͍߹Θͤ •  εέʔϥϏϦςΟΞϕΠϥϏϦςΟ –  ·ͬͨ͘ؾʹͤͣ࢖͍͑ͯΔ
  44. .#BB4ͷ࣮ࡍ •  Ұ౓׳ΕΔͱපΈ͖ͭʹ •  ͜Ε͚ͩͰશͯͷόοΫΤϯυ͕࿫͑Δ  –  ཁ݅ʹΑΔ΋ɺ͋Δఔ౓ͷن໛Ͱ͸೉ͦ͠͏ –  ผ్*BB41BB4ʹஔ͍ͨΞϓϦέʔγϣϯͱ

    ૊Έ߹Θͤ •  ϨΠςϯγ –  ϞόΠϧΞϓϦέʔγϣϯͰ͸ؾʹͳΒͳ͍͜ͱ ͕ଟ͍ •  εέʔϥϏϦςΟ –  લड़ͷͱ͓Γ
  45. .#BB4ͷ͕͜͜ෆ҆ •  ந৅౓ߴΊϩοΫΠϯ – ଞαʔϏε΁ͷ৐Γ׵͑ίετ͕ߴ͍ – 4%, – σʔλ͕͢΂ͯಠࣗσʔλϕʔεʹŋŋŋ •  "NB[PO4/4ʹൺ΂ͯྉۚʹׂߴײ

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

  47. "84ͱ.#BB4

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

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

  50. "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Ͱ࣮ݱ͞ΕΔ 
  51. ࣮ࡍͷͱ͜Ζ •  "84ͱ.#BB4ͷؔ܎"84ͱ 1BB4ͷؔ܎ – ࣗ෼Ͱؤுͬͯ૊Έ߹ΘͤΔͷ͕"84 – ༗ػతʹͭͳ͛ͯʮαʔϏεʯʹ࢓্͛ͯΔ Δͷ͕1BB4.#BB4 •  ଟ͘ͷ.#BB4αʔϏεͷཪ͕"84ͳͷ΋Α͘ࣅ ͍ͯΔ

  52. ྫ͑͹ϓογϡ௨஌Λ"84Ͱ΍Δͱŋŋŋ •  Ұ෦ࣗ෼Ͱ؅ཧ͢Δඞཁ – ϓογϡج൫͸"84͕΍ͬͯ͘ΕΔ – σόΠετʔΫϯͷ؅ཧ͕ඞཁ •  ΞϓϦέʔγϣϯϢʔβʔͷ*%ͱσόΠετʔΫ ϯͷϚοϐϯά͸"NB[PO͸΍Βͳ͍ –  ྫ!OBPZB@JUP㱻EFGDF

    •  ʮొ࿥ظ͕ؒҰϲ݄Ҏ಺ͷਓʹͷΈϓογϡŋŋŋʯ ͱ͔͢Δ৔߹͸ͦͷͨΊͷσʔλϕʔεΛ4΍ 3%4ʹࣗ෼Ͱผ్࣋ͭඞཁ
  53. 1BSTFͳΒ •  ֤Ϣʔεέʔε͕༗ػతʹܨ͕͍ͬͯΔ – σόΠετʔΫϯΛ1BSTFʹ༬͚Δࡍʹϝ λσʔλΛ෇༩Ͱ͖Δ – σόΠετʔΫϯ͸ࣗ෼ͷΫϥ΢υετϨʔ δʹอଘ͞ΕΔ – ͦͷϝλσʔλΛجʹ1'2VFSZͰݕࡧՄ – 4%,͔ΒͰ΋8FC"1*͔ΒͰ΋ΫΤϦՄ ೳ

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

  55. 044ͷ.#BB4

  56. )FMJPT

  57. -PPQ#BDL

  58. %FQMPZE

  59. 044#BB4 •  )FMJPT –  1BSTFͷϞσϧʹ͍ۙ •  J044%, •  3VCZͰॻ͔ΕͨόοΫΤϯυαʔϏε • 

    -PPQ#BDL –  4USPOH/PEF –  ྑͦ͞͏ɺͰ΋Α͘Έͯͳ͍͔ΒΘ͔Γ·ͤΜ •  %FQMPZE –  .#BB4ͱ͍͏ΑΓ#BB4 ˞  –  "1*όοΫΤϯυ ϞόΠϧʹ΋࢖͑Δ  ˞'JSFCBTFͱ͔ʹ͍ۙͷ͔΋
  60. $  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
  61. %  helios  server     #  or     %

     git  push  heroku  master  
  62. #  プッシュ通知の登録  (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  
  63. )FMJPTͷ࣮ࡍ •  3BDLΞϓϦ J04ϥΠϒϥϦ •  )FSPLV3FBEZ •  "'/FUXPSLJOHͷNBUUU͞Μ࡞Ϟ δϡʔϧ܈ͷάϧʔ – IPVTUPO

    DVQFSUJOP EVCBJ WFOJDF •  ࣮༻ੑ – Μʔɾɾɾ
  64. None
  65. ·ͱΊ •  .#BB4ศརͰ͢ –  1BSTF,JOWFZ͋ͨΓ͕ਓؾɺ͔ͭయܕతͳ ϞσϧέʔεͬΆ͍ –  ͚ͲɺϩοΫΠϯ͞Ε·͢ •  "84͸෦඼ɺ.#BB4͸αʔϏε

    –  ϩοΫΠϯΛආ͚Δʹ͸"84Λ૊Έ߹Θ࣮ͤͯ ૷͢Δํ͕͍͍ •  044.#BB4 –  ੝Γ্͕͖ͬͯͯΔͷ͔ɺͲ͏ͳͷ͔ –  ·༷ͩࢠݟɺͱ͍͏ͱ͜Ζ