Parse.com에서 Rubbymotion 및 Push Notification

RubbyMotion Advent Calendar 2013, 4일차.
Baas(Backend asa Service)를 대표하는 인물 Parse.퍼시노티픽을 컴으로 설치했기 때문에 파우스를 사용합니다.저는 com에 대한 인상과 소감을 쓰고 싶습니다.

설정에서 첫 번째 Push notification까지


Parse.com에 등록한 후 가장 먼저 방문한 것은Push Quick Start Guide이다.
Parse.com의 문서는 전체적으로 보면 비교적 읽기 쉽다. 이것은 내가 좋아하는 이유 중의 하나이다.
위쪽부터 순서대로 작성된 내용을 구현하고 페이지 끝에 있는 센드 테스트 푸시 버튼을 클릭하면 푸시 노티픽션이 앱이 설치된 실제 기기로 배달돼 설치가 완료된다.
뭐랄까, 모범적인 Start Guide입니다.
작성된 소스 코드는 본문의 결말에 기재되어 있습니다.

설치가 완료되면 애플리케이션이 시작됩니다.인터넷에서 무슨 일이 일어났는지


어디 보자Dashboard.
왼쪽 상단에 있는 Selectan app 드롭다운 에서 이번 테스트 애플리케이션을 선택하고 마이그레이션 후 화면 상단에 있는 Data Browser 를 클릭하면 이런 느낌의 화면.

이 화면은Parse입니다.컴이 개발사에 제공하는 키밸류형 데이터 스토어의 상태를 볼 수 있다.
두 개의 Installations Class Object가 있습니다.
※ 이번에는 두 장치에 앱을 설치했습니다.
iOS 애플리케이션의 경우com에서 Object를 만들라고 지시한 게 앱이에요.delegate.rb의 이 부분.
app_delegate.rb
  # callback of register_push_notifications
  # see https://www.parse.com/tutorials/ios-push-notifications
  def application(application, didRegisterForRemoteNotificationsWithDeviceToken:newDeviceToken)
    # Store the deviceToken in the current installation and save it to Parse.
    currentInstallation = PFInstallation.currentInstallation()
    currentInstallation.setDeviceTokenFromData(newDeviceToken)
    currentInstallation.saveInBackground()
  end
