Giter VIP home page Giter VIP logo

igetui-ruby's Introduction

IGeTui::Ruby

个推服务端 ruby-sdk

Installation

Add this line to your application's Gemfile:

gem 'igetui-ruby', require: 'igetui'

And then execute:

$ bundle

Or install it yourself as:

$ gem install igetui-ruby

Usage

Push Message To Single

pusher = IGeTui.pusher(your_app_id, your_app_key, your_master_secret)

# 创建通知模板
template = IGeTui::NotificationTemplate.new
template.logo = 'push.png'
template.logo_url = 'http://www.igetui.com/wp-content/uploads/2013/08/logo_getui1.png'
template.title = '测试标题'
template.text = '测试文本'

# 创建单体消息
single_message = IGeTui::SingleMessage.new
single_message.data = template

# 创建客户端对象
client = IGeTui::Client.new(your_client_id)

# 发送一条通知到指定的客户端
ret = pusher.push_message_to_single(single_message, client)
p ret

Push Message To List

pusher = IGeTui.pusher(your_app_id, your_app_key, your_master_secret)

# 创建一条透传消息
template = IGeTui::TransmissionTemplate.new
# Notice: content should be string.
content = {
            action: "notification",
            title: "标题aaa",
            content: "内容",
            type: "article",
            id: "4274"
          }
content = content.to_s.gsub(":", "").gsub("=>", ":")
template.transmission_content = content
# 设置iOS的推送参数,如果只有安卓 App,可以忽略下面一行
# template.set_push_info("", 1, "这里是iOS推送的显示信息", "")

# 创建群发消息
list_message = IGeTui::ListMessage.new
list_message.data = template

# 创建客户端对象
client_1 = IGeTui::Client.new(your_client_id_1)
client_2 = IGeTui::Client.new(your_client_id_2)
client_list = [client_1, client_2]

content_id = pusher.get_content_id(list_message)
ret = pusher.push_message_to_list(content_id, client_list)

Push Message To App

pusher = IGeTui.pusher(your_app_id, your_app_key, your_master_secret)

# 创建通知模板
template = IGeTui::NotificationTemplate.new
template.logo = 'push.png'
template.logo_url = 'http://www.igetui.com/wp-content/uploads/2013/08/logo_getui1.png'
template.title = '测试标题'
template.text = '测试文本'

# 创建APP群发消息
app_message = IGeTui::AppMessage.new
app_message.data = template
app_message.app_id_list = [your_app_id]

# 发送一条通知到程序
ret = pusher.push_message_to_app(app_message)
p ret

Custom Test

require 'rubygems'
require 'igetui'

@pusher = IGeTui.pusher(your_app_id, your_app_key, your_master_secret)
ret = @pusher.get_client_id_status(your_client_id)
p ret

Auto Test

运行测试之前,请先修改 test/pusher_test.rb 中的相关配置。

rake test

Documents

Contributing

  1. Fork it ( http://github.com/wjp2013/igetui-ruby/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

igetui-ruby's People

Contributors

eric-guo avatar giaogiaocat avatar oldfritter avatar u2 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.