쓰기 편하라고 웹에서 쓸 수 있게 만들어 봤다.
https://gcmsender.herokuapp.com
——————————-
클라이언트는 다 만들었으니 이젠 송신 서버를 만들어야한다.
API key 만들기
- Google Developers Console의 현재 작업 중인 프로젝트로 간다.
- APIs&auth – Credentials – Public API access – Create New Key – Server Key 를 선택한다.
- 입력란에 아무 것도 넣지 말고 Crate 버튼을 누른다.
- Key for server applications 의 API key가 송신서버에서 사용할 값이다.
송신서버 만들기
- 루비 설치
- gcm gem 설치(https://github.com/spacialdb/gcm)
- 루비 파일 생성(send.rb)
require 'gcm' gcm = GCM.new("API key in Key for server applications") registration_ids= ["phone의 reg id1", "phone의 reg id2"] options = {data: {msg: "qwerasdfzxcv"}} response = gcm.send_notification(registration_ids, options) puts response
- 루비 파일 실행
ruby send.rb
폰에서 해당 내용이 잘 오는지 확인한다.