Parse.com에 HTTP를 요청했어야 하는데 Parse.SDK에 포함된 PFINstallation 클래스가 그것을 숨겼습니다.
근데 Installations Class가 뭐냐면요.및 문서입니다.
Push Notification Guide에는 설치라는 작은 제목이 있습니다.
Push Developer Guide | Parse
Installations
Every Parse application installed on a device registered for push notifications has an associated Installation object. The Installation object is where you store all the data needed to target push notifications. For example, in a baseball app, you could store the teams a user is interested in to send updates about their performance.
  • Push notioffiction을 보내는 장치를 위한 설치 object 만들기
  • installation object는 응용 사양에 따라 확장할 수 있으며 Push notification을 보내는 대상 장치에 필요한 모든 정보를 확인할 수 있습니다.
  • 이런 거.
    이 문서도 보기 쉽다.
    지금 읽는 곳 왼쪽에 내비게이션이 돋보이기 때문에 자신이 지금 무엇을 읽고 있는지 직관적으로 알 수 있다.
    지금 읽고 있는 곳은 언제든지 내비게이션에서 돌아올 수 있기 때문에 다른 신경 쓰이는 부분을 살짝 훑어본다.
    예: 여기Cloud Code Guide | Parse
    잘 모르겠지만.
  • Node.js에서.com에서 자신의 Function을 정의할 수 있음
  • 정의된 Function은 요청https://api.parse.com/1/functions/[function 名]을 통해 호출할 수 있다
  • Function 내에서 데이터 스토어에 대해 CRUD
  • 를 실행할 수 있음
  • Function과 달리 CRUD에 대한 hook
  • 도 정의할 수 있습니다.
  • 에도 Scheduller
  • 가 있습니다.
    나는 이런 말을 읽을 수 있다.

    Parse.com에 대한 인상이 바뀌었어요.


    자기가 파르세야.대상
  • Push Notification, in App Purchase 등 iOS를 비롯한 모바일 앱 구축에 필요한 Backend Service
  • 제공
    이런 인상이 있다.
    하지만 사실
  • Parse.com 제공
  • Key-Value Store
  • Key-Value Store 작업을 위한 Rest API
  • Rest API의 HTTP 요청에 대한 다양한 SDK 숨기기
  • Installation Object와 같은 특별한 Object를 제작한 경우 Push Notification 등 특별한 동작을 지원
  • 이런 분위기.
    전자와 후자는 어떤 차이가 있습니까?이렇게 물어보시면 조금 말이 막혀요.
    전자
  • 정형처리를 하면 수월하지만 조금이라도 비정규적인 일을 하면 금세 막다른 골목에 몰린다는 인상을 준다
  • 이와 상대되는 후자는
  • Parse..com에서 상상하지 못한 사용법도 여러 가지 방법으로 완성할 수 있다는 인상을 준다
  • 게다가 문서를 읽거나 SDK를 만질 때 가용성을 매우 중시한다.
    이런 상황에서 사용자는 우리의 응용 프로그램을 가리키며 사용자에 대한 사랑을 말합니까?있죠.
    그래서 좀 정식으로 이용하고 싶어요!
    (이게 무슨 총결산이야)

    최후


    RubyMotion Advent Calendar 2013, 내일 5일째naoya@github!
    주제 밖의 말, 용자두악용 Xversion 2.0 잠자는 용자와 맹우 안내은 같은 날 10:00!!

    참고 자료

  • Push Notification에 대한 공식 문서
  • About Local Notifications 및 Push Notifications(영어)
  • Local 및 Push Notification 프로그래밍 가이드(일본어)
  • Installation Object 기반 Parsecom 뭐 해요?
  • Provider Communication with Apple Push Notification Service
  • 소스 코드 Gemfile source 'https://rubygems.org' gem 'rake' gem 'motion-cocoapods' gem "bubble-wrap", :require => "bubble-wrap/all" Rakefile # -*- coding: utf-8 -*- $:.unshift("/Library/RubyMotion/lib") require 'motion/project/template/ios' begin require 'bundler' Bundler.require rescue LoadError end Motion::Project::App.setup do |app| # Use `rake config' to see complete project settings. app.name = 'pushtest' app.identifier = "자신의 app indentifier" # Parse.com 의존 라이브러리 # see https://parse.com/apps/quickstart_push#ios/native/existing app.frameworks += [ "AudioToolbox", "CFNetwork", "CoreGraphics", "CoreLocation", "MobileCoreServices", "QuartzCore", "Security", "StoreKit", "SystemConfiguration" ] app.libs += ["/usr/lib/libz.dylib"] # Parse.com SDK app.vendor_project( 'vendor/Parse.framework', :static, :products => ['Parse'], :headers_dir => 'Headers' ) # Parse.com SDK 종속 Objective-C 라이브러리 app.pods do pod 'Facebook-iOS-SDK' end app.development do #Provisioning 소개 경로 #Provisioning Profile을 만드는 방법은 # → https://www.parse.com/tutorials/ios-push-notifications app.provisioning_profile = "" #이 줄이 없으면'aps-environment'error가 돌아온다 # TODO: at release, see http://kametaro.wordpress.com/2011/09/21/appstore%E3%81%8B%E3%82%89%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB%E3%81%97%E3%81%9F%E3%82%A2%E3%83%97%E3%83%AA/ app.entitlements['aps-environment'] = 'development' end end app_delegate.rb class AppDelegate def application(application, didFinishLaunchingWithOptions:launchOptions) self.register_push_notifications(application) self.configure_parse_service(launchOptions) @window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds) @window.rootViewController = HelloViewController.new @window.makeKeyAndVisible true end def application(application, didFailToRegisterForRemoteNotificationsWithError:error) if (error.code == 3010) App.alert("Push notifications don't work in the simulator!") else App.alert("didFailToRegisterForRemoteNotificationsWithError: #{error.code}, #{error.domain}, #{error.userInfo}") end end def register_push_notifications(application) application.registerForRemoteNotificationTypes( UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound) end def configure_parse_service(launchOptions) # see https://parse.com/apps/pushtest--177/edit#app_keys Parse.setApplicationId( "Parse.com의 애플 Id", clientKey: "Parie.com의 client key", ) PFAnalytics.trackAppOpenedWithLaunchOptions(launchOptions) end # callback of register_push_notifications # see https://www.parse.com/tutorials/ios-push-notifications def application(application, didRegisterForRemoteNotificationsWithDeviceToken:newDeviceToken) # Store the deviceToken in the current installation and save it to Parse. currentInstallation = PFInstallation.currentInstallation() currentInstallation.setDeviceTokenFromData(newDeviceToken) currentInstallation.saveInBackground() end def application(application, didReceiveRemoteNotification:userInfo) PFPush.handlePush(userInfo) end end hello_view_controller.rb # -*- coding: utf-8 -*- class HelloViewController < UIViewController def viewDidLoad super view.backgroundColor = UIColor.blueColor end end

    좋은 웹페이지 즐겨찾